Samarth Naik commited on
Commit
9edbda4
·
1 Parent(s): 34bde63

fix: Optimize dependencies and Dockerfile for HF Spaces build

Browse files

- Simplify requirements.txt to avoid dependency conflicts
- Use staged Docker builds for better reliability
- Install PyTorch CPU version first, then TTS library
- Add git dependency for TTS model downloads
- Use Python 3.10 for better compatibility

Files changed (2) hide show
  1. Dockerfile +15 -9
  2. requirements.txt +7 -19
Dockerfile CHANGED
@@ -1,28 +1,34 @@
1
- FROM python:3.9-slim
2
 
3
  # Set working directory
4
  WORKDIR /app
5
 
6
- # Install system dependencies
7
  RUN apt-get update && apt-get install -y \
8
  build-essential \
9
- libsndfile1 \
10
  ffmpeg \
 
 
 
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
- # Copy requirements and install Python dependencies
 
 
 
14
  COPY requirements.txt .
 
 
 
 
15
  RUN pip install --no-cache-dir -r requirements.txt
16
 
17
  # Copy application code
18
  COPY . .
19
 
20
- # Expose port
21
  EXPOSE 7860
22
 
23
- # Set environment variables
24
- ENV GRADIO_SERVER_NAME="0.0.0.0"
25
- ENV GRADIO_SERVER_PORT="7860"
26
-
27
  # Run the application
28
  CMD ["python", "app.py"]
 
1
+ FROM python:3.10-slim
2
 
3
  # Set working directory
4
  WORKDIR /app
5
 
6
+ # Install system dependencies required for audio processing
7
  RUN apt-get update && apt-get install -y \
8
  build-essential \
9
+ libsndfile1-dev \
10
  ffmpeg \
11
+ git \
12
+ wget \
13
+ && apt-get clean \
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
+ # Upgrade pip and install wheel
17
+ RUN pip install --upgrade pip setuptools wheel
18
+
19
+ # Copy requirements first for better caching
20
  COPY requirements.txt .
21
+
22
+ # Install Python dependencies with more robust approach
23
+ RUN pip install --no-cache-dir torch torchaudio --index-url https://download.pytorch.org/whl/cpu
24
+ RUN pip install --no-cache-dir TTS==0.22.0
25
  RUN pip install --no-cache-dir -r requirements.txt
26
 
27
  # Copy application code
28
  COPY . .
29
 
30
+ # Expose port for Hugging Face Spaces
31
  EXPOSE 7860
32
 
 
 
 
 
33
  # Run the application
34
  CMD ["python", "app.py"]
requirements.txt CHANGED
@@ -2,26 +2,14 @@
2
  fastapi==0.104.1
3
  uvicorn[standard]==0.24.0
4
 
5
- # Text-to-Speech engine
6
- coqui-tts==0.21.1
7
-
8
  # File handling and HTTP
9
  python-multipart==0.0.6
10
- python-dateutil==2.8.2
11
-
12
- # Audio processing dependencies (required by Coqui TTS)
13
- numpy==1.24.3
14
- scipy==1.11.4
15
- librosa==0.10.1
16
- soundfile==0.12.1
17
-
18
- # Machine learning dependencies
19
- torch==2.0.1
20
- torchaudio==2.0.2
21
 
22
- # Hugging Face integration
23
- transformers==4.35.2
 
 
 
24
 
25
- # Utilities
26
- pydantic==2.5.0
27
- typing-extensions==4.8.0
 
2
  fastapi==0.104.1
3
  uvicorn[standard]==0.24.0
4
 
 
 
 
5
  # File handling and HTTP
6
  python-multipart==0.0.6
 
 
 
 
 
 
 
 
 
 
 
7
 
8
+ # Audio processing dependencies
9
+ numpy>=1.21.0
10
+ scipy>=1.7.0
11
+ librosa>=0.9.0
12
+ soundfile>=0.12.0
13
 
14
+ # Essential utilities
15
+ pydantic>=2.0.0