Spaces:
Sleeping
Sleeping
File size: 1,462 Bytes
84f2a5a 5aabe28 84f2a5a c8abb49 84f2a5a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# -*- coding: utf-8 -*-
"""whisper_microphone.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1nvViL6jAkzpXX3quqkz2I44m70S-YN8t
# Using gradio for making a nice UI.
Upload audio file version.
Installing requirements.
"""
#!pip install gradio
#!pip install git+https://github.com/huggingface/transformers
from transformers import pipeline
import gradio as gr
import os
"""## Building a Demo
Now that we've fine-tuned our model we can build a demo to show
off its ASR capabilities! We'll make use of 🤗 Transformers
`pipeline`, which will take care of the entire ASR pipeline,
right from pre-processing the audio inputs to decoding the
model predictions.
Running the example below will generate a Gradio demo where can input audio to
our fine-tuned Whisper model to transcribe the corresponding text:
"""
from transformers import WhisperTokenizer
from transformers import WhisperProcessor
pipe = pipeline(model="Victorlopo21/whisper-medium-gl-30")
# change to "your-username/the-name-you-picked"
def transcribe(audio):
text = pipe(audio)['text']
return text
iface = gr.Interface(
fn=transcribe,
inputs=gr.Audio(source='microphone', type="filepath"),
outputs="text",
title="Whisper Medium Galician",
description="Realtime demo for Galician speech recognition using a fine-tuned Whisper medium model.",
)
iface.launch(debug=True)
# TO TRY
|