Skip to content

Continue ZONOS2 long-form chunks from earlier audio codes for voice consistency - #1328

Merged
0xShug0 merged 1 commit into
0xShug0:mainfrom
Ryu1845:feature/zonos2-long-form
Nov 18, 2026
Merged

0xShug0 merged 1 commit into
0xShug0:mainfrom
Ryu1845:feature/zonos2-long-form

Conversation

@Ryu1845

@Ryu1845 Ryu1845 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

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 (default true) turns it off. text_chunk_size now defaults to 150 (was 300), as upstream. An explicit text_chunk_mode keeps 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 a6e32214 versus 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.

Text A, CUDA Continuation off Continuation on
Unreferenced, lowest window cosine (median of 12 seeds) 0.906 0.981
Unreferenced, seeds below 0.95 12 of 12 1 of 12
Unreferenced, WER (mean of 12 seeds) 0.54% 1.26%
Unreferenced, takes with every sentence 12 of 12 11 of 12
Cloned, lowest window cosine (median of 6 seeds) 0.982 0.978
Cloned, cosine to the reference clip (mean of 6 seeds) 0.975 0.965
Cloned, WER (6 seeds) 0.00% 0.00%
Lowest window cosine, off -> on Seeds Result
Long text, CUDA 3 0.903 -> 0.978, 0.861 -> 0.982, 0.907 -> 0.967
Text A, Vulkan 4 0.907 -> 0.975, 0.924 -> 0.978, 0.880 -> 0.983, 0.888 -> 0.980
Text A, CPU 2 0.896 -> 0.985, 0.899 -> 0.973
Backend Text Off: RTF On: RTF Off: peak VRAM On: peak VRAM
CUDA A, 12 seeds 0.306 0.322 9,699 MiB 10,345 MiB
CUDA A cloned, 6 seeds 0.317 0.330 9,701 MiB 10,219 MiB
CUDA Long, 3 seeds 0.304 0.326 9,703 MiB 10,303 MiB
Vulkan A, 4 seeds 0.338 0.353 - -
CPU, 16 threads A, 2 seeds 2.67 3.21 - -

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.

  • Continuation prompts and word-packed chunks equal the output of ZONOS2's own builders (a5b2ee8) row for row: zonos2_prompt_test <oracle_dir>, with the oracle written by tests/community_models/zonos2/make_longform_oracle.py.
  • Unchanged paths are byte-identical to main: a single chunk with a fade (CUDA), and multi-chunk requests with long_form_continuation=false (CUDA, cloned on CUDA, CPU).
  • Long text: one take with continuation off dropped a sentence (9.54% WER); all three takes with continuation on were complete (0.83-1.66%).
  • Streaming and offline output with continuation have the same length and differ by at most 8 LSB on CUDA and Vulkan, 12 LSB cloned with a fade, and 1 LSB in 11 samples on the CPU. Main differs by 9 LSB on CUDA.
  • In one session, the first of three requests equals a fresh process and the third equals the first. The expert cache equals resident experts on the CPU.
  • Fallbacks: with max_tokens=4300 the first chunk is left out of the prompts from the third chunk on and the long text is complete; with max_tokens=5200 no continuation prompt fits and every chunk is a new take; a chunk stopped by max_tokens=300 is followed by a new take.

Known limitations

  • One unreferenced take of 12 (seed 11) is worse with continuation: its first chunk ran on in silence to max_tokens and 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 the trailing_silence_s row 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.
  • A chunk that follows a finished sentence can open with a pause of several seconds (4.4 s in 1 of 3 long-text takes). Word packing makes this rare; with the framework's sentence chunks it happened in 2 of 12 takes, which is why word packing is the default.
  • One Vulkan take of 4 with continuation inserted four words (4.30% WER).
  • With a voice reference, chunks were already consistent; continuation lowers the similarity to the reference slightly and lengthens pauses.
  • Not ported: prefix_cfg_scale, long_form_window_chunks, long_form_pin_anchor and the sentence split mode.

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.
@0xShug0

0xShug0 commented Nov 18, 2026

Copy link
Copy Markdown
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.

@0xShug0
0xShug0 merged commit b47cea0 into 0xShug0:main Nov 18, 2026
7 checks passed
@Ryu1845

Ryu1845 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Thank you. I'll be paying attention so just ping me if anything is needed

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