Spaces:
Runtime error
Runtime error
# Use Python 3.10 slim image | |
FROM python:3.10-slim | |
# Set environment variables | |
ENV PYTHONDONTWRITEBYTECODE=1 \ | |
PYTHONUNBUFFERED=1 \ | |
HF_HOME=/app/.cache \ | |
TRANSFORMERS_VERBOSITY=error | |
# Set working directory and create necessary folders | |
WORKDIR /app | |
RUN mkdir -p /app/.cache /app/models/suno-bark /app/models/sentiment && \ | |
chmod -R 777 /app/.cache /app/models | |
# Install OS dependencies | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
libsndfile1 ffmpeg ca-certificates && \ | |
rm -rf /var/lib/apt/lists/* | |
# Copy requirements and install Python dependencies | |
COPY requirements.txt . | |
RUN pip install --no-cache-dir --root-user-action=ignore -U pip && \ | |
pip install --no-cache-dir --root-user-action=ignore \ | |
"numpy<2" \ | |
"protobuf" && \ | |
pip install --no-cache-dir --root-user-action=ignore -r requirements.txt | |
# Install soundfile | |
RUN pip install soundfile | |
# Download Bark TTS model using snapshot_download | |
RUN python3 -c "\ | |
from huggingface_hub import snapshot_download; \ | |
snapshot_download(repo_id='suno/bark-small', local_dir='/app/models/suno-bark', local_dir_use_symlinks=False)" | |
# Download sentiment analysis model using snapshot_download | |
RUN python3 -c "\ | |
from huggingface_hub import snapshot_download; \ | |
snapshot_download(repo_id='cardiffnlp/twitter-xlm-roberta-base-sentiment', local_dir='/app/models/sentiment', local_dir_use_symlinks=False)" | |
# Copy application source code | |
COPY app.py . | |
# Expose port for the application | |
EXPOSE 7860 | |
# Launch app using Uvicorn | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |