Spaces:
Paused

kalpi314 commited on
Commit
c86091f
Β·
verified Β·
1 Parent(s): cee6a0c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +65 -18
README.md CHANGED
@@ -1,29 +1,62 @@
1
  ---
2
- title: Live Whisper Speech To Text
3
  emoji: πŸŽ™οΈ
4
  colorFrom: blue
5
  colorTo: purple
6
  sdk: gradio
7
- sdk_version: 4.44.0
8
  app_file: app.py
9
  pinned: false
 
10
  ---
11
 
12
- # Live Speech-to-Text (Whisper tiny.en)
13
 
14
- A minimal, real-time speech-to-text demo built with Gradio and a small
15
- Whisper model (`openai/whisper-tiny.en`, ~39M params) so it runs
16
- comfortably on the free CPU tier.
 
 
 
17
 
18
  ## How it works
19
 
20
- - The browser streams short microphone chunks to the app via
21
- `gr.Audio(streaming=True)`.
22
- - Each chunk is appended to a rolling buffer (capped at 30s so latency
23
- stays low during long sessions).
24
- - The Whisper pipeline re-transcribes the buffer on every chunk, so the
25
- textbox updates live as you speak.
26
- - "Clear transcript" resets the buffer.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
  ## Run locally
29
 
@@ -32,9 +65,23 @@ pip install -r requirements.txt
32
  python app.py
33
  ```
34
 
35
- ## Swapping the model
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
- Edit `MODEL_ID` in `app.py`:
38
- - `openai/whisper-tiny.en` β€” fastest, English-only (default)
39
- - `openai/whisper-base.en` β€” a bit more accurate, still fast, English-only
40
- - `openai/whisper-tiny` β€” multilingual, similar speed to tiny.en
 
1
  ---
2
+ title: Live Whisper MLX Speech To Text
3
  emoji: πŸŽ™οΈ
4
  colorFrom: blue
5
  colorTo: purple
6
  sdk: gradio
7
+ sdk_version: 6.26.0
8
  app_file: app.py
9
  pinned: false
10
+ suggested_hardware: cpu-basic
11
  ---
12
 
13
+ # Live Speech-to-Text β€” Whisper on MLX
14
 
15
+ Real-time transcription with `openai/whisper-tiny.en` running on
16
+ [MLX](https://github.com/ml-explore/mlx). **No PyTorch anywhere in the
17
+ dependency tree** β€” 35 packages installed, none of them torch.
18
+
19
+ Built for Apple Silicon, where MLX uses Metal. It still builds and runs
20
+ on Hugging Face's free Linux CPU tier via `mlx[cpu]`.
21
 
22
  ## How it works
23
 
24
+ - The browser streams microphone chunks via `gr.Audio(streaming=True)`.
25
+ - Each chunk is converted to mono, resampled to 16 kHz with an
26
+ anti-aliased polyphase filter, and turned into a mel spectrogram.
27
+ - A per-session **AlignAtt streaming decoder** consumes each chunk and
28
+ emits only the tokens its cross-attention says have settled.
29
+
30
+ ### Why streaming, not a rolling buffer
31
+
32
+ The obvious approach β€” keep the last N seconds of audio and re-run
33
+ `model.generate()` on it every chunk β€” costs more as the buffer grows,
34
+ and hallucinates. Measured on one 2.8s clip of real speech:
35
+
36
+ | approach | output |
37
+ |---|---|
38
+ | `generate()` on the buffer | `The quick brown fox jumps over the lazy dog. The The The The The The…` |
39
+ | streaming decoder | `the` β†’ `quick brown fox` β†’ `jumps over` β†’ `the lazy dog.` |
40
+
41
+ Whisper pads its input to 30 seconds internally and keeps decoding into
42
+ that padding, so the filler is structural rather than bad luck β€” it
43
+ survived greedy decoding, disabling `condition_on_previous_text`, and
44
+ trimming trailing silence. The streaming decoder never has the problem
45
+ because it only emits what the audio actually supports.
46
+
47
+ Throughput on an M-series Mac: roughly **8Γ— realtime** for `tiny.en`.
48
+
49
+ ## Hardware
50
+
51
+ Designed for **`cpu-basic`**. Requesting a GPU tier has a cost beyond the
52
+ bill: a Space set to ZeroGPU (`zero-a10g`) can only run on Hugging Face's
53
+ infrastructure, because ZeroGPU apps are expected to import the `spaces`
54
+ package and decorate their entrypoints β€” which makes the Space
55
+ unrunnable anywhere else, including on your own machine.
56
+
57
+ `suggested_hardware` above only advises people who *duplicate* this
58
+ Space. The tier this Space actually runs on is a repository setting β€”
59
+ **Settings β†’ Hardware** in the Space UI β€” and must be changed there.
60
 
61
  ## Run locally
62
 
 
65
  python app.py
66
  ```
67
 
68
+ Or through [sidepage](https://github.com/kalpi-4/sidepage), which fetches
69
+ the Space, shows you the plan, and asks before running anything:
70
+
71
+ ```bash
72
+ sidepage pull huggingface.co/spaces/<owner>/<name>
73
+ sidepage serve <name> # prompts for confirmation, then serves
74
+ sidepage serve <name> --anon # ...and gives you a public URL
75
+ ```
76
+
77
+ ## Tuning
78
+
79
+ | Variable | Default | What it does |
80
+ |---|---|---|
81
+ | `WHISPER_MODEL` | `openai/whisper-tiny.en` | `openai/whisper-base.en` is more accurate and slower; `openai/whisper-small.en` more so |
82
+ | `WHISPER_STREAM_EVERY` | `0.75` | Seconds between chunks β€” lower is more responsive, and more CPU |
83
 
84
+ Use the standard `openai/*` repos, not the pre-converted
85
+ `mlx-community/whisper-*-mlx` ones: mlx-audio converts the weights itself
86
+ on load and needs the Hugging Face processor files, which those repos
87
+ don't ship. Loading one fails with *"Processor not found."*