FastAPI service for pyannote speaker diarization, with SSE streaming and a queued worker pool.
2.3K
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.
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-slimsha-<short> — immutable commit builds from maindocker 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.
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.
| Method | Path | Description |
|---|---|---|
GET | /live | Liveness probe. |
GET | /health | Readiness probe (200 once the model is loaded). |
GET | /metrics | Prometheus exposition. |
POST | /diarize | Bearer-authenticated SSE diarization endpoint. |
| Name | Required | Default | Purpose |
|---|---|---|---|
API_KEYS | yes | — | Comma-separated bearer tokens accepted on /diarize. |
HF_TOKEN / HUGGING_FACE_HUB_TOKEN | yes* | — | *Unless MODEL_PATH points at an offline checkout. |
MODEL_PATH | no | — | Absolute path to a local pyannote pipeline directory. |
HF_HOME | no | /opt/huggingface | Hugging Face cache root — mount a volume here to persist downloads. |
DIARIZE_WORKERS | no | 1 | Concurrent diarization workers (keep at 1 for single-GPU). |
MAX_QUEUE_DEPTH | no | 64 | Queue cap; further requests get 503 queue_full + Retry-After: 5. |
SSE_HEARTBEAT_SECONDS | no | 5 | Interval between SSE heartbeat frames. |
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.
Content type
Image
Digest
sha256:f8abf734c…
Size
4.3 GB
Last updated
10 days ago
docker pull maximfilms/pyannote_fastapi