Spaces:
Build error
Build error
Download app.py from GenAICoder/Audio_Transcript1: direct link, hf CLI and curl.
- Browser
- Download file 1.09 kB
-
https://huggingface.co/spaces/GenAICoder/Audio_Transcript1/resolve/07a6fb4b7ffc06eff4cfa8f25acc1e341c054245/app.py
- Command line
-
hf download hf://spaces/GenAICoder/Audio_Transcript1@07a6fb4b7ffc06eff4cfa8f25acc1e341c054245/app.py
-
curl -L -o app.py https://huggingface.co/spaces/GenAICoder/Audio_Transcript1/resolve/07a6fb4b7ffc06eff4cfa8f25acc1e341c054245/app.py
1.09 kB
| !pip install transformers | |
| !pip install gradio | |
| from transformers import pipeline | |
| import os | |
| import gradio as gr | |
| asr = pipeline(task="automatic-speech-recognition", | |
| model="distil-whisper/distil-small.en") | |
| demo = gr.Blocks() | |
| def transcribe_speech(filepath): | |
| if filepath is None: | |
| gr.Warning("No audio found, please retry.") | |
| return "" | |
| output = asr(filepath) | |
| return output["text"] | |
| mic_transcribe = gr.Interface( | |
| fn=transcribe_speech, | |
| inputs=gr.Audio(sources="microphone", | |
| type="filepath"), | |
| outputs=gr.Textbox(label="Transcription", | |
| lines=3), | |
| allow_flagging="never") | |
| file_transcribe = gr.Interface( | |
| fn=transcribe_speech, | |
| inputs=gr.Audio(sources="upload", | |
| type="filepath"), | |
| outputs=gr.Textbox(label="Transcription", | |
| lines=3), | |
| allow_flagging="never", | |
| ) | |
| with demo: | |
| gr.TabbedInterface( | |
| [mic_transcribe, | |
| file_transcribe], | |
| ["Transcribe Microphone", | |
| "Transcribe Audio File"], | |
| ) | |
| demo.launch(share=True) |