# Kokoro-82M TTS. Apache 2.0 code AND weights — clean stack vs
# F5-TTS's CC-BY-NC asterisk.
#
# Kokoro runs fine on CPU but we use the cuda base to stay
# consistent with f5-tts and pick up the GPU when free.
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

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

# kokoro pulls phonemizer + soundfile + espeakng transitively.
RUN pip install --no-cache-dir 'kokoro>=0.9.0' 'fastapi>=0.115.0' 'uvicorn>=0.32.0' 'soundfile>=0.13.0'

RUN mkdir -p /cache/hf /audio

COPY server.py /app/server.py
WORKDIR /app

EXPOSE 7860

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