File size: 1,483 Bytes
10a3914
 
 
9ea9ec8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10a3914
9ea9ec8
10a3914
 
9ea9ec8
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# ══════════════════════════════════════════════════════════════
# 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"]