whisper-flow · docs/performance
Making whisper-flow faster
Almost all of the server's time goes to Whisper inference, and the streaming loop runs inference more often than it needs to. This page shows where the time goes and the changes that win it back, ranked by impact. The written plan with file references is in performance.md.
The animations are illustrative and use made-up durations, not measurements. Step 0 of the plan is to measure.
Where the time goes
Audio arrives in 64 ms chunks and joins the current window. The loop sends the window to Whisper again and again to produce partials. The Whisper box is busy almost all the time; the WebSocket, JSON and numpy steps around it are tiny next to it.
One utterance, today vs. after items 4 and 6
Today the loop re-transcribes back to back, including while only silence is arriving, and when the segment ends by silence it runs one more full pass to make the final. With paced re-transcription (6) and the last partial reused as the final (4), the same utterance uses fewer calls and its final arrives sooner.
Whisper pads every window to 30 seconds Highitem 3
The encoder always runs on 30 s of input, so a 2.5 s window costs as much encoder time as a
full 30 s one. whisper.cpp's audio_ctx sizes the encoder to the real audio plus a
margin. It needs the whisper.cpp backend (item 1).
Encoder input: 30 s for 2.5 s of speech.
Consecutive partials must agree Mediumitem 5
Words are committed (and their audio dropped from the window) only when two consecutive
partials agree on them, and only outside the last WF_COMMIT_MARGIN_MS. With
temperature=0.1 Whisper samples, so the same audio can come back worded
differently and little gets committed. Greedy decoding gives the same answer for the same
audio.
The full list, by impact
Each item can be its own PR. Details and file references are in performance.md.
Suggested order
One-liners: fp16 on CUDA (2) and greedy decoding (5)
A free speedup on NVIDIA, and partials that agree sooner, so words commit and segments close sooner.
Loop changes in streaming.py: reuse the final (4) and pace calls (6)
Finals arrive one inference sooner, and one server handles more sessions.
New backends: whisper.cpp / faster-whisper (1) with audio_ctx (3)
The biggest change and the biggest gain. Do it with step 0's measurements in place to show the improvement.