File size: 2,041 Bytes
22c7ca5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.10-slim

ENV DEBIAN_FRONTEND=noninteractive \
    PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    PIP_NO_CACHE_DIR=1 \
    TOKENIZERS_PARALLELISM=false

WORKDIR /code

RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    git \
    curl \
    wget \
    libsndfile1 \
    libportaudio2 \
    libopenblas-dev \
    libomp-dev \
    ffmpeg \
    libavcodec-extra \
    && rm -rf /var/lib/apt/lists/*

COPY requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt

RUN pip install --no-cache-dir huggingface-hub accelerate

ARG HF_TOKEN=
ENV HUGGINGFACE_HUB_TOKEN=${HF_TOKEN}
ENV HF_TOKEN=${HF_TOKEN}

RUN pip install --no-cache-dir outetts uroman gdown

ENV HF_HOME=/tmp/huggingface
ENV TRANSFORMERS_CACHE=/tmp/huggingface
ENV HUGGINGFACE_HUB_CACHE=/tmp/huggingface
ENV HF_HUB_CACHE=/tmp/huggingface

ENV HOME=/tmp

RUN mkdir -p /tmp/huggingface && chmod -R 777 /tmp/huggingface && \
    mkdir -p /code/models && \
    chmod -R 777 /code && \
    chmod -R 777 /code/models

RUN if [ -n "$HF_TOKEN" ]; then \
      python -c "from huggingface_hub import login; import os; t=os.environ.get('HF_TOKEN');\nprint('Token present' if t else 'No token');\nlogin(token=t, add_to_git_credential=True)" && \
      echo '✅ Hugging Face login complete'; \
    else \
      echo '⚠️ Hugging Face login skipped'; \
    fi



RUN mkdir -p /code/models && \
    wget -q -O /code/models/wavtokenizer_mediumdata_frame75_3s_nq1_code4096_dim512_kmeans200_attn.yaml \
    https://huggingface.co/novateur/WavTokenizer-medium-speech-75token/resolve/main/wavtokenizer_mediumdata_frame75_3s_nq1_code4096_dim512_kmeans200_attn.yaml || true

COPY . .
RUN if [ -d "/code/yarngpt" ] && [ -f "/code/yarngpt/audiotokenizer.py" ]; then \
      echo "Using vendored yarngpt from project"; \
    else \
      pip install --no-cache-dir git+https://github.com/saheedniyi02/yarngpt.git; \
    fi

EXPOSE 7860

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--lifespan", "off"]