feat(stt): transcribe long audio via overlapping Whisper chunks
Summary
- Adds
backend/utils/whisper_stt.pyto window audio longer than Whisper'''s ~30s limit into overlapping 30s chunks (5s stride) - Wires
PyTorchSTTBackend.transcribe()through the shared helper so Captures,/transcribe, and dictation get full-file transcripts on PyTorch backends (Windows CUDA, Linux, etc.) - Includes unit tests for chunking and text joining
Motivation
Whisper only accepts ~30 seconds of audio per forward pass. Without chunking, longer captures (videos, podcasts, meeting recordings) were truncated or incomplete.
Test plan
- [x]
pytest backend/tests/test_whisper_stt_chunks.py(3 tests pass) - [ ] Manual: upload a >60s capture in Captures tab and verify full transcript
- [ ] Manual:
POST /transcribewith a long audio file
Notes
- MLX (Apple Silicon) path unchanged β MLX Whisper already accepts file paths directly
- Chunk overlap may produce minor duplicate words at window boundaries; acceptable tradeoff for full coverage
Summary by CodeRabbit
-
New Features
- Added longer-audio speech recognition support with overlapping chunks for more reliable transcription.
- Improved PyTorch-based transcription handling for better end-to-end voice input support.
-
Documentation
- Added a developer setup guide with local installation, startup steps, troubleshooting tips, and GPU/VRAM guidance.
-
Tests
- Added coverage for audio chunking and transcript merging behavior.
π Walkthrough
Walkthrough
This PR adds Whisper long-form transcription chunking utilities (backend/utils/whisper_stt.py), refactors pytorch_backend.py to delegate to the new helper, adds accompanying unit tests, introduces a Windows-specific Python requirements file, and adds a developer setup/workflow guide document.
Changes
Whisper Long-Form Transcription
| Layer / File(s) | Summary |
|---|---|
Chunking and transcription helper backend/utils/whisper_stt.py |
Adds constants for chunk/stride sizing, iter_whisper_chunks for overlapping windowing, join_whisper_chunk_texts for filtering/joining text, and transcribe_whisper_pytorch to run per-chunk Whisper inference with optional forced decoder IDs. |
Backend integration backend/backends/pytorch_backend.py |
Replaces inline Whisper feature extraction, generation, and decoding in _transcribe_sync with a call to transcribe_whisper_pytorch. |
Chunking unit tests backend/tests/test_whisper_stt_chunks.py |
Adds tests for single-chunk short audio, multi-chunk overlap behavior, and text-joining filtering. |
Windows Setup Dependencies and Developer Guide
| Layer / File(s) | Summary |
|---|---|
Windows backend requirements backend/requirements-win-setup.txt |
Adds a full dependency list covering web/API, database, ML, and multiple TTS engine dependencies (LuxTTS, Chatterbox, HumeAI, Kokoro) plus audio, HTTP, and MCP utilities. |
Developer guide document VOICEBOX_DEV_GUIDE.md |
Adds environment summary, startup instructions for backend/Tauri, VRAM management guidance for a 6GB GPU, and initial setup notes. |
Estimated code review effort: 3 (Moderate) | ~25 minutes
Sequence Diagram(s)
sequenceDiagram
participant PytorchBackend
participant WhisperSTT as transcribe_whisper_pytorch
participant Chunker as iter_whisper_chunks
participant Model as WhisperModel
PytorchBackend->>WhisperSTT: transcribe_whisper_pytorch(audio, processor, model, device, language)
WhisperSTT->>Chunker: iter_whisper_chunks(audio)
Chunker-->>WhisperSTT: overlapping audio chunks
loop for each chunk
WhisperSTT->>Model: generate(chunk, forced_decoder_ids)
Model-->>WhisperSTT: decoded text
end
WhisperSTT-->>PytorchBackend: join_whisper_chunk_texts(texts)
Possibly related PRs
- jamiepine/voicebox#262: Both PRs modify the PyTorch Whisper transcription path in
backend/backends/pytorch_backend.pyaround language handling andforced_decoder_idslogic.
π₯ Pre-merge checks | β 4 | β 1
β Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | β οΈ Warning | Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
β Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | β Passed | Check skipped - CodeRabbitβs high-level summary is enabled. |
| Title check | β Passed | The title clearly matches the main change: long-audio Whisper transcription using overlapping chunks. |
| Linked Issues check | β Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | β Passed | Check skipped because no linked issues were found for this pull request. |
β¨ Finishing Touches
π§ͺ Generate unit tests (beta)
- [ ] Create PR with unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
This addresses #626. Confirming the bug is not limited to imported files β the live dictation path is affected too (Voicebox 0.5.0, Windows 11, CUDA/PyTorch backend): captures over ~30s record and play back in full, but only the first ~30s are transcribed.
Since this PR wires the chunking through PyTorchSTTBackend, it should cover that path as well. Happy to test a build.
The 30s-per-forward-pass limit is real and worth fixing, but as written the overlap is never removed, so every overlapped region is emitted twice.
iter_whisper_chunks steps by CHUNK - STRIDE (25s), so consecutive windows share 5s, and join_whisper_chunk_texts concatenates with a plain space. Running the helper as-is over a 90s input:
0.0s -> 30.0s
25.0s -> 55.0s <-- overlaps the previous by 5s
50.0s -> 80.0s <-- overlaps the previous by 5s
75.0s -> 90.0s <-- overlaps the previous by 5s
4 chunks covering 105s of audio for a 90s file - 15s transcribed twice
Any speech inside those 5s bands is heard by two windows and appears twice in the joined text:
'the note said nothing at all no name no name no number just a date
just a date by the time anyone checked anyone checked the file was gone'
The overlap itself is the right instinct β it stops a word being cut in half at a boundary β but it has to be used as context and then trimmed, rather than concatenated. That's what transformers' own pipeline("automatic-speech-recognition", chunk_length_s=30, stride_length_s=5) does: it drops the stride regions from each chunk's output using token timestamps, so boundaries are covered without duplication. Delegating to it (or reimplementing the trim with return_timestamps=True) would fix this and remove most of transcribe_whisper_pytorch.
Worth noting that the current tests can't catch it. test_iter_whisper_chunks_long_audio_multiple_windows asserts sum(len(c) for c in chunks) > len(audio), which asserts the double-counting is present rather than that it's handled, and the join test only checks empty strings are skipped. A test that transcribes known speech spanning a boundary and asserts each word appears once would pin the behaviour.
Found this while building against the backend from outside β happy to be wrong if the duplication is trimmed somewhere downstream that I've missed.
Thanks for this, @deepakmaseeh. The same fix landed on main via #1151 (long-form Whisper transcription using transformers' built-in sequential decoding, so clips over 30 seconds are no longer truncated), which took a library-native route to the same result as your overlapping-chunk approach, so we're closing this one as superseded. It ships in 0.6.0, now cut and waiting on an Apple notarization block.