Skip to content

Qwen3-TTS PR 3: sentence chunking and error status for /v1/audio/speech - #300

Open
merceod wants to merge 6 commits into
mainfrom
engine/speech-sentence-chunking
Open

merceod wants to merge 6 commits into
mainfrom
engine/speech-sentence-chunking

Conversation

@merceod

@merceod merceod commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Long inputs to /v1/audio/speech are synthesized as ordered sentence chunks.

speech_chunking.split_sentences groups sentences (Latin and CJK terminators, paragraph breaks, over-long sentences wrap at clauses and then spaces) into pieces of about speech_chunk_max_chars. serving_speech submits one engine request per piece, keeps speech_chunk_lookahead pieces in flight while the current one streams, and concatenates the PCM in order for both streaming and non-streaming responses. Each autoregressive request stays within the length its model was trained for, the engine batches the pieces like independent requests, and a client seed advances per piece.

Opt-in per adapter (speech_chunk_min_chars, off by default) and overridable per request with sentence_chunking: true|false. Adapters that keep the default behave as before. Qwen3-TTS turns it on for inputs of 600+ characters.

Also in here: a streaming request now looks at its first engine result before answering 200, so a rejected request (bad voice, dead worker) comes back with its error status instead of an empty WAV, and a mid-stream error closes the stream.

Six commits, one per file. Tests in test/modular/test_speech_chunking.py cover the splitter and the handler on the stubbed router (ordered ids and playback, per-chunk seeds, streaming concatenation, opt-out, forced chunking, error status). Full test/modular passes.

This branch has not been deployed

No deployments
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