Kokoro-82M adapter (q8/WASM first, WebGPU experimental) #16

Closed
opened 2026-10-25 14:58:41 +00:00 by dsh · 3 comments
Owner

Goal

The quality tier: Kokoro-82M in the same worker/queue architecture, without the 325 MB WebGPU trap.

Scope

  • Engine module for kokoro-js@1.2.1 (Apache-2.0), pinned exactly (it pins transformers ^3.5.1; do not float). Model onnx-community/Kokoro-82M-v1.0-ONNX, dtype: 'q8', device: 'wasm' only.
  • Asset manager: q8 model 92.4 MB + one 510 KB voice; Cache API storage with progress and purge; explicit download only.
  • Voice list from list_voices() (55 voices); show language + grade where available; default af_heart.
  • Run in the shared Worker (#9); PCM 24 kHz out; stream() optional behind a flag.
  • Feature-gate WebGPU: hidden behind an experimental toggle requiring navigator.gpu, and never auto-download fp32 (325.5 MB). Document hexgrad/kokoro#275 as the reason.
  • Spike gate: 20 sequential syntheses with no monotonic heap growth; record performance.memory/DevTools numbers on a 2 GB-class client.

Acceptance

  • q8/WASM works in Chrome and Safari desktop, and the model is cached across reloads.
  • Heap is stable over 20 calls; no WebGPU path is reachable by default.
  • Voice switch reuses the cached model.

Notes

  • Depends on #8, #9, #12. Part of M3. Sizes and bugs: docs/research/tts-engines.md §4.
## Goal The quality tier: Kokoro-82M in the same worker/queue architecture, without the 325 MB WebGPU trap. ## Scope - [ ] Engine module for `kokoro-js@1.2.1` (Apache-2.0), pinned exactly (it pins `transformers ^3.5.1`; do not float). Model `onnx-community/Kokoro-82M-v1.0-ONNX`, `dtype: 'q8'`, `device: 'wasm'` only. - [ ] Asset manager: q8 model 92.4 MB + one 510 KB voice; Cache API storage with progress and purge; explicit download only. - [ ] Voice list from `list_voices()` (55 voices); show language + grade where available; default `af_heart`. - [ ] Run in the shared Worker (#9); PCM 24 kHz out; `stream()` optional behind a flag. - [ ] Feature-gate WebGPU: hidden behind an experimental toggle requiring `navigator.gpu`, and **never** auto-download fp32 (325.5 MB). Document `hexgrad/kokoro#275` as the reason. - [ ] Spike gate: 20 sequential syntheses with no monotonic heap growth; record `performance.memory`/DevTools numbers on a 2 GB-class client. ## Acceptance - q8/WASM works in Chrome and Safari desktop, and the model is cached across reloads. - Heap is stable over 20 calls; no WebGPU path is reachable by default. - Voice switch reuses the cached model. ## Notes - Depends on #8, #9, #12. Part of M3. Sizes and bugs: `docs/research/tts-engines.md` §4.
Author
Owner

Implemented in a47bc6f — awaiting browser proof.

  • Dedicated Kokoro worker (src/worker/kokoro-entry.js) bundling kokoro-js 1.2.1 (transformers.js + ORT), isolated from Piper's ORT; numThreads = 1 so no COOP/COEP is needed.
  • Adapter src/engines/kokoro.js: eight curated voices (af_heart default, af_bella, af_nicole, am_michael, am_fenrir, bf_emma, bm_george, bm_fable), q8 model (~92.4 MB) + per-voice style (~0.5 MB), download only through explicit prepare().
  • Settings: engine picker (Piper / Kokoro), voice list follows the engine, one remembered voice per engine; the First-run copy shows the 92 MB Kokoro budget. setEngine tears down the old worker/queue/context.
  • Build embeds both worker sources (bundle 2.9 MB; host still 0 MB inference).
  • 148 tests; new coverage for the Kokoro adapter and per-engine voice switching.

Manual test needed: Settings → Kokoro → Enable audio & preview (one 92 MB download), then auto-read/read-aloud. Report first-utterance latency and any worker/CORS error.

**Implemented** in `a47bc6f` — awaiting browser proof. - Dedicated Kokoro worker (`src/worker/kokoro-entry.js`) bundling `kokoro-js` 1.2.1 (transformers.js + ORT), isolated from Piper's ORT; `numThreads = 1` so no COOP/COEP is needed. - Adapter `src/engines/kokoro.js`: eight curated voices (`af_heart` default, `af_bella`, `af_nicole`, `am_michael`, `am_fenrir`, `bf_emma`, `bm_george`, `bm_fable`), q8 model (~92.4 MB) + per-voice style (~0.5 MB), download only through explicit `prepare()`. - Settings: engine picker (Piper / Kokoro), voice list follows the engine, one remembered voice per engine; the First-run copy shows the 92 MB Kokoro budget. `setEngine` tears down the old worker/queue/context. - Build embeds both worker sources (bundle 2.9 MB; host still 0 MB inference). - 148 tests; new coverage for the Kokoro adapter and per-engine voice switching. **Manual test needed:** Settings → Kokoro → *Enable audio & preview* (one 92 MB download), then auto-read/read-aloud. Report first-utterance latency and any worker/CORS error.
Author
Owner

Kokoro load failure fixed in 32304d7. Root cause: scripts/build-client.mjs marked fs/path as external for both workers (Piper needs the shim for its Node branches). The Kokoro worker then kept require("path") from kokoro-js and our banner shim threw node builtin path is unavailable in the browser worker before any model download.

  • Piper worker keeps external: ['fs','path'] + shim.
  • Kokoro worker now bundles its browser build with no externals (verified: zero require(...) in the emitted kokoro worker).
  • Rebuilt bundle 2.89 MB; 148 tests green.

Also moved the mascot 1 px closer (4 px overlap) per the operator's last visual pass.

**Kokoro load failure fixed in `32304d7`.** Root cause: `scripts/build-client.mjs` marked `fs`/`path` as *external* for **both** workers (Piper needs the shim for its Node branches). The Kokoro worker then kept `require("path")` from kokoro-js and our banner shim threw `node builtin path is unavailable in the browser worker` before any model download. - Piper worker keeps `external: ['fs','path']` + shim. - Kokoro worker now bundles its browser build with no externals (verified: zero `require(...)` in the emitted kokoro worker). - Rebuilt bundle 2.89 MB; 148 tests green. Also moved the mascot 1 px closer (4 px overlap) per the operator's last visual pass.
Author
Owner

Dropped: Kokoro was removed on 2026-11-04 in favour of LibriTTS (904 voices) and Phonon; adapter, worker, dependency and tests deleted.

Dropped: Kokoro was removed on 2026-11-04 in favour of LibriTTS (904 voices) and Phonon; adapter, worker, dependency and tests deleted.
dsh closed this issue 2026-11-06 04:36:05 +00:00
Sign in to join this conversation.
No description provided.