FROM python:3.11-slim WORKDIR /app # System deps: build-essential (pdf extraction), espeak-ng (Kokoro/misaki g2p # fallback for out-of-dictionary words), curl (TTS model download below) RUN apt-get update && apt-get install -y \ build-essential \ curl \ espeak-ng \ && rm -rf /var/lib/apt/lists/* COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Kokoro ONNX model files — the fp32 export (same weights as the torch release, # so audio quality is unchanged; do NOT swap in the int8/fp16 variants unless a # quality drop is acceptable). ~340MB total; skip with # --build-arg DOWNLOAD_TTS_MODELS=false (TTS then 503s and clients fall back). ARG DOWNLOAD_TTS_MODELS=true RUN if [ "$DOWNLOAD_TTS_MODELS" = "true" ]; then \ mkdir -p models && \ curl -fL -o models/kokoro-v1.0.onnx \ https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files-v1.0/kokoro-v1.0.onnx && \ curl -fL -o models/voices-v1.0.bin \ https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files-v1.0/voices-v1.0.bin ; \ fi COPY . . EXPOSE 7860 CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]