Spaces:
Runtime error
Runtime error
Download app.py from devcharmander/toast-master: direct link, hf CLI and curl.
- Browser
- Download file 639 Bytes
-
https://huggingface.co/spaces/devcharmander/toast-master/resolve/main/app.py
- Command line
-
hf download hf://spaces/devcharmander/toast-master/app.py
-
curl -L -o app.py https://huggingface.co/spaces/devcharmander/toast-master/resolve/main/app.py
639 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| import numpy as np | |
| model_path = "ggml-small.en-tdrz.bin" | |
| transcriber = pipeline("automatic-speech-recognition", model=model_path) | |
| def transcribe(stream, new_chunk): | |
| sr, y = new_chunk | |
| y = y.astype(np.float32) | |
| y /= np.max(np.abs(y)) | |
| if stream is not None: | |
| stream = np.concatenate([stream, y]) | |
| else: | |
| stream = y | |
| return stream, transcriber({"sampling_rate": sr, "raw": stream})["text"] | |
| demo = gr.Interface( | |
| transcribe, | |
| ["state", gr.Audio(sources=["microphone"], streaming=True)], | |
| ["state", "text"], | |
| live=True, | |
| ) | |
| demo.launch() | |