-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.xtts
More file actions
66 lines (55 loc) · 2.32 KB
/
Dockerfile.xtts
File metadata and controls
66 lines (55 loc) · 2.32 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
FROM python:3.11-slim
WORKDIR /app
ENV DEBIAN_FRONTEND=noninteractive
ENV COQUI_TOS_AGREED=1
ARG PRE_DOWNLOAD=true
# Install system dependencies (include ffmpeg for robust audio conversions)
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
-o Acquire::Retries=3 \
-o Acquire::http::Timeout=60 \
git \
wget \
ffmpeg \
espeak-ng \
espeak-ng-data \
libespeak-ng1 \
build-essential \
|| (apt-get -o Acquire::Retries=3 --fix-missing install -y --no-install-recommends \
git wget ffmpeg espeak-ng espeak-ng-data libespeak-ng1 build-essential) \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements and install Python dependencies
COPY requirements_xtts.txt .
# Install pip, then install PyTorch CPU wheels first and pin transformers/numpy
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
pip install --no-cache-dir "torch==2.2.2+cpu" "torchaudio==2.2.2" -f https://download.pytorch.org/whl/cpu/torch_stable.html && \
pip install --no-cache-dir "transformers==4.49.0" "numpy==1.26.4" && \
pip install --no-cache-dir -r requirements_xtts.txt
# Copy service files
COPY xtts_service_simple.py .
# Create models directory
RUN mkdir -p /app/models
# Optional model pre-download controlled by build arg (avoid making very large images by default)
# Write a small Python script and optionally run it to pre-download models
RUN cat > /tmp/predownload.py <<'PY'
import os
os.environ['COQUI_TOS_AGREED'] = '1'
try:
from TTS.api import TTS
print('Pre-downloading small models...')
TTS(model_name='tts_models/en/ljspeech/tacotron2-DDC', progress_bar=False, gpu=False)
TTS(model_name='vocoder_models/en/ljspeech/hifigan_v2', progress_bar=False, gpu=False)
try:
print('Attempting to pre-download xtts_v2 (this may be large)')
TTS(model_name='tts_models/multilingual/multi-dataset/xtts_v2', progress_bar=False, gpu=False)
print('xtts_v2 predownload complete')
except Exception as e:
print('xtts_v2 predownload skipped or failed:', e)
except Exception as e:
print('Model predownload step failed (continuing):', e)
PY
RUN if [ "$PRE_DOWNLOAD" = "true" ]; then python /tmp/predownload.py; fi
# Expose port
EXPOSE 5001
# Run the service
CMD ["python", "xtts_service_simple.py"]