kokoro: persist custom voices across container recreate
Wrapper only enumerates one voice directory (settings.voices_dir, default /app/api/src/voices/v1_0 — inside the container's writable layer, not bind-mounted). Override via VOICES_DIR=/app/user_voices (host bind mount) and add a command shim that cp -r's built-ins from the in-image v1_0 into user_voices on every start. Built-ins re-seed fresh from the image (so upgrades that add voices propagate); custom .pt files in user_voices are preserved (cp -r is additive). Also adds scripts/blend_kokoro_voice.py + a playbook around it that mirrors the wrapper's request-time voice="a(w)+b(w)" math but writes the result as a named .pt to user_voices, making it discoverable via GET /v1/audio/voices and persistent across recreate. Defaults to athena = af_bella(2)+af_aoede(1) normalized.
This commit is contained in:
@@ -27,18 +27,30 @@ services:
|
||||
# that env var harmlessly; the gpu variant honors it.
|
||||
ports:
|
||||
- "${KOKORO_BIND:-0.0.0.0}:${KOKORO_PORT}:8880"
|
||||
# Persistent custom voices: the wrapper only enumerates one voice
|
||||
# directory (controlled by VOICES_DIR; default in-image is
|
||||
# /app/api/src/voices/v1_0 which is NOT bind-mounted). We point it
|
||||
# at /app/user_voices (which IS host-bind-mounted) and seed the
|
||||
# built-ins into it on every container start. Custom voices written
|
||||
# by scripts/blend_kokoro_voice.py land directly on the host bind
|
||||
# mount and survive `up --force-recreate` and image upgrade.
|
||||
# `cp -r` (no `-n`): always refresh built-ins from the image so
|
||||
# upgrades that add/change built-in voicepacks propagate.
|
||||
# Custom-named .pt files in user_voices that don't exist in v1_0
|
||||
# are NOT touched (cp -r only copies entries from src).
|
||||
command: ["/bin/bash", "-c", "cp -r /app/api/src/voices/v1_0/. /app/user_voices/ && exec ./entrypoint.sh"]
|
||||
environment:
|
||||
- NVIDIA_VISIBLE_DEVICES=${KOKORO_GPU_DEVICES:-}
|
||||
- USE_GPU=${KOKORO_USE_GPU:-false}
|
||||
- API_LOG_LEVEL=${KOKORO_LOG_LEVEL:-INFO}
|
||||
- VOICES_DIR=/app/user_voices
|
||||
volumes:
|
||||
# Optional voice-overlay mount — drop a custom <name>.pt into the
|
||||
# host dir to make it available alongside the 60+ built-ins. The
|
||||
# image already ships voicepacks at this path, so the bind mount
|
||||
# SHADOWS them — only do this if you actually want to manage the
|
||||
# full voice library yourself. For most deploys, leave the mount
|
||||
# commented out and use the in-image voices.
|
||||
# - ${KOKORO_VOICES_DIR}:/app/api/src/voices/v1_0
|
||||
# Host-bind-mounted voice directory. Hosts both the image's
|
||||
# built-ins (re-seeded on each container start by the command
|
||||
# shim above) and any custom voices created via the blend
|
||||
# script. Must be chowned to uid 1001 (appuser inside the
|
||||
# container) on the host so the shim's cp can write — handled
|
||||
# by playbooks/deploy-kokoro.yaml.
|
||||
- ${KOKORO_USER_VOICES_DIR}:/app/user_voices
|
||||
healthcheck:
|
||||
# The image is python-based with curl available. /v1/audio/voices
|
||||
|
||||
Reference in New Issue
Block a user