Spaces:
Sleeping
Sleeping
File size: 2,302 Bytes
b9cacf3 | 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 | # ββ Base image ββββββββββββββββββββββββββββββββββββββββββββββββ
FROM python:3.11-slim
# ββ System dependencies ββββββββββββββββββββββββββββββββββββββββ
# libgomp1 is required by ONNX Runtime (used internally by piper-tts)
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*
# ββ Non-root user required by HuggingFace Spaces ββββββββββββββ
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# ββ Working directory ββββββββββββββββββββββββββββββββββββββββββ
WORKDIR $HOME/app
# ββ Install Python dependencies ββββββββββββββββββββββββββββββββ
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt
# ββ Download Piper voice model (en_US-lessac-medium) ββββββββββ
# Model and its JSON config are fetched from the official Piper voices repo
RUN mkdir -p $HOME/app/models \
&& curl -L -o $HOME/app/models/en_US-lessac-medium.onnx \
"https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/en/en_US/lessac/medium/en_US-lessac-medium.onnx" \
&& curl -L -o $HOME/app/models/en_US-lessac-medium.onnx.json \
"https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/en/en_US/lessac/medium/en_US-lessac-medium.onnx.json"
# ββ Copy application code ββββββββββββββββββββββββββββββββββββββ
COPY --chown=user app.py .
# ββ Expose the port HuggingFace Spaces expects βββββββββββββββββ
EXPOSE 7860
# ββ Start the server βββββββββββββββββββββββββββββββββββββββββββ
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
|