Skip to content

fix(tts): fail the request when a chunk fails instead of dropping it - #571

Merged
remsky merged 2 commits into
remsky:masterfrom
davidcoulson:fix/surface-synthesis-errors
Oct 28, 2026
Merged

remsky merged 2 commits into
remsky:masterfrom
davidcoulson:fix/surface-synthesis-errors

Conversation

@davidcoulson

Copy link
Copy Markdown
Contributor

Errors from model calls and audio encoding were logged and swallowed at
three levels of generate_audio_stream, so a sentence that failed was
left out of an HTTP 200 with nothing to show the text was incomplete.
Streams also kept going and finalized their download link file.

Let those errors propagate. Non-streaming requests get the existing
error response; a stream is cut off, which clients can detect, and
TempFileWriter removes its file when it exits with an error so the
download link never serves the truncated audio. Pause-chunk errors are
unchanged.

Testing

  • pytest: full suite passes.
  • test_failed_chunk_raises_instead_of_dropping_speech drives the real _process_chunk with a failing model call; on master the stream ends quietly with no audio.
  • test_failed_write_removes_partial_download checks the download file goes when the writer exits with an error.
  • Both fail on master and pass here.
  • Not reproduced on CUDA: I had no way to make a real chunk fail mid-request, so this is covered by the unit tests. Normal speech on an RTX 3070 (Unraid, nvidia runtime), image built from docker/gpu/Dockerfile.optimized with this and the sibling PRs merged is unchanged.

Follows #562-#568 from the same review. Based on master on its own; it overlaps those PRs in the CHANGELOG [Unreleased] section and in the imports of temp_manager.py (#563).

davidcoulson and others added 2 commits October 28, 2026 16:33
Errors from model calls and audio encoding were logged and swallowed at
three levels of generate_audio_stream, so a sentence that failed was
left out of an HTTP 200 with nothing to show the text was incomplete.
Streams also kept going and finalized their download link file.

Let those errors propagate. Non-streaming requests get the existing
error response; a stream is cut off, which clients can detect, and
TempFileWriter removes its file when it exits with an error so the
download link never serves the truncated audio. Pause-chunk errors are
unchanged.
@remsky
remsky merged commit b3f9965 into remsky:master Oct 28, 2026
3 checks passed
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.

2 participants