Spaces:
No application file
No application file
Download App.py from Purnachary/ASR: direct link, hf CLI and curl.
- Browser
- Download file 787 Bytes
-
https://huggingface.co/spaces/Purnachary/ASR/resolve/main/App.py
- Command line
-
hf download hf://spaces/Purnachary/ASR/App.py
-
curl -L -o App.py https://huggingface.co/spaces/Purnachary/ASR/resolve/main/App.py
787 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # Load Whisper pipeline | |
| pipe = pipeline(task="automatic-speech-recognition", model="openai/whisper-small") | |
| # Function to transcribe audio file | |
| def transcribe(audio_file): | |
| if audio_file is None: | |
| return "Please upload an audio file." | |
| return pipe(audio_file)["text"] | |
| # Gradio Interface | |
| with gr.Blocks() as app: | |
| gr.Markdown("## 🎙️ Whisper Speech-to-Text (ASR)\nUpload or record audio and get transcription.") | |
| with gr.Row(): | |
| audio_input = gr.Audio(type="filepath", label="Upload or Record Audio") | |
| output_text = gr.Textbox(label="Transcription") | |
| transcribe_btn = gr.Button("Transcribe") | |
| transcribe_btn.click(fn=transcribe, inputs=audio_input, outputs=output_text) | |
| app.launch() |