Spaces:
Sleeping
Sleeping
# -*- 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 | |