Download app.py from Devion333/wave2vec2: direct link, hf CLI and curl.
- Browser
- Download file 630 Bytes
-
https://huggingface.co/spaces/Devion333/wave2vec2/resolve/main/app.py
- Command line
-
hf download hf://spaces/Devion333/wave2vec2/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Devion333/wave2vec2/resolve/main/app.py
630 Bytes
| import os | |
| os.environ["TRANSFORMERS_NO_TF"] = "1" | |
| from transformers import pipeline | |
| import gradio as gr | |
| # Explicitly define the task so HF knows it's ASR | |
| pipe = pipeline( | |
| task="automatic-speech-recognition", | |
| model="Devion333/wav2vec2-xls-r-300m-dv" | |
| ) | |
| def transcribe(audio): | |
| return pipe(audio)["text"] | |
| demo = gr.Interface( | |
| fn=transcribe, | |
| inputs=gr.Audio(sources=["microphone", "upload"], type="filepath"), | |
| outputs="text", | |
| title="Wav2Vec2 ASR Demo", | |
| description="Realtime demo for English speech recognition using Devion333/wav2vec2-xls-r-300m-dv." | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |