# ══════════════════════════════════════════════════════════════ # Chatterbox Turbo TTS — CPU-Optimised Docker Image # ══════════════════════════════════════════════════════════════ FROM python:3.11-slim # Audio codec libraries for soundfile/librosa RUN apt-get update && \ apt-get install -y --no-install-recommends libsndfile1 ffmpeg && \ rm -rf /var/lib/apt/lists/* WORKDIR /app # Install PyTorch CPU first (from dedicated index for smaller size) RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu # Install remaining dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy application code + local built-in voice samples from repo root COPY config.py text_processor.py chatterbox_wrapper.py app.py ./ COPY *.wav ./ # Pre-download ONNX models + tokenizer at build time RUN python -c "\ from chatterbox_wrapper import ChatterboxWrapper; \ ChatterboxWrapper(download_only=True); \ print('Models pre-downloaded successfully')" # Prevent thread oversubscription in production ENV OMP_NUM_THREADS=1 ENV MKL_NUM_THREADS=1 ENV OPENBLAS_NUM_THREADS=1 EXPOSE 7860 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]