# Sulkta build of Tortoise-TTS.
#
# Voice roster (built-in, no cloning needed): angie, daniel, deniro,
# emma, freeman, geralt, halle, jlaw, lj, mol, myself, pat, pat2,
# rainbow, snakes, tim_reynolds, tom, train_atkins, train_dotrice,
# train_dreams, train_grace, train_kennard, train_lescault,
# train_mouse, weaver, william. ~26 voices baked in.
#
# License: Apache 2.0 (code) + Apache 2.0 (model weights). Clean
# stack for share/publish.
#
# Speed: slow. Trade for quality. Standard preset is ~10x slower
# than Kokoro; high_quality is ~30x slower. Worth it for the
# audiobook-quality bar.

FROM pytorch/pytorch:2.6.0-cuda12.4-cudnn9-runtime

ENV DEBIAN_FRONTEND=noninteractive \
    PYTHONUNBUFFERED=1 \
    HF_HOME=/cache/hf \
    HF_HUB_DISABLE_TELEMETRY=1 \
    TORTOISE_MODELS_DIR=/cache/tortoise-models

RUN apt-get update && apt-get install -y --no-install-recommends \
        ffmpeg \
        git \
        ca-certificates \
        curl \
    && rm -rf /var/lib/apt/lists/*

RUN pip install --no-cache-dir \
        'tortoise-tts>=3.0.0' \
        'fastapi>=0.115.0' \
        'uvicorn>=0.32.0' \
        'soundfile>=0.13.0' \
        'numpy<2'

RUN mkdir -p /cache/hf /cache/tortoise-models /audio

COPY tortoise_server.py /app/tortoise_server.py
WORKDIR /app

EXPOSE 7860

CMD ["uvicorn", "tortoise_server:app", "--host", "0.0.0.0", "--port", "7860"]
