Download Dockerfile from grimshaw/cpu-tts: direct link, hf CLI and curl.
- Browser
- Download file 2.3 kB
-
https://huggingface.co/spaces/grimshaw/cpu-tts/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/grimshaw/cpu-tts/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/grimshaw/cpu-tts/resolve/main/Dockerfile
2.3 kB
| FROM python:3.10-slim | |
| ENV PYTHONDONTWRITEBYTECODE=1 \ | |
| PYTHONUNBUFFERED=1 \ | |
| PIP_NO_CACHE_DIR=1 \ | |
| HOST=0.0.0.0 \ | |
| PORT=7860 \ | |
| MODEL_DIR=/app/models/supertonic-2 \ | |
| SUPERTONIC_CACHE_DIR=/app/models/supertonic-2 \ | |
| KITTEN_MODEL_NAME=KittenML/kitten-tts-micro-0.8 \ | |
| KITTEN_CACHE_DIR=/app/models/hf-cache \ | |
| KOKORO_MODEL_DIR=/app/models/kokoro \ | |
| HF_HOME=/app/models/hf-cache \ | |
| HUGGINGFACE_HUB_CACHE=/app/models/hf-cache \ | |
| WORKSPACE_DIR=/tmp/tts-server \ | |
| JOB_DB_PATH=/tmp/tts-server/jobs.db \ | |
| PERSISTENT_OUTPUT_DIR=/store \ | |
| ENABLE_MELO_TTS=true \ | |
| REQUIRE_AUTH=false | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| ca-certificates \ | |
| curl \ | |
| ffmpeg \ | |
| git \ | |
| libsndfile1 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| RUN useradd -m -u 1000 user | |
| WORKDIR /app | |
| COPY --chown=user:user requirements.txt requirements-melo.txt ./ | |
| RUN pip install -r requirements.txt | |
| RUN git clone https://github.com/myshell-ai/MeloTTS.git /tmp/MeloTTS && \ | |
| pip install -e /tmp/MeloTTS | |
| COPY --chown=user:user . /app | |
| RUN mkdir -p /app/models/supertonic-2 /app/models/kokoro /app/models/hf-cache /tmp/tts-server /store && \ | |
| chown -R user:user /tmp/tts-server /store && \ | |
| python -c "from supertonic import TTS; tts = TTS(model_dir='/app/models/supertonic-2', auto_download=True); print(f'Preloaded model at {tts.model_dir}')" | |
| RUN python - <<'PY' | |
| from huggingface_hub import snapshot_download | |
| snapshot_download( | |
| repo_id='onnx-community/Kokoro-82M-v1.0-ONNX', | |
| local_dir='/app/models/kokoro', | |
| allow_patterns=['config.json', 'tokenizer.json', 'tokenizer_config.json', 'onnx/model_q8f16.onnx', 'voices/*.bin'], | |
| ) | |
| print('Preloaded Kokoro assets into /app/models/kokoro') | |
| PY | |
| RUN python - <<'PY' | |
| from kittentts import KittenTTS | |
| KittenTTS(model_name='KittenML/kitten-tts-micro-0.8', cache_dir='/app/models/hf-cache') | |
| print('Preloaded Kitten TTS assets into /app/models/hf-cache') | |
| PY | |
| RUN python -m unidic download | |
| RUN python /tmp/MeloTTS/melo/init_downloads.py | |
| RUN python - <<'PY' | |
| from melo.api import TTS | |
| TTS(language='EN', device='cpu', use_hf=True) | |
| print('Verified MeloTTS dependency in the image') | |
| PY | |
| USER user | |
| EXPOSE 7860 | |
| CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"] | |