Spaces:
Sleeping
Sleeping
| # ββ 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"] | |