File size: 2,937 Bytes
3f792e8 3e27995 3f792e8 3e27995 3f792e8 3e27995 5de798e 3f792e8 3e27995 3f792e8 5de798e 3e27995 3f792e8 46827e9 3e27995 3f792e8 3e27995 938d58f 321254f 938d58f 321254f cb974bb 3e27995 cb974bb b899c60 3e27995 321254f 5de798e 785835e fdcc0cf 65f46e8 b899c60 3e27995 3f792e8 3e27995 5de798e 3f792e8 3e27995 3b1fac6 |
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
FROM python:3.9-slim
# Set working directory
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
ffmpeg \
git \
wget \
curl \
build-essential \
libsndfile1 \
libasound2-dev \
portaudio19-dev \
libportaudio2 \
libportaudiocpp0 \
libsndfile1-dev \
libflac-dev \
libvorbis-dev \
libogg-dev \
libmp3lame-dev \
libmad0-dev \
libtwolame-dev \
libavcodec-dev \
libavformat-dev \
libavutil-dev \
libswresample-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first for better caching
COPY requirements.txt .
# Install Python dependencies with proper error handling
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
pip install --no-cache-dir -r requirements.txt
# Test critical imports to catch issues early
RUN python -c "import librosa; print('β librosa OK')" && \
python -c "import resampy; print('β resampy OK')" && \
python -c "import transformers; print('β transformers OK')" && \
python -c "import torch; print('β torch OK')" && \
python -c "import pyannote; print('β pyannote OK')" && \
python -c "import whisper; print('β whisper OK')" && \
python -c "import fastapi; print('β fastapi OK')" && \
echo "All critical imports successful!"
# Copy application code
COPY . .
# Create necessary directories with proper permissions
RUN mkdir -p templates static uploads outputs model_cache temp_files demo_results demo_audio results \
/tmp/matplotlib /tmp/fontconfig \
&& chmod -R 777 templates static \
&& chmod -R 777 uploads outputs model_cache temp_files demo_results demo_audio results \
&& chmod -R 777 /tmp/matplotlib /tmp/fontconfig
# Set environment variables for Hugging Face Spaces
ENV PYTHONPATH=/app \
GRADIO_ANALYTICS_ENABLED=False \
HF_MODELS_CACHE=/app/model_cache \
OUTPUT_DIR=./outputs \
TEMP_DIR=./temp_files \
WHISPER_MODEL_SIZE=small \
TARGET_LANGUAGE=en \
MAX_WORKERS=1 \
USE_GPU=false \
HF_HOME=/app/model_cache \
TRANSFORMERS_CACHE=/app/model_cache \
TORCH_HOME=/app/model_cache \
XDG_CACHE_HOME=/app/model_cache \
PYANNOTE_CACHE=/app/model_cache \
MPLCONFIGDIR=/tmp/matplotlib \
HUGGINGFACE_HUB_CACHE=/app/model_cache \
HF_HUB_CACHE=/app/model_cache \
FONTCONFIG_PATH=/tmp/fontconfig \
CTRANSLATE2_FORCE_CPU_ISA=generic \
TF_CPP_MIN_LOG_LEVEL=2 \
TOKENIZERS_PARALLELISM=false \
OMP_NUM_THREADS=1 \
MKL_NUM_THREADS=1 \
NUMBA_NUM_THREADS=1 \
TF_ENABLE_ONEDNN_OPTS=0 \
MALLOC_ARENA_MAX=2 \
PYTHONUNBUFFERED=1
# Expose port for Hugging Face Spaces
EXPOSE 7860
# Health check for Hugging Face Spaces
HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
# Preload models and start the application
CMD ["python", "startup.py"] |