Skip to main content

Command Palette

Search for a command to run...

The Nightmare of Local Speaker Diarization (And How We Dockerized It)

How we combined Faster-Whisper, VAD, and Speaker Diarization into a single zero-dependency Docker container for air-gapped enterprise environments.

Updated
3 min readView as Markdown
The Nightmare of Local Speaker Diarization (And How We Dockerized It)
D
Full-stack developer and digital architect with over 20 years of experience in technical SEO and web product management. I am the creator behind a growing ecosystem of high-precision utility tools and specialized calculation engines. My work focuses on building interactive, user-centric platforms that simplify complex data—spanning industrial engineering standards, academic forecasting, and strategic gaming utilities. I’m passionate about micro-SaaS development, prompt engineering, and creating lightweight, high-performance web applications that provide immediate value to niche communities.

OpenAI's Whisper is arguably the most significant open-source contribution to speech recognition. But if you’ve ever tried to build a production-grade meeting transcription pipeline, you know Whisper has a fatal flaw: It doesn't know who is speaking.

In the B2B SaaS world, a transcript without speaker tags is just a useless wall of text. You need Speaker Diarization.

In this post, I'll walk through the architectural nightmares of combining ASR (Automatic Speech Recognition) with Diarization, and how we ultimately solved it by unifying the pipeline into a single, air-gapped Enterprise Docker image.

The Architecture of "Who Spoke When"

To get a perfect transcript with speaker tags, you can't just run one AI model. You need a highly orchestrated pipeline:

  1. VAD (Voice Activity Detection): Filters out silence and background noise to find actual speech segments.

  2. Diarization (e.g., PyAnnote / CAM++): Extracts voice embeddings and clusters them (identifying SPK_1, SPK_2, etc.).

  3. ASR (Faster-Whisper): Transcribes the actual words.

  4. Alignment: Merging the timestamps from the Diarization model with the word-level timestamps from Whisper.

The Dependency Hell

If you try to build this locally, you will immediately run into "dependency hell".

  • Whisper relies on specific versions of CTranslate2.

  • Diarization models often require conflicting versions of PyTorch or torchaudio.

  • Running this on an NVIDIA GPU requires precise matching of CUDA toolkits and cuDNN libraries.

When our enterprise clients asked to run our transcription engine on their own AWS VPCs for privacy reasons, we knew we couldn't just hand them a requirements.txt and wish them luck.

The Solution: A Zero-Dependency Docker Container

To solve this, we pivoted to an immutable infrastructure approach. We packaged the entire pipeline—ASR, VAD, Diarization, and a FastAPI backend—into a single Docker image.

1. Model Caching at Build Time

Instead of downloading multi-gigabyte models at runtime (which fails in air-gapped environments without internet access), we inject the AI models directly into the Docker image layers during the build process:

# Pre-baking huggingface/modelscope models into the image
COPY models_cache/huggingface /root/.cache/huggingface
COPY models_cache/modelscope /root/.cache/modelscope

2. Cython IP Protection

Because we deploy this to enterprise servers, we needed to protect the proprietary alignment algorithms. We added a build step that uses Cython to compile all core Python logic into .so binary extensions, entirely removing the human-readable .py source code from the final image.

3. Unified REST API

The container exposes a simple /api/transcribe endpoint. The client uploads an audio file, and the internal Python engine handles the complex VAD -> Diarization -> Whisper -> Alignment pipeline natively on the GPU, returning clean JSON.

Why This Matters for B2B

For sectors like legal, medical, and finance, uploading internal meeting recordings to public cloud APIs is a massive security violation. By providing a self-hosted, Dockerized pipeline, companies get state-of-the-art AI transcription while keeping 100% of their data strictly inside their own firewall.

If you are building products for privacy-conscious industries, stop fighting with PyTorch dependencies. Check out how we structured our Enterprise Docker Edition at FreeAudioToText.