audio-try / Dockerfile
Ajay
VoxSplit POC
e630855
Raw
History Blame Contribute Delete
1.03 kB
FROM python:3.11-slim
ENV PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
HF_HOME=/app/.cache/huggingface \
UPLOAD_DIR=/tmp/uploads \
PORT=7860
WORKDIR /app
# System libs needed by soundfile / librosa for audio decoding.
RUN apt-get update && apt-get install -y --no-install-recommends \
libsndfile1 ffmpeg \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY backend ./backend
COPY frontend ./frontend
# Pre-download the gender model so the first request isn't slow.
RUN python -c "from transformers import Wav2Vec2ForSequenceClassification, Wav2Vec2FeatureExtractor as F; M='prithivMLmods/Common-Voice-Gender-Detection'; Wav2Vec2ForSequenceClassification.from_pretrained(M); F.from_pretrained(M)"
# Make caches/uploads writable for non-root hosts (e.g. HF Spaces runs as uid 1000).
RUN mkdir -p /tmp/uploads "$HF_HOME" && chmod -R 777 /app/.cache /tmp/uploads
EXPOSE 7860
CMD ["sh", "-c", "uvicorn backend.main:app --host 0.0.0.0 --port ${PORT:-7860}"]