File size: 1,286 Bytes
9db256c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Base image with Python 3.12
FROM python:3.12-slim

# Set working directory
WORKDIR /app

# Install system dependencies
# Added ffmpeg for video processing
RUN apt-get update && apt-get install -y \
    portaudio19-dev \
    libsdl-pango-dev \
    libcairo2-dev \
    libpango1.0-dev \
    build-essential \
    texlive-full \
    wget \
    ffmpeg \
    && rm -rf /var/lib/apt/lists/*

# Copy Python files
COPY requirements.txt .
COPY main.py .
COPY src/ ./src/
COPY utils/ ./utils/
COPY prompts/ ./prompts/

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Download ONNX model if missing
RUN mkdir -p src/tts && \
    [ ! -f src/tts/kokoro-v1.0.onnx ] && \
    wget -O src/tts/kokoro-v1.0.onnx https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files-v1.0/kokoro-v1.0.onnx

# Setup for Hugging Face Spaces
# Create a user with UID 1000 (standard for HF Spaces)
RUN useradd -m -u 1000 user

# Create writable directories and set permissions
RUN mkdir -p output media .nicegui src/tts && \
    chown -R user:user /app

# Switch to non-root user
USER user

# Set Environment Variables
ENV PYTHONPATH=/app:$PYTHONPATH
ENV PORT=7860

# Expose the default HF Spaces port
EXPOSE 7860

# Start your Python script
CMD ["python", "main.py"]