Files
speech/Containerfile
du5t acdf098c41 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>
2026-06-18 18:46:45 +09:00

48 lines
1.4 KiB
Docker

FROM docker.io/pytorch/pytorch:2.7.0-cuda12.6-cudnn9-runtime
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
WHISPER_CACHE_DIR=/srv/asr/models-cache \
ASR_BASE_DIR=/srv/asr
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
libsndfile1 \
curl \
supervisor \
python3-venv \
&& rm -rf /var/lib/apt/lists/*
COPY envs/ /build/envs/
# gateway venv — 경량, GPU 불필요
RUN python -m venv /opt/venvs/gateway && \
/opt/venvs/gateway/bin/pip install --upgrade pip && \
/opt/venvs/gateway/bin/pip install -r /build/envs/gateway.txt
# faster-whisper venv — CTranslate2가 CUDA 직접 처리
RUN python -m venv /opt/venvs/faster_whisper && \
/opt/venvs/faster_whisper/bin/pip install --upgrade pip && \
/opt/venvs/faster_whisper/bin/pip install -r /build/envs/faster_whisper.txt
# qwen3 venv — base image의 torch/CUDA 상속
RUN python -m venv --system-site-packages /opt/venvs/qwen3 && \
/opt/venvs/qwen3/bin/pip install --upgrade pip && \
/opt/venvs/qwen3/bin/pip install -r /build/envs/qwen3.txt
# xtts venv — base image의 torch/CUDA 상속
RUN python -m venv --system-site-packages /opt/venvs/xtts && \
/opt/venvs/xtts/bin/pip install --upgrade pip && \
/opt/venvs/xtts/bin/pip install -r /build/envs/xtts.txt
COPY app/ /app/
RUN chmod +x /app/start.sh
EXPOSE 8000
CMD ["/app/start.sh"]