didodev commited on
Commit
9c5218d
·
1 Parent(s): 4ca6263

Fix HF build deps + Linux null sink

Browse files
Files changed (2) hide show
  1. Dockerfile +11 -6
  2. app.py +2 -1
Dockerfile CHANGED
@@ -1,21 +1,26 @@
1
  FROM python:3.11-slim
2
 
3
- # System deps (ffmpeg for audio conversion + git for some pip installs if needed)
 
 
 
 
4
  RUN apt-get update && apt-get install -y --no-install-recommends \
5
  ffmpeg \
6
  git \
 
 
 
7
  && rm -rf /var/lib/apt/lists/*
8
 
9
  WORKDIR /app
10
 
11
- # Install Python deps
12
  COPY requirements.txt /app/requirements.txt
13
- RUN pip install --no-cache-dir -r requirements.txt
 
14
 
15
- # Copy the application code
16
  COPY . /app
17
 
18
- # Hugging Face Spaces expects port 7860
19
  EXPOSE 7860
20
-
21
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
  FROM python:3.11-slim
2
 
3
+ # System deps:
4
+ # - ffmpeg: audio conversion
5
+ # - libsndfile1: required by soundfile/librosa
6
+ # - build-essential/pkg-config: needed for some wheels/extensions (e.g., webrtcvad if it compiles)
7
+ # - git: in case any pip install pulls from git
8
  RUN apt-get update && apt-get install -y --no-install-recommends \
9
  ffmpeg \
10
  git \
11
+ libsndfile1 \
12
+ build-essential \
13
+ pkg-config \
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
  WORKDIR /app
17
 
18
+ # Faster / more reliable installs
19
  COPY requirements.txt /app/requirements.txt
20
+ RUN pip install --no-cache-dir --upgrade pip setuptools wheel \
21
+ && pip install --no-cache-dir -r requirements.txt
22
 
 
23
  COPY . /app
24
 
 
25
  EXPOSE 7860
 
26
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
app.py CHANGED
@@ -2,6 +2,7 @@ import os
2
  import re
3
  import shutil
4
  import subprocess
 
5
  from fastapi import FastAPI, UploadFile, File
6
  from fastapi.responses import JSONResponse
7
 
@@ -28,7 +29,7 @@ def detect_trim_times(wav_path: str):
28
  """
29
  # Run silencedetect and capture output
30
  p = subprocess.run(
31
- ["ffmpeg", "-i", wav_path, "-af", "silencedetect=noise=-35dB:d=0.35", "-f", "null", "NUL"],
32
  cwd=WORKDIR,
33
  stdout=subprocess.PIPE,
34
  stderr=subprocess.STDOUT,
 
2
  import re
3
  import shutil
4
  import subprocess
5
+ NULL_SINK = "NUL" if os.name == "nt" else "/dev/null"
6
  from fastapi import FastAPI, UploadFile, File
7
  from fastapi.responses import JSONResponse
8
 
 
29
  """
30
  # Run silencedetect and capture output
31
  p = subprocess.run(
32
+ ["ffmpeg", "-i", wav_path, "-af", "silencedetect=noise=-35dB:d=0.35", "-f", "null", NULL_SINK],
33
  cwd=WORKDIR,
34
  stdout=subprocess.PIPE,
35
  stderr=subprocess.STDOUT,