Repository navigation
Emit whole 16-bit samples from DeepgramHttpTTSService - #5989
Merged
markbackman merged 2 commits intoOct 1, 2026
Merged
Conversation
HTTP chunk boundaries can fall mid-sample. Stream the response through _stream_audio_frames_from_iterator so every TTSAudioRawFrame holds whole samples; a frame ending mid-sample made the TTFA scan raise and stopped the service's audio for the rest of the session.
markbackman
approved these changes
Oct 1, 2026
markbackman
left a comment
Contributor
There was a problem hiding this comment.
LGTM. Thanks! I'll look into a centralized fix for this problem, but this is safe, so approving.
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 5 files with indirect coverage changes 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DeepgramHttpTTSServiceturned each chunk read from the HTTP response straight into aTTSAudioRawFrame, but chunk boundaries don't have to fall between 16-bit samples, so a frame can end mid-sample (#3109 reported this:buffer size must be a multiple of element size). With metrics enabled, the TTFA scan reads the buffered audio as int16 and raises on the odd length inside_audio_context_task_handler. The task dies and the service produces no audio for that utterance or any later one.Same issue as #5090 (xAI HTTP) and #4952 (Rime WebSocket).
Fix
Stream the response through
TTSService._stream_audio_frames_from_iterator, asXAIHttpTTSService,RimeHttpTTSServiceand Piper already do. It holds back a dangling byte, so every emitted frame contains whole samples.Testing
tests/test_deepgram_tts.py: a local server splits the PCM mid-sample. With metrics enabled, the test asserts that the frames are even-length and reassemble into the original PCM. Onmainit gets no audio frames at all.main, neither utterance produces audio and the handler logsbuffer size must be a multiple of element size. With this change, both arrive intact and TTFA is reported.