Skip to content

fix(audio): write real sizes into non-streamed WAV headers - #587

Merged
remsky merged 2 commits into
remsky:masterfrom
somaz94:fix/non-stream-wav-header-sizes
Nov 13, 2026
Merged

remsky merged 2 commits into
remsky:masterfrom
somaz94:fix/non-stream-wav-header-sizes

Conversation

@somaz94

@somaz94 somaz94 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Non-streamed WAV ("stream": false) kept the streaming placeholder 0xFFFFFFFF in the RIFF and data chunk sizes, so readers that trust the header, like Python's wave, saw a one-sentence file as about 25 hours long. StreamingAudioWriter reads the buffer before the container closes on purpose, since a stream cannot know its final length, and generate_audio joined those chunks as they were. Once the chunks are joined the length is known, so generate_audio now writes the real RIFF size and walks the chunks to data (ffmpeg puts a LIST chunk before it, so it is not at offset 36) to write its size too. Streaming responses are unchanged. The non-stream branch of /v1/audio/speech, its download link and /dev/captioned_speech all go through generate_audio, so all three get the fix.

The new test feeds real StreamingAudioWriter WAV chunks through generate_audio and checks the RIFF size and wave.getnframes(). It failed before the change with a RIFF size of 4294967295. uv run pytest gives 669 passed and 9 skipped, ruff check . passes, and the changed files are formatted. I used Claude Code to help trace this and write the change, and I reviewed and tested it myself.

Closes #586

Testing

  • uv run pytest passes locally (API changes)
  • npm run test:web passes locally (web player changes)
  • New or changed behavior has a test
  • Ran in Docker (npm run cpu:up / gpu:up), for inference or docker changes
  • CHANGELOG.md entry, if users will notice the change

@somaz94
somaz94 force-pushed the fix/non-stream-wav-header-sizes branch from bc26c4c to 9f2a49f Compare November 13, 2026 01:47
@remsky
remsky merged commit a6d1d6e into remsky:master Nov 13, 2026
4 checks passed
@remsky

remsky commented Nov 13, 2026

Copy link
Copy Markdown
Owner

Thanks for the fix, merged in @somaz94

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WAV response with stream=false is not finalised: RIFF and data sizes stay 0xFFFFFFFF

2 participants