File size: 1,915 Bytes
c3c0d65
 
 
267160d
 
 
c3c0d65
 
267160d
 
c3c0d65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93f7bf7
c3c0d65
 
93f7bf7
 
 
4799475
c3c0d65
93f7bf7
 
 
 
c162be1
3b4c0b9
c3c0d65
 
 
 
 
93f7bf7
 
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
# Base Image
FROM python:3.10-slim

# Build argument for Hugging Face token
ARG HF_TOKEN

ENV DEBIAN_FRONTEND=noninteractive \
    PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    HF_TOKEN=${HF_TOKEN}

WORKDIR /code

# System Dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    git \
    curl \
    libopenblas-dev \
    libomp-dev \
    ffmpeg \
    && rm -rf /var/lib/apt/lists/*

# Copy requirements and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Hugging Face + model tools
RUN pip install --no-cache-dir huggingface-hub sentencepiece accelerate fasttext

# Hugging Face cache environment
ENV HF_HOME=/models/huggingface \
    TRANSFORMERS_CACHE=/models/huggingface \
    HUGGINGFACE_HUB_CACHE=/models/huggingface \
    HF_HUB_CACHE=/models/huggingface

# Created cache dir and set permissions
RUN mkdir -p /models/huggingface && chmod -R 777 /models/huggingface

RUN python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='facebook/mms-tts-hau')" \
 && python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='facebook/mms-tts-eng')" \
 && python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='facebook/mms-tts-yor')" \
 && find /models/huggingface -name '*.lock' -delete

RUN python -c "from transformers import pipeline; pipeline('text-to-speech', model='facebook/mms-tts-hau')" \
 && python -c "from transformers import pipeline; pipeline('text-to-speech', model='facebook/mms-tts-eng')" \
 && python -c "from transformers import pipeline; pipeline('text-to-speech', model='facebook/mms-tts-yor')"

# Models will be downloaded at runtime when HF_TOKEN is available

# Copy project files
COPY . .

EXPOSE 7860

CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]