Add XTTS-v2 as first TTS backend, extensible for more

Mirrors the ASR backend pattern exactly: a BACKENDS dict in
tts/router.py maps a backend name to its worker URL, so adding the
next backend is just a new worker file + venv + supervisord entry +
one dict line. XTTS-v2 runs in its own venv (--system-site-packages,
inherits base image torch/CUDA) as a new supervisord program on
port 8005.

XTTS is zero-shot voice cloning, so a reference-voice library was
added (/tts/voices CRUD, stored under /srv/tts/voices) — synthesis
requires picking a previously uploaded voice. Results and model
cache live under /srv/tts/{results,models-cache}, new quadlet
volumes, owned by the same 983:983 user as the existing /srv/asr
dirs.

Fixed two environment issues uncovered while getting XTTS to
actually run inside the container (non-root user, root-built venvs):
- coqui-tts only pins transformers>=4.57 with no ceiling, so pip
  installed an incompatible 5.x; pinned to the last 4.x release.
- HOME defaults to /app (owned by root) for the container's runtime
  user, so numba/matplotlib/torch cache writes failed; HOME is now
  forced to /tmp in all three workers (faster_whisper, qwen3, xtts)
  before any of those libraries get imported.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
du5t
2026-06-18 18:46:45 +09:00
parent ac49bfc7f9
commit acdf098c41
13 changed files with 761 additions and 24 deletions

13
envs/xtts.txt Normal file
View File

@@ -0,0 +1,13 @@
# torch는 --system-site-packages로 base image에서 상속
fastapi==0.115.0
uvicorn[standard]==0.30.6
python-multipart==0.0.9
soundfile>=0.12.0
# coqui-tts: 원래 Coqui사의 TTS 패키지는 2024년 회사 해체로 unmaintained.
# 동일한 TTS.api import 경로를 유지하는 커뮤니티 후속 패키지를 사용한다.
coqui-tts
# coqui-tts는 transformers>=4.57만 선언해서 pip이 호환 안 되는 5.x를 깔아버린다
# (transformers 5.x에서 transformers.pytorch_utils.isin_mps_friendly가 제거되어
# ImportError 발생). 마지막 4.x로 고정.
transformers==4.57.6
huggingface_hub<1.0