Repository navigation
Continue ZONOS2 long-form chunks from earlier audio codes for voice consistency - #1328
Merged
Merged
Conversation
Port ZONOS2's long-form generation (tts/longform.py): text is packed by words into chunks of 150 code points, and every chunk after the first is generated as a continuation of the first and the previous chunk's audio codes, in one code stream that is decoded once. Unreferenced multi-chunk requests no longer change voice between chunks. - prompt: build_zonos2_continuation_prompt and split_zonos2_long_form_text, checked against ZONOS2's own builders (make_longform_oracle.py). - backbone: prefill attention in blocks of 1024 query rows, so prompts of several thousand rows fit. - session: long_form_continuation request option (default on), text_chunk_size default 300 -> 150, fallbacks when a prompt does not fit or a chunk stops at max_tokens. Single-chunk requests and long_form_continuation=false are byte-identical to the previous build.
Owner
|
@Ryu1845 Thanks! I'll merge this PR first and test it later. I'm working on an MoE refactor that requires changes to the ZONOS2 implementation, so I'd like to include this PR now to avoid future conflicts. We still have time to fix any issues before the next release. |
Contributor
Author
|
Thank you. I'll be paying attention so just ping me if anything is needed |
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.
Follow-up to the note in #1282 that ZONOS2 may have the same voice-consistency issue as Zonos3. It does: without a voice reference every long-form chunk is an independent take, so each chunk can pick a different voice.
Port ZONOS2's own long-form generation (
tts/longform.py) instead of the Zonos3 approach, since ZONOS2 has no reference-codes prompt slot. Text is packed by words into chunks of 150 code points, and every chunk after the first is generated as a continuation: its prompt holds the text and the generated audio codes of the first chunk (pinned as the voice anchor) and of the previous chunk, and the model continues those codes into the new text. The chunks form one code stream that is decoded once, offline and streaming. Prefill attention now runs in blocks of 1,024 query rows so prompts of several thousand rows fit.long_form_continuation(defaulttrue) turns it off.text_chunk_sizenow defaults to 150 (was 300), as upstream. An explicittext_chunk_modekeeps the framework chunker. Unlike #1282, continuation also applies to requests with a voice reference, as upstream does; the numbers below show it gains nothing there, so say if you would rather limit it to unreferenced requests. All changes are model-local; no framework or GGML changes. The Web UI control is not included.Validation
Direct comparison: main
a6e32214versus this branch. RTX 4090, Threadripper PRO 5955WX, Release build, Q8_0 package, default sampling. Text A is 5 sentences (93 words, 515 characters); the long text is 11 sentences (241 words, 1,244 characters). Voice consistency is the lowest cosine between the ECAPA embeddings (the model's own speaker encoder) of any two 4-second windows of one take. WER is Qwen3-ASR-1.7B.RTF uses actual output duration. Takes with continuation are longer: 34.0 s against 32.4 s on text A, 30.4 s against 27.1 s cloned, 83.7 s against 73.6 s on the long text.
a5b2ee8) row for row:zonos2_prompt_test <oracle_dir>, with the oracle written bytests/community_models/zonos2/make_longform_oracle.py.long_form_continuation=false(CUDA, cloned on CUDA, CPU).max_tokens=4300the first chunk is left out of the prompts from the third chunk on and the long text is complete; withmax_tokens=5200no continuation prompt fits and every chunk is a new take; a chunk stopped bymax_tokens=300is followed by a new take.Known limitations
max_tokensand lost part of a sentence (10.75% WER, the one seed below 0.95). In a separate measurement this happened in 2 of 92 first chunks generated without thetrailing_silence_srow and 0 of 92 with it. That is too few to attribute it to the row, and ZONOS2 drops the row on continued chunks too, so the port keeps upstream's behaviour.prefix_cfg_scale,long_form_window_chunks,long_form_pin_anchorand the sentence split mode.