Repository navigation
omnivoice: size automatic long-form chunks in code points, not bytes - #1108
Merged
Merged
Conversation
The automatic chunk size divided target audio tokens by the UTF-8 byte length while chunk_text_punctuation counts code points, so CJK chunks came out about 3x the intended 15 s (e.g. a 222-character Chinese paragraph of ~35 s was never split). Long single passes produced mid-phrase pauses. Fixed in both offline and streaming paths.
linyqh
force-pushed
the
omnivoice-cjk-chunk-size
branch
from
October 27, 2026 03:46
9e8a5d6 to
622195f
Compare
Owner
|
@linyqh Thanks for the fix! PR merged. |
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.
Symptom
Chinese (and other CJK) text longer than
audio_chunk_threshold_sec(30 s) is split into chunks about three times larger thanaudio_chunk_duration_sec(15 s). A ~220-character Chinese paragraph (~35 s) is not split at all. The model then generates 35–45 s in one pass. The output has long pauses inside phrases, words split in the middle, and in the auto-voice case whole clauses dropped or garbled toward the end. This may be related to #842.Cause
The automatic path in
OmniVoiceSessioncomputesprompt.text.size()is the UTF-8 byte length.chunk_text_punctuationthen measurestext_chunk_sizein code points. For ASCII the two are equal. For CJK each character is 3 bytes, so the chunk budget comes out 3x too large. Upstream Python useslen(text), which counts characters.Fix
Use
engine::text::utf8_codepoint_countfor the per-character rate, in both the offline path (run) and the streaming path (plan_text_chunks). There is no other change. ASCII input is unaffected by construction, and text at or under the 30 s threshold never reaches this code.Validation
Apple M5, macOS 27.0.1, Metal.
omnivoice-f16.gguffromaudio-cpp/audio.cpp-gguf, seed 7, default 32 steps. "Before" is upstream main950b5db4and "after" is this branch; both builds are identical apart from this commit.Texts: a 309-character Chinese narration paragraph (281 Han characters), its first 80 characters (under the 30 s threshold), and a 633-character English paragraph (over the threshold). The chunk sizes come from the
omnivoice.text_chunk_size/omnivoice.text_chunk_counttrace keys. CER uses Qwen3-ASR-1.7B Q8 on Han characters only. "Mid-phrase pauses" are gaps of at least 150 ms between consecutive Qwen3-ForcedAligner words with no punctuation between them.b.wavIn the auto-voice "before" run, the second chunk drops about 60 of 281 characters and garbles the end (e.g.
教他怎样风向怎样,在浪头之间。). After the fix every character is read.The clone case uses the English reference speaker for Chinese text, so it is slow (about 3 characters per second) and still has some long pauses after the fix. The improvement there shows mainly in CER.
I also reproduced this on v0.9.2 (
0097d365) with a Chinese voice-clone reference and a 417-character paragraph. Chunks went from 227 to 96 characters. Mid-phrase pauses dropped from 17 (longest 1.92 s) to 5 (longest 320 ms). Paragraphs under the threshold were byte-identical.git diff --checkpasses. Not tested: CUDA, Vulkan, CPU. The change only touches host-side integer arithmetic before generation, with no backend code involved.