Bound HTTP STT windows while preserving long user turns #723
@jackboyla do you want to review this one?
<!-- ccr-overview-v2 -->
🟢 Approval recommended
No blocking issues were identified in windowing, cache invalidation, configuration wiring, or cancellation and session safeguards.
0 open findings
<details>
<summary><strong>What changed in this PR</strong></summary>
Adds opt-in bounded HTTP transcription windows to handle long user turns without changing conversational boundaries or default uploads.
Changes:
| File | Description |
| ---- | ----------- |
| tests/test_openai_stt_windows.py | Tests bounded requests, transcript preservation, and lifecycle safeguards. |
| tests/test_openai_stt_handler.py | Tests sanitized backend rejection messages. |
| tests/test_backend_registry.py | Tests window configuration wiring. |
| src/speech_to_speech/VAD/vad_handler.py | Supplies internal snapshots independently of captions. |
| src/speech_to_speech/STT/openai_compatible_handler.py | Implements bounded windows, prefix caching, and rejection guidance. |
| src/speech_to_speech/s2s_pipeline.py | Connects window settings to VAD and STT. |
| src/speech_to_speech/arguments_classes/openai_stt_arguments.py | Adds the optional window-duration argument. |
| docs/openai-compatible-stt.md | Explains configuration, behavior, and limitations. |
</details>
🧠 Review effort: Balanced
---
💡 <a href="/huggingface/speech-to-speech/new/main?filename=.github/skills/code-review/SKILL.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add a code-review agent skill</a> or configure MCP servers for context-aware, tailored reviews. <a href="https://docs.github.com/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review?tool=webui#mcp-servers-and-agent-skills" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn more in the docs.</a>
@jackboyla do you want to review this one?
taking a look now 👀
nit: keeps mypy happy on py310 and py311 with the same hashes
return hashlib.sha256(np.ascontiguousarray(audio).data.cast("B")).digest()
Approved these changes.
looks sound in the normal pipeline. i don't have any issues apart from the nit above
92 stt tests and both type targets pass with the suggestion
jackboyla
andimarafioti
Fixes #655.
Long or repeatedly reopened user turns currently submit cumulative WAVs to the HTTP STT backend. Qwen3-ASR served by vLLM can reject those uploads at its configurable duration/file-size limits; progressive updates also repeatedly decode the completed prefix.
Add opt-in
--openai_stt_max_window_s 120(also available in configured STT blocks). Completed windows retain their text across revisions, and the tail remains revisable. VAD exposes a backend-independent cadence for cumulative progressive audio snapshots, including when live captions are disabled. The current pipeline enables that capability for this HTTP backend; downstream STT owns slicing and caching. The final transcript still uses the existing conversational-turn and response-admission path. Leaving the option unset preserves current uploads.Cuts select the quietest 100 ms frame midpoint in the five seconds before the cap. They remain bounded without silence, cover every sample, and use no overlap or text deduplication. This follows the investigated two-minute direction without requiring unavailable timestamps. Changed audio/language invalidates cached text; existing cancellation/session fences guard commits and outputs. Known HTTP duration/file-size rejections now provide fixed, sanitized guidance.
The VAD snapshot contract documents the input-sample cadence, cumulative audio, continued capture, and final-prefix caveat. Held short fragments can be added only at finalization, so consumers must handle changed audio rather than assume every snapshot is an exact final prefix. The existing snapshot test now lives in a VAD test module; backend-specific upload/cache assertions stay in the HTTP STT tests.
Scope excludes streaming transports (#536/#537), aligners, global inference scheduling, and a total VAD-memory cap. Quiet points are not guaranteed word boundaries; recognition errors and server backlogs remain possible.
Validation performed locally:
- Settings: MLX Audio 0.4.7, greedy English decoding, independent requests without carried text, and no internal model chunking. WER used Whisper's English normalizer and spelling map, checked with jiwer 4.0.0.
- Model
mlx-community/Qwen3-ASR-1.7B-bf16@e1f6c266914abc5a46e8756e02580f834a6cf8a7. Dataset mirrorilyakam/librispeech-long@a5bb3ef1a678743ef6c6d1014f8f731d8c56c5e7(LibriSpeech-Long). Test IDs:1089-134686-0000through0002joined in order (11m41s, the longest input),1188-133604-0000, and test-other1688-142285-0000.- This pilot does not describe recognition quality on vLLM. vLLM 0.28.0 splits Qwen3-ASR audio longer than 30 s into chunks itself (
max_audio_clip_sis the model'schunk_length, which is 30). On vLLM, the client cap therefore bounds request size and repeated work, not the recognition chunk length.Compatibility assessment uses OpenAI's multipart transcription contract, vLLM 0.28 service limits, and duration validation. No Realtime event, WebRTC/RTP, codec, or item-identity change. Local browser checks supplement source inspection; tests alone are not protocol proof.
Deployment vLLM throughput and speech-paced end-of-turn latency are unverified. The measured improvement is bounded upload size and less repeated completed audio; no production latency or capacity claim is made. Total VAD audio memory remains cumulative.
Fresh independent review of the documentation trim recommended approve, with no actionable blockers or approval-blocking evidence gaps. It found the remaining guide additions useful and proportionate, and confirmed changes were limited to prose, docstrings/comments, and help metadata. The reviewer independently passed 138 tests with four loopback HTTP tests deselected; the implementing-agent 106-test run above included loopback. No new tests, fixtures, runtime logic, or protocol behavior were added.
CI for the documentation trim passed all 17 jobs, including full Python 3.11–3.14 tests, Linux/macOS installation, lint, types, packaging, and Agents SDK compatibility. These are CI results, separate from the local checks above.