Skip to content

Kokoro: chunk Chinese and Japanese text at 100 codepoints by default - #1022

Merged
0xShug0 merged 1 commit into
0xShug0:mainfrom
hiroki-abe-58:kokoro-cjk-chunk-size
Oct 21, 2026
Merged

0xShug0 merged 1 commit into
0xShug0:mainfrom
hiroki-abe-58:kokoro-cjk-chunk-size

Conversation

@hiroki-abe-58

@hiroki-abe-58 hiroki-abe-58 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Long Chinese or Japanese text fails with Kokoro's default text_chunk_size of 240 codepoints:

audiocpp_cli failed: Kokoro phoneme string exceeds 510 symbols; segmenting is not implemented in the framework path yet

These languages phonemize to several symbols per character. A Chinese chunk exceeds the 510-symbol input limit from about 150 characters, so a 240-character chunk fails, as does any paragraph long enough to fill one.

This PR makes the default 100 codepoints for Chinese and Japanese voices (language codes z and j, resolved as the frontend already does). Other languages keep 240, and an explicit text_chunk_size still takes precedence. The spec no longer declares a fixed default; its description states the rule. The docs are updated to match.

Validation

  • Windows 11, RTX 5090, CUDA build of this branch: .\scripts\build_windows.ps1 -Preset windows-cuda-release -Target audiocpp_cli -CudaArchitectures 120a-real.
  • Models from audio-cpp/audio.cpp-gguf@44e93ef:
    • Kokoro-82M-GGUF/kokoro-82m-q8_0.gguf for Chinese;
    • kokoro-82m-multilingual-q8_0.gguf for Japanese, with MeCab from the mecab-python3 1.0.12 wheel via AUDIOCPP_MECAB_LIBRARY.
  • Run: audiocpp_cli --family kokoro_tts --task tts --backend cuda --model <gguf> --text <text> --voice-id <zf_xiaobei|jf_alpha> --language <zh|ja> --seed 1 --out <wav> --log.
  • CER: Whisper large-v3-turbo with sequential long-form decoding, measured against the input text.
text main (240) this PR (default)
Chinese, 219 chars, zf_xiaobei fails (510 symbols) 3 chunks, 48.0 s, CER 0.005
Japanese, 404 chars, jf_alpha fails (510 symbols) 5 chunks, 70.2 s, CER 0.034
Japanese, 141 chars, jf_alpha 1 chunk, 25.1 s, CER 0.023 2 chunks, 25.8 s, CER 0.038
  • With this branch's defaults, the Chinese and Japanese outputs are byte-identical to main run with --text-chunk-size 100.
  • On main, the 219-character Chinese paragraph passes with --text-chunk-size 80, 100, 120 and 140, and fails from 160 on.
  • Languages other than Chinese and Japanese keep the 240 default unchanged. They weren't run here because this machine has no eSpeak-ng library.

Phoneme-level segmentation, splitting a chunk by its 510-symbol budget, would remove the limit entirely. This PR only keeps the default from hitting it.

🤖 Generated with Claude Code

A 240-codepoint chunk of Chinese or Japanese phonemizes to more than 510 symbols, so long text in those languages failed with 'Kokoro phoneme string exceeds 510 symbols'. Default to 100 codepoints for Chinese and Japanese voices; other languages keep 240 and an explicit text_chunk_size still applies.
@0xShug0
0xShug0 merged commit 4babdde into 0xShug0:main Oct 21, 2026
7 checks passed
@0xShug0

0xShug0 commented Oct 21, 2026

Copy link
Copy Markdown
Owner

@hiroki-abe-58 Thanks for improving CJK chunking and fixing language handling! All three PRs merged.

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