Sign inSign up

maximfilms/pyannote_fastapi

By maximfilms

Updated 10 days ago

FastAPI service for pyannote speaker diarization, with SSE streaming and a queued worker pool.

Image
Machine learning & AI
Web servers
0

2.3K

maximfilms/pyannote_fastapi repository overview

pyannote speaker diarization — FastAPI service

A minimal FastAPI HTTP wrapper around pyannote/speaker-diarization-community-1. Upload an audio file and stream the diarization result back over Server-Sent Events, with periodic heartbeats so long jobs don't time out behind proxies.

Application code only — model weights are not bundled. The upstream pipeline is gated on Hugging Face under CC-BY-4.0; you must supply your own HF_TOKEN (after accepting the model card terms) or mount an offline checkout via MODEL_PATH.

Tags

  • latest, <version> — CUDA build, base pytorch/pytorch:*-cuda*-cudnn9-runtime (auto-selected at build time)
  • latest-cpu, <version>-cpu — CPU-only build on python:3.11-slim
  • sha-<short> — immutable commit builds from main

Run

docker run --rm -it --gpus all \
  -e API_KEYS="replace-me" \
  -e HF_TOKEN="replace-me" \
  -v pyannote_hf_cache:/opt/huggingface \
  -p 8000:8000 \
  maximsachs/pyannote_fastapi:latest

CPU-only host: drop --gpus all and use the :latest-cpu tag.

Call it

curl -N -fsS \
  -H "Authorization: Bearer replace-me" \
  -H "Accept: text/event-stream" \
  -F "file=@/path/to/audio.wav" \
  http://127.0.0.1:8000/diarize

You'll receive a text/event-stream of status and heartbeat events, ending in a result event with the speaker segments.

Endpoints

MethodPathDescription
GET/liveLiveness probe.
GET/healthReadiness probe (200 once the model is loaded).
GET/metricsPrometheus exposition.
POST/diarizeBearer-authenticated SSE diarization endpoint.

Key environment variables

NameRequiredDefaultPurpose
API_KEYSyesComma-separated bearer tokens accepted on /diarize.
HF_TOKEN / HUGGING_FACE_HUB_TOKENyes**Unless MODEL_PATH points at an offline checkout.
MODEL_PATHnoAbsolute path to a local pyannote pipeline directory.
HF_HOMEno/opt/huggingfaceHugging Face cache root — mount a volume here to persist downloads.
DIARIZE_WORKERSno1Concurrent diarization workers (keep at 1 for single-GPU).
MAX_QUEUE_DEPTHno64Queue cap; further requests get 503 queue_full + Retry-After: 5.
SSE_HEARTBEAT_SECONDSno5Interval between SSE heartbeat frames.

Source and full docs

github.com/maximsachs/pyannote_fastapi — full API reference, every error code, SSE event schema, and tuning guide in docs/API.md. Wrapper code is MIT; the model itself remains CC-BY-4.0 and gated.

Tag summary

Content type

Image

Digest

sha256:f8abf734c

Size

4.3 GB

Last updated

10 days ago

docker pull maximfilms/pyannote_fastapi