You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WAV response with stream=false is not finalised: RIFF and data sizes stay 0xFFFFFFFF #586
A non-streamed WAV response carries 0xFFFFFFFF in both the RIFF chunk size and the data chunk size. A 144,168-byte file reports 4,294,967,295 for both; the real values are 144,160 and 144,090. Python's wave reads it as 89,478 seconds.
The header is the WAV file's own 44-byte RIFF/WAVE header, not an HTTP header. The engine writes it; the client that reads the file uses the two size fields to compute duration. The defect is on the engine side; the symptom is on the client side.
The sentinel is deliberate for streaming (PR #94): the engine does not know the final size while sending, so it writes a placeholder and patches it at the end. With stream: false the file is complete and the length is known, but the non-streaming branch never runs the finalise step. In api/src/routers/openai_compatible.py the non-streaming branch returns Response(content=output, ...) from tts_service.generate_audio, which concatenates the writer's per-chunk drains; StreamingAudioWriter.finalize() is only called in the return_download_link branch.
Repro:
docker run --rm -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-cpu:latest
The body starts 52 49 46 46 ff ff ff ff 57 41 56 45 (RIFF....WAVE).
Versions: api/src/services/streaming_audio_writer.py is blob 5f9b598 in v0.9.1, v0.9.2 and master, so this is not fixed on any branch. #497 fixed the flush ordering and #94 introduced the sentinel; this is the case both leave alone.
Suggested fix: finalise the writer before building the Response in the non-streaming branch, as return_download_link already does, or patch the two size fields after concatenation.
Opened a PR for this: #587. It writes the real sizes once generate_audio has joined the chunks, and walks to the data chunk because ffmpeg puts a LIST chunk ahead of it, so the size is not at offset 40.
Activity
somaz94 commentedon Nov 5, 2026
Opened a PR for this: #587. It writes the real sizes once
generate_audiohas joined the chunks, and walks to the data chunk because ffmpeg puts a LIST chunk ahead of it, so the size is not at offset 40.