Files
esh-pfi-infrastructure/stacks/kokoro
vh e0d1c44137 chore(fleet): repoint stale irv-ml1 refs (10.100.79.3 -> irv-ml1.nh3.internal)
The 2026-09-06 headscale cutover retired irv-ml1's wg0 tunnel IP 10.100.79.3
(now 10.6.110.50). Repointed all LIVE canonical refs to the DNS NAME so the next
move can't re-break them: homepage.href/siteMonitor labels across 25 stack
composes, load-bearing env defaults (asset-engine INFERENCE_HOST, open-webui
AUDIO_TTS_OPENAI_API_BASE_URL, skaldsong SKALDSONG_TTS_BASE_URL, zonos-gateway
ZONOS_URL, dia), homepage services.yaml manual cards (Voice Design Studio,
IRV-ML1), and servers/irv-ml1/ssh-target. Updated the stale 'WG tunnel' comment
to the mesh reality.

Left as-is: README curl-examples and .env.example comments (docs), and historical
mentions in CLAUDE.md/persistent-memory. NOTE: applying the label repoints to the
RUNNING irv-ml1 containers needs a recreate per service (labels read at creation);
deployed .env values are separate from these canonical defaults.
2026-09-07 15:08:56 -07:00
..

Kokoro

hexgrad/Kokoro-82M served via remsky/Kokoro-FastAPI.

Why this stack exists

Lowest-latency English TTS in the fleet by a wide margin — ~300 ms time-to-first-audio on GPU, 35-100x realtime, ~1 GB VRAM at fp16. Native streaming (Kokoro's KPipeline.__call__ is a per-phrase generator) and the wrapper exposes it via OpenAI-compat stream=true over chunked HTTP — drop-in for any OpenAI SDK client.

Complementary to the rest of the TTS slate:

use case
Kokoro low-latency English, fixed voice library
Chatterbox Turbo low-latency English w/ voice cloning + paralinguistic tags
IndexTTS-2 English voice cloning + emotion vector / text control
Qwen3-TTS-1.7B-Base high-quality English voice cloning
CosyVoice 3 multilingual (Chinese-leaning)
VibeVoice 1.5B long-form podcast / multi-speaker dialogue

API

OpenAI-compat at http://10.100.79.3:8193:

# List built-in voices (~60 of them, named like af_bella, am_adam, jf_*, zf_*).
curl http://10.100.79.3:8193/v1/audio/voices

# Single-shot synthesis.
curl -fsS -X POST http://10.100.79.3:8193/v1/audio/speech \
  -H 'Content-Type: application/json' \
  -d '{"model":"kokoro","input":"Hello there.","voice":"af_bella","response_format":"wav"}' \
  > out.wav

# Streaming — pipe straight into a player.
curl -fsS -X POST http://10.100.79.3:8193/v1/audio/speech \
  -H 'Content-Type: application/json' \
  -d '{"model":"kokoro","input":"long passage here…","voice":"af_bella","stream":true}' \
  | mpv --no-cache -

# Voice mixing — sum voicepacks with weights.
curl -fsS -X POST http://10.100.79.3:8193/v1/audio/speech \
  -H 'Content-Type: application/json' \
  -d '{"model":"kokoro","input":"hello","voice":"af_bella(2)+af_heart(1)","response_format":"wav"}' \
  > mix.wav

Web UI at /web (browse voices + try in-place); OpenAPI at /docs.

Supported response_format: mp3 | wav | opus | flac | pcm.

Voices

  • Built-in: 60+ in 8 languages (en-US, en-GB, ja, zh, es, fr, hi, it). Discoverable via GET /v1/audio/voices — naming convention is <lang_code><gender_letter>_<name> (e.g. af_bella, am_adam, jf_alpha, zf_xiaobei).

  • Custom blends: weighted-average existing voicepacks into a new named voice using playbooks/blend-kokoro-voice.yaml (script: scripts/blend_kokoro_voice.py). Mirrors the wrapper's request-time voice="a(w)+b(w)" math but persists the result so it shows up in /v1/audio/voices. Example shipped: athena = af_bella(2)+af_aoede(1) normalized.

    scripts/elway irv-ml1 --playbook playbooks/blend-kokoro-voice.yaml \
      --var 'recipe=af_bella(1)+am_adam(1)' --var out_name=androgyne
    # add --var force=1 to overwrite an existing voice
    

    Persistence design: the wrapper enumerates exactly one directory (VOICES_DIR, default in-image /app/api/src/voices/v1_0). compose.yaml overrides VOICES_DIR=/app/user_voices (host bind mount /worktank/kokoro/user_voices) and adds a command: shim that cp -r's the in-image built-ins into that dir on every container start. Result:

    • built-in voicepacks re-seed on each start, so image upgrades that add/change built-ins propagate automatically
    • custom blends written by the script live on the host bind mount — survive docker restart, up --force-recreate, image upgrade, and host reboot
    • one-time prereq: the host dir must be chowned to 1001:1001 (uid of appuser inside the container) so the shim's cp can write — handled by playbooks/deploy-kokoro.yaml
  • Cloned voices: training a Kokoro voice from samples is non- trivial — consult the hexgrad community for how-to. For voice cloning use Chatterbox Turbo or IndexTTS-2 instead.

Deploy

scripts/elway irv-ml1 --playbook playbooks/deploy-kokoro.yaml

First deploy: ~6.5 GB image pull from GHCR (~2-5 min on a fast link). No model download on first run — Kokoro-82M weights are baked in. Subsequent starts: a few seconds.

License

Apache-2.0 for both the wrapper code (remsky/Kokoro-FastAPI) and the Kokoro-82M weights (hexgrad).