File size: 2,624 Bytes
5b5e7fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Use an official Python runtime as a parent image
FROM python:3.9-slim-buster

# Set the working directory in the container
WORKDIR /app

# Install build tools and other dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    cmake \
    pkg-config \
    libblis-dev \
    python3-venv \
    python3-dev \
    wget \
    libopenblas-dev

# Create a virtual environment
RUN python3 -m venv venv

# Activate the virtual environment
RUN . /app/venv/bin/activate

# Copy the locally cloned Coqui TTS repository (excluding large files)
COPY TTS /app/TTS

# Set the working directory to the TTS directory
WORKDIR /app/TTS

# Set a generic architecture flag
ENV BLIS_ARCH="generic"

# Try to agree to the Coqui TTS license via environment variable
ENV COQUI_TTS_AGREED=1

# Install Coqui TTS requirements
RUN . /app/venv/bin/activate && pip install -r requirements.txt --timeout=300

# Explicitly install the TTS package itself in editable mode
RUN . /app/venv/bin/activate && pip install -e . --timeout=300

# Change working directory back to /app
WORKDIR /app

# Create the model directory
RUN mkdir -p /app/models/xtts_v2

# Download XTTS v2 model files
RUN wget -O /app/models/xtts_v2/config.json https://huggingface.co/coqui/XTTS-v2/resolve/main/config.json?download=true
RUN wget -O /app/models/xtts_v2/model.pth https://huggingface.co/coqui/XTTS-v2/resolve/main/model.pth?download=true
RUN wget -O /app/models/xtts_v2/vocab.json https://huggingface.co/coqui/XTTS-v2/resolve/main/vocab.json?download=true
RUN wget -O /app/models/xtts_v2/dvae.pth https://huggingface.co/coqui/XTTS-v2/resolve/main/dvae.pth?download=true
RUN wget -O /app/models/xtts_v2/speakers_xtts.pth https://huggingface.co/coqui/XTTS-v2/resolve/main/speakers_xtts.pth?download=true

# Create the audio directory if it doesn't exist
RUN mkdir -p /app/audio

# Copy the speaker_reference.wav file if it exists at the root
COPY speaker_reference.wav /app/audio/speaker_reference.wav

# Copy the web page files
COPY web /app/web

# Copy the application code
COPY local_server_new.py /app/

# Install your other dependencies (fastapi, uvicorn, bangla, etc.)
COPY requirements.txt /app/
RUN . /app/venv/bin/activate && pip install -r /app/requirements.txt --no-cache-dir --timeout=300

# Create start.sh script
RUN echo "#!/bin/bash" > start.sh && \
    echo "source /app/venv/bin/activate" >> start.sh && \
    echo "/app/venv/bin/python -m uvicorn local_server_new:app --host 0.0.0.0 --port 80" >> start.sh && \
    chmod +x start.sh

# Expose port
EXPOSE 80

# Run the app using the script
CMD ["./start.sh"]