Spaces:
Running
Running
Fix HF Spaces deployment: use Docker SDK, pin huggingface_hub, pre-download models
Browse files- Changed sdk from streamlit to docker in README.md
- Pinned huggingface_hub<1.0.0 to fix use_auth_token compatibility with SpeechBrain
- Removed streamlit-webrtc (not supported in HF Spaces)
- Updated Dockerfile: pre-download SpeechBrain models, non-root user, headless mode
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Dockerfile +21 -4
- README.md +1 -4
- requirements.txt +4 -2
Dockerfile
CHANGED
|
@@ -15,18 +15,35 @@ COPY requirements.txt .
|
|
| 15 |
# Install Python dependencies
|
| 16 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 17 |
|
| 18 |
-
# Copy application code
|
| 19 |
COPY . .
|
| 20 |
|
| 21 |
-
# Create necessary directories
|
| 22 |
RUN mkdir -p data/db data/clips pretrained_models
|
| 23 |
|
| 24 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
EXPOSE 7860
|
| 26 |
|
| 27 |
# Set environment variables
|
| 28 |
ENV STREAMLIT_SERVER_PORT=7860
|
| 29 |
ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
|
|
|
|
| 30 |
|
| 31 |
# Run Streamlit
|
| 32 |
-
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|
|
|
|
| 15 |
# Install Python dependencies
|
| 16 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 17 |
|
| 18 |
+
# Copy application code
|
| 19 |
COPY . .
|
| 20 |
|
| 21 |
+
# Create necessary directories with proper permissions
|
| 22 |
RUN mkdir -p data/db data/clips pretrained_models
|
| 23 |
|
| 24 |
+
# Pre-download SpeechBrain models during build
|
| 25 |
+
RUN python -c "\
|
| 26 |
+
from speechbrain.inference.VAD import VAD; \
|
| 27 |
+
VAD.from_hparams(source='speechbrain/vad-crdnn-libriparty', savedir='pretrained_models/vad'); \
|
| 28 |
+
print('VAD model downloaded')"
|
| 29 |
+
|
| 30 |
+
RUN python -c "\
|
| 31 |
+
from speechbrain.inference.speaker import SpeakerRecognition; \
|
| 32 |
+
SpeakerRecognition.from_hparams(source='speechbrain/spkrec-ecapa-voxceleb', savedir='pretrained_models/spkrec'); \
|
| 33 |
+
print('Speaker Recognition model downloaded')"
|
| 34 |
+
|
| 35 |
+
# HF Spaces runs as user 1000 - set permissions
|
| 36 |
+
RUN useradd -m -u 1000 user
|
| 37 |
+
RUN chown -R user:user /app
|
| 38 |
+
USER user
|
| 39 |
+
|
| 40 |
+
# Expose port (HF Spaces uses 7860)
|
| 41 |
EXPOSE 7860
|
| 42 |
|
| 43 |
# Set environment variables
|
| 44 |
ENV STREAMLIT_SERVER_PORT=7860
|
| 45 |
ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
|
| 46 |
+
ENV HOME=/home/user
|
| 47 |
|
| 48 |
# Run Streamlit
|
| 49 |
+
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0", "--server.headless=true"]
|
README.md
CHANGED
|
@@ -3,10 +3,7 @@ title: SOP Audio Analyzer
|
|
| 3 |
emoji: 🎙️
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: red
|
| 6 |
-
sdk:
|
| 7 |
-
sdk_version: 1.29.0
|
| 8 |
-
python_version: "3.11"
|
| 9 |
-
app_file: app.py
|
| 10 |
pinned: false
|
| 11 |
---
|
| 12 |
|
|
|
|
| 3 |
emoji: 🎙️
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: red
|
| 6 |
+
sdk: docker
|
|
|
|
|
|
|
|
|
|
| 7 |
pinned: false
|
| 8 |
---
|
| 9 |
|
requirements.txt
CHANGED
|
@@ -1,8 +1,11 @@
|
|
| 1 |
-
# Core ML - compatible with Python 3.11
|
| 2 |
torch==2.5.1
|
| 3 |
torchaudio==2.5.1
|
| 4 |
speechbrain>=1.0.0
|
| 5 |
|
|
|
|
|
|
|
|
|
|
| 6 |
# Audio processing
|
| 7 |
librosa>=0.10.0
|
| 8 |
soundfile>=0.12.1
|
|
@@ -21,7 +24,6 @@ sqlalchemy>=2.0.0
|
|
| 21 |
|
| 22 |
# UI
|
| 23 |
streamlit>=1.29.0
|
| 24 |
-
streamlit-webrtc>=0.47.0
|
| 25 |
plotly>=5.18.0
|
| 26 |
|
| 27 |
# Utilities
|
|
|
|
| 1 |
+
# Core ML - compatible with Python 3.11
|
| 2 |
torch==2.5.1
|
| 3 |
torchaudio==2.5.1
|
| 4 |
speechbrain>=1.0.0
|
| 5 |
|
| 6 |
+
# HuggingFace - pinned for SpeechBrain compatibility
|
| 7 |
+
huggingface_hub<1.0.0
|
| 8 |
+
|
| 9 |
# Audio processing
|
| 10 |
librosa>=0.10.0
|
| 11 |
soundfile>=0.12.1
|
|
|
|
| 24 |
|
| 25 |
# UI
|
| 26 |
streamlit>=1.29.0
|
|
|
|
| 27 |
plotly>=5.18.0
|
| 28 |
|
| 29 |
# Utilities
|