Skip to content

Kokoro chinese voice - #9

Merged
efficiencyx merged 2 commits into
efficiencyx:mainfrom
runnevia-ryn:kokoro-chinese-voice
Nov 7, 2026
Merged

efficiencyx merged 2 commits into
efficiencyx:mainfrom
runnevia-ryn:kokoro-chinese-voice

Conversation

@runnevia-ryn

@runnevia-ryn runnevia-ryn commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #8 (multi-zip import), as agreed on Discord. Only the last commit is new here; once #8 is in, this shows just that one, and I'll rebase if it doesn't.

Summary

Kokoro can speak Mandarin Chinese, picked from a Language menu like Pocket-TTS's.

  • Sidecar: a KOKORO_LANGUAGES registry in tts/sidecar/config.py (English, Mandarin). A non-English language is only a G2P, built on first use around the model already loaded, so no second copy of the weights. /voices lists a language only when its G2P modules are installed (otherwise the row stays hidden, as before), and /warm builds the G2P and fetches the voice ahead of the first chunk. Requests reuse the existing lang field.
  • Settings: Kokoro gets the Language row, moved above Voice. The default is English, so nothing changes until someone picks something else. Mandarin lists its 4 female voices (zf_*), matching the female-only English list. Auto-detect routes each sentence by script (hanzi without kana is Mandarin) and uses the voice picked for that language, kept in a new tts.voices pref; under Auto the voice menu is greyed.
  • Chunker: cuts on 。!?~ and soft-splits on ,;:, so a Chinese reply starts playing after its first sentence instead of arriving as one chunk (and a long one no longer hits the 2000 byte cap in tts.php).
  • misaki[zh]==0.9.4 pinned, kokoro 0.9.4's own misaki version.
  • Adding a language later: an entry in KOKORO_LANGUAGES, its misaki extra, a rule in webapp/js/voice/kokoro-lang.js. Written up in docs/architecture.md.

Most of the 56 files are ?v= bumps cascading from tts.js, wire-tts.js, speech-card.js and prefs.js, each +1 over #8's numbers, so the wardrobe modules #8 bumped go to 33 and wardrobe.js to 41 with no clash.

Why

Kokoro was fixed to American English, so Chinese text came out as "Chinese letter". Agreed with effx on Discord: a language dropdown plus a voice dropdown, kept modular.

Validation

  • python -m py_compile tts/sidecar/*.py: ok (Python 3.10 on Linux, and the Windows TTS venv)

  • Sidecar routing test against a fake kokoro module (not in this PR): 27/27. Covers routing, voice and script fallbacks, /voices, /warm, unload, missing misaki[zh], and a G2P that fails to build or to synthesize falling back to English.

  • node --test .github/scripts/js/*.test.mjs: 17/17, including the new tts-text.test.mjs

  • node --check on all webapp JS, check-cache-busters.sh, check-refs.py, check-consistency.sh: ok (Linux), on top of Wardrobe: Load mod (.zip) can import several zips at once #8

  • Real model, Windows 10, CPU, kokoro 0.9.4 / misaki 0.9.4, standalone sidecar on a spare port: 8 sentences, /warm and 2 concurrent requests all returned audio, the Mandarin G2P was built once, a short Chinese sentence took about 0.6 to 1.1 s. Listened to all of them, and checked that sidecar's log: no errors or fallbacks.

  • Full Jun OS on Windows: Kokoro's Language and Voice menus (English default, Mandarin, Auto), the Play preview, chatting in Chinese under Auto, and the Pocket-TTS language menu unchanged.

  • Docker, Colab, Android: not run, no Docker setup here. Docker gets misaki[zh] from tts/requirements.txt.

  • ./sync-webapp.sh: not run, the Windows install serves webapp/ directly. Hard-refreshed instead.

  • I ran targeted syntax or automated checks for the files I changed.

  • I exercised the affected behavior directly where practical.

  • I checked the relevant service or browser logs.

Platforms affected

Windows (tested), Docker CPU/NVIDIA/AMD and Colab (same sidecar and webapp, not run). Android: its voice engine doesn't send Kokoro languages, so the client should keep the old path there (not run).

Checklist

  • The change is focused and preserves existing APIs and configuration unless documented otherwise.
  • I updated documentation and .env.example when behavior or configuration changed. (no new env knobs)
  • I did not include secrets, private chat data, model weights, or extracted/recovered game assets.
  • Frontend changes remain dependency-free ES modules and use consistent ?v= cache-busters.
  • For changes under webapp/, I ran ./sync-webapp.sh (-s only for static files) and hard-refreshed, or explained above why I could not.
  • Streaming changes handle markers split across arbitrary chunks and do not expose hidden action or bookkeeping tags. (n/a, the chunker only gained new break characters)
  • Prompt changes preserve prefix stability and keep dynamic context after the user's question, unless the PR explicitly explains why that invariant changes. (n/a)

Known limitations

  • English inside a Chinese sentence ("我是Jun") is read poorly: misaki's v1.0 Mandarin G2P passes latin letters through as they are. Kokoro-82M-v1.1-zh with en_callable may fix that, but it's a second model, so a separate PR if you want it.
  • ~ doesn't stretch the sound, it's just dropped.
  • Japanese is unchanged ("Chinese letter" / "Japanese letter"). Any kana keeps text off Mandarin so it isn't made worse.
  • I didn't touch NOTICE, since it doesn't list the TTS Python deps (kokoro, spacy...). The new ones are jieba, pypinyin and cn2an, all MIT. Happy to add them if you want.

The file input now accepts multiple files. They are imported one at a time, because importZip rewrites the shared mod list and state and re-applies the textures each time. A zip that fails is skipped and the rest still load; the message shows how many loaded and which files failed and why. With a single file the messages are the same as before.

Bumps ?v= to 32 for the wardrobe modules that import each other (mods/section.js, wardrobe/panel.js, tiles.js, looks.js, color-picker.js), and to 40 for wardrobe.js in wardrobe.html.
KOKORO_LANGUAGES in tts/sidecar/config.py registers English and
Mandarin. Mandarin is a misaki[zh] G2P around the model already
loaded, built on first use or on /warm, and listed in /voices only
when it's installed. Kokoro's settings get Language above Voice
(default English, so nothing changes until it's picked), one voice
per language, and per-sentence auto-detect by script. The chunker
also cuts on fullwidth 。!?~ so Chinese starts playing after its
first sentence instead of arriving as one chunk.
@efficiencyx
efficiencyx merged commit 7af66d2 into efficiencyx:main Nov 7, 2026
8 checks passed
mcchickengaming added a commit to mcchickengaming/JunOS that referenced this pull request Nov 15, 2026
- data/items.json: five currencies (Credits, Materials, Salvage Sigils,
  Whispers, Citizen Pass points), kinds, and an entry for every id the
  progression service can hand out (stand-ins marked sample), with tiers.
- The progression blob gets a wallet; drops and story grants of kind
  "currency"; a keepsake is one of each. Game saves carry the wallet and only
  ever keep whole counts above zero.
- lib/inventory.php + api/inventory.php + js/core/inventory.js: show, check
  and spend (all or nothing, says what's missing); keepsakes are never spent;
  a page can never give itself anything.
- Settings > The game > Everything you own (money chips, keepsakes, things by
  kind, a find box). How to play.
- Tests: inventory.test.php, inventory.test.mjs, api-checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HyRtqiEw7vAr4HoRVaqpqW
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