/ services / diarization / Dockerfile
Dockerfile
 1  FROM python:3.11-slim
 2  
 3  WORKDIR /app
 4  
 5  RUN apt-get update && apt-get install -y --no-install-recommends \
 6      libsndfile1 \
 7      libportaudio2 \
 8      git \
 9      build-essential \
10      && rm -rf /var/lib/apt/lists/*
11  
12  # Install PyTorch + torchaudio (latest cu121)
13  RUN pip install --no-cache-dir \
14      torch torchaudio --index-url https://download.pytorch.org/whl/cu121
15  
16  # Install pyannote.audio + diart with compatible deps
17  RUN pip install --no-cache-dir \
18      pyannote.audio \
19      websockets
20  
21  # diart with relaxed deps
22  RUN pip install --no-cache-dir --no-deps diart && \
23      pip install --no-cache-dir rx optuna sounddevice websocket-server
24  
25  # CAM++ via modelscope
26  RUN pip install --no-cache-dir modelscope
27  
28  # 3D-Speaker source
29  RUN git clone --depth 1 https://github.com/modelscope/3D-Speaker.git /opt/3d-speaker
30  ENV PYTHONPATH="/opt/3d-speaker"
31  
32  # Patch diart for compatibility with newer torchaudio
33  RUN python3 -c "\
34  import pathlib; \
35  p = pathlib.Path('/usr/local/lib/python3.11/site-packages/diart/audio.py'); \
36  p.write_text(p.read_text().replace('torchaudio.set_audio_backend(\"soundfile\")', 'pass')); \
37  p2 = pathlib.Path('/usr/local/lib/python3.11/site-packages/diart/sources.py'); \
38  src = p2.read_text(); \
39  src = src.replace('from torchaudio.io import StreamReader', 'try:\\n    from torchaudio.io import StreamReader\\nexcept ImportError:\\n    StreamReader = None'); \
40  p2.write_text(src); \
41  print('Patched diart for torchaudio compat')"
42  
43  COPY service.py ./
44  
45  EXPOSE 7007
46  
47  CMD ["python", "service.py"]