| # Let's get pipelines from transformers | |
| from transformers import pipeline | |
| # Let's import Gradio | |
| import gradio as gr | |
| # Let's set up the model | |
| model = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-large-xlsr-53-spanish") | |
| title = "Audio2Text" | |
| description = "Record your audio in Spanish and send it in order to received a transcription" | |
| # Function | |
| def transcribe(audio): | |
| # Let's invoke "model" defined above | |
| text = model(audio)["text"] | |
| return text | |
| # Interface Set-Up | |
| gr.Interface( | |
| fn=transcribe, | |
| inputs=[gr.Audio(sources=["microphone"], type="filepath")], | |
| outputs=["textbox"] | |
| ).launch() |