stacks/index-tts: own FastAPI wrapper for IndexTTS-2 + deploy playbook
Adds a third TTS to the irv-ml1 fleet. IndexTTS-2 is Bilibili's
emotion-controllable zero-shot TTS (paper 2506.21619). Distinguishing
capability vs the existing two: timbre and emotion are disentangled —
clone a voice's timbre from one reference and the emotion from a
different reference, OR set emotion via 8-vector, OR derive it from a
text description. Neither CosyVoice 3 nor Qwen3-TTS-1.7B-Base does
this cleanly in English.
Wrapper is owned end-to-end (~150 lines in app.py) — the only existing
FastAPI fork (csllpr/index-tts-fastapi) targets v1 and is a dormant
single-commit repo. Upstream IndexTTS-2 ships only a Gradio webui.
Layout follows the qwen3-tts pattern:
stacks/index-tts/
Dockerfile — CUDA 12.8 base, IndexTTS pinned to a SHA
app.py — FastAPI: POST /v1/audio/speech + /v1/voices
entrypoint.sh — one-time HF snapshot_download of the weights
compose.yaml — env-driven, GPU pinning support, bind mounts
.env.example — port 8192, fp16, paths
README.md — API examples + comparison vs the other TTS
playbooks/deploy-index-tts.yaml — elway playbook for irv-ml1
Voice and emotion libraries are flat host dirs of WAVs, bind-mounted.
Drop a new <name>.wav and /v1/voices picks it up immediately.
License caveat: IndexTTS-2 weights ship under a custom Bilibili
license (free at our scale, not OSI-open). README documents it.
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
# Deploy IndexTTS-2 (https://github.com/index-tts/index-tts) to irv-ml1
|
||||
# behind our own FastAPI wrapper (stacks/index-tts/app.py).
|
||||
#
|
||||
# Builds the image locally from the Dockerfile in stacks/index-tts/
|
||||
# (which clones the upstream IndexTTS-2 repo at a pinned SHA inside
|
||||
# the build), stages app.py + entrypoint.sh + compose + .env under
|
||||
# /opt/docker/compose/index-tts/, brings it up, waits for /healthz,
|
||||
# and verifies the API surface.
|
||||
#
|
||||
# First run is slow: ~5-10 min for the docker build (CUDA torch + the
|
||||
# IndexTTS pinned-deps tail) plus ~5-7 GB model download from HF on
|
||||
# first container start (entrypoint.sh handles that). The healthz wait
|
||||
# below allows up to 15 min total.
|
||||
#
|
||||
# Usage:
|
||||
# scripts/elway irv-ml1 --playbook playbooks/deploy-index-tts.yaml
|
||||
#
|
||||
# Idempotent — every step is creates-/when-gated; rerun is safe.
|
||||
|
||||
vars:
|
||||
compose_dir: /opt/docker/compose/index-tts
|
||||
cache_dir: /worktank/index-tts/cache
|
||||
voices_dir: /worktank/index-tts/voices
|
||||
emotions_dir: /worktank/index-tts/emotions
|
||||
host_port: "8192"
|
||||
|
||||
steps:
|
||||
# ── host-side dirs ──────────────────────────────────────────────────
|
||||
|
||||
- name: Ensure /worktank/index-tts root exists (one-time, sudo)
|
||||
shell: mkdir -p /worktank/index-tts
|
||||
sudo: true
|
||||
creates: /worktank/index-tts
|
||||
|
||||
- name: Chown /worktank/index-tts to lkraven
|
||||
shell: chown lkraven:lkraven /worktank/index-tts
|
||||
sudo: true
|
||||
when: '[ "$(stat -c %U /worktank/index-tts)" != lkraven ]'
|
||||
|
||||
- name: Ensure cache dir exists
|
||||
shell: mkdir -p {{ cache_dir }}
|
||||
creates: "{{ cache_dir }}"
|
||||
|
||||
- name: Ensure voices dir exists
|
||||
shell: mkdir -p {{ voices_dir }}
|
||||
creates: "{{ voices_dir }}"
|
||||
|
||||
- name: Ensure emotions dir exists
|
||||
shell: mkdir -p {{ emotions_dir }}
|
||||
creates: "{{ emotions_dir }}"
|
||||
|
||||
- name: Ensure compose dir exists
|
||||
shell: mkdir -p {{ compose_dir }}
|
||||
creates: "{{ compose_dir }}"
|
||||
|
||||
# ── deploy build context (compose, env, dockerfile, app, entrypoint) ──
|
||||
|
||||
- name: Upload compose.yaml
|
||||
upload:
|
||||
src: stacks/index-tts/compose.yaml
|
||||
dest: "{{ compose_dir }}/compose.yaml"
|
||||
mode: "0644"
|
||||
|
||||
- name: Upload Dockerfile
|
||||
upload:
|
||||
src: stacks/index-tts/Dockerfile
|
||||
dest: "{{ compose_dir }}/Dockerfile"
|
||||
mode: "0644"
|
||||
|
||||
- name: Upload app.py
|
||||
upload:
|
||||
src: stacks/index-tts/app.py
|
||||
dest: "{{ compose_dir }}/app.py"
|
||||
mode: "0644"
|
||||
|
||||
- name: Upload entrypoint.sh
|
||||
upload:
|
||||
src: stacks/index-tts/entrypoint.sh
|
||||
dest: "{{ compose_dir }}/entrypoint.sh"
|
||||
mode: "0755"
|
||||
|
||||
- name: Seed .env from template (only if absent)
|
||||
upload:
|
||||
src: stacks/index-tts/.env.example
|
||||
dest: "{{ compose_dir }}/.env"
|
||||
mode: "0644"
|
||||
when: "[ ! -f {{ compose_dir }}/.env ]"
|
||||
|
||||
# ── build + bring up ────────────────────────────────────────────────
|
||||
|
||||
- name: docker compose build (~5-10 min first time; cached after)
|
||||
shell: cd {{ compose_dir }} && docker compose build
|
||||
|
||||
- name: docker compose up -d
|
||||
shell: cd {{ compose_dir }} && docker compose up -d
|
||||
|
||||
- name: Wait for /healthz to respond (allow ~15 min for model download)
|
||||
shell: |
|
||||
for i in $(seq 1 180); do
|
||||
curl -sf -o /dev/null --max-time 3 http://localhost:{{ host_port }}/healthz && exit 0
|
||||
sleep 5
|
||||
done
|
||||
exit 1
|
||||
changed_when: "false"
|
||||
|
||||
verify:
|
||||
- name: /healthz returns 200
|
||||
shell: curl -sf -o /dev/null http://localhost:{{ host_port }}/healthz
|
||||
changed_when: "false"
|
||||
|
||||
- name: /v1/voices returns a JSON object with 'voices' and 'emotions' keys
|
||||
shell: curl -sf http://localhost:{{ host_port }}/v1/voices | grep -q '"voices"'
|
||||
changed_when: "false"
|
||||
|
||||
- name: Container is running
|
||||
shell: docker inspect index-tts --format '{{.State.Status}}' | grep -q running
|
||||
changed_when: "false"
|
||||
Reference in New Issue
Block a user