Skip to content

Fix truncated Opus tail in streaming writer#450

Closed
slime-turing wants to merge 1 commit intoremsky:masterfrom
slime-turing:fix/opus-tail-truncation
Closed

Fix truncated Opus tail in streaming writer#450
slime-turing wants to merge 1 commit intoremsky:masterfrom
slime-turing:fix/opus-tail-truncation

Conversation

@slime-turing
Copy link

Summary

  • fix truncated Opus tails in the in-memory streaming writer
  • keep Opus on a 48 kHz codec clock while resampling 24 kHz PCM input
  • document why the final Opus/Ogg bytes must be read only after muxer finalization

Root cause

The in-memory Opus path was reading the output buffer before the muxer finished flushing on container close. That left the final Ogg/Opus pages out of the last response chunk, which shortened clips and could clip the final word.

Testing

  • PYTHONPATH=$PWD .venv/bin/python -m pytest api/tests/test_audio_service.py -q
  • PYTHONPATH=$PWD .venv/bin/python -m pytest api/tests/test_openai_endpoints.py -q -k "speech_endpoint or speech_streaming or speech_pcm_streaming"
  • direct writer-level Opus encode/decode validation confirming ~2.089s output from ~2.09s input after the fix

@slime-turing
Copy link
Author

Closing this for now because it overlaps the same root-cause fix already proposed in #448. I’m keeping the local branch and extra regression/docs work on my side until upstream merges #448 or another equivalent fix, then I can re-check whether anything unique still needs to be proposed.

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.

1 participant