# Repository Briefing: MahmoudAshraf97/whisper-diarization
> Source: https://repoforai.com/repo/MahmoudAshraf97/whisper-diarization (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/MahmoudAshraf97/whisper-diarization
- **Category**: Voice, Vision & Video (语音 / 视觉 / 视频生成)
- **Primary Language**: Jupyter Notebook
- **License**: BSD-2-Clause
- **Engineering Health**: B (57/100 · Maintenance 12/35 · Adoption 19/25 · Releases 6/20 · License 20/20)
- **Review Snapshot**: 2026-12-02
- **Deployment / Stack Signals**: CLI, GPU, Local AI
- **Momentum**: 5,677 ★ total (+1 24h / +3 7d) · 500 forks
- **Topics**: `asr`, `speaker-diarization`, `speech`, `speech-recognition`, `speech-to-text`, `whisper`
- **When to Use**: Best for: Local batch processing of interviews, podcasts, and meetings where speakers usually take turns and transcripts need speaker labels. Skip if: You need reliable attribution during crosstalk, a managed or real-time API, or configurable SRT sentence-length limits.

## Overview
```text
### Architecture & Core Mechanics
This is a local, file-oriented Python pipeline, with `diarize.py` as the main entrypoint and a companion notebook. It first extracts vocals with Demucs unless separation is disabled, transcribes with faster-whisper, and refines word timestamps with `ctc-forced-aligner`. The NeMo branch uses MarbleNet for voice activity detection and segmentation, then TitaNet for speaker embeddings.

The branches meet on the audio timeline: aligned words are mapped to speaker segments, and punctuation is used to refine sentence grouping around small timing shifts. The stack includes `nemo_toolkit[asr] >=2.5.0, <3`, `faster-whisper>=1.1.0`, `nltk`, and Git-sourced Demucs, deepmultilingualpunctuation, and ctc-forced-aligner. Some Whisper and NeMo settings are fixed in `diarize.py` and `helpers.py`, so deeper tuning requires editing Python rather than passing CLI flags.

### Key Capabilities & Differentiators
The pipeline produces speaker-attributed transcription from an audio file. It uses word-level timing internally to decide who spoke and then organizes the transcript into sentences. `--whisper-model` defaults to the English-only `medium.en`; for non-English audio, choose a multilingual model rather than relying on `--language` alone. The language flag is useful when automatic detection fails.

Use `--no-stem` to bypass vocal separation and `--suppress_numerals` to write numbers as words, which can improve alignment. `--device` selects the runtime device, defaulting to CUDA when available. Lower `--batch-size` to reduce memory pressure or set it to `0` for non-batched inference. A maximum sentence length for SRT subtitles is planned, not an available control.

### Trade-offs & Limitations
Compared with plain Whisper, this pipeline adds speaker attribution and timestamp reconciliation at the cost of additional model stages and a more involved installation. Compared with wiring Whisper to a separate diarization stack such as pyannote.audio, it provides a ready-made mapping from word timings to speaker segments, but exposes only part of that pipeline through CLI settings. Compared with a managed speech API, local execution keeps audio processing on your hardware while making you responsible for runtime maintenance and capacity.

Overlapping speech remains unresolved: extracting vocals does not separate one speaker from another. The experimental parallel entrypoint is intended to change scheduling, not transcript quality; whether it saves time depends on the workload and hardware. The repository is BSD-2-Clause, but dependencies and model weights should be reviewed separately before redistribution.

### Hardware & Deployment Guide
Target Python 3.10 or newer, with FFmpeg and Cython installed before running `pip install -c constraints.txt -r requirements.txt`. Python 3.9 is possible with manual dependency installation but is not the straightforward setup path. Start with `python diarize.py -a AUDIO_FILE_NAME`. Installation pulls several packages from Git, so plan to stage dependencies and model assets separately for an air-gapped deployment rather than assuming an offline installer.

Inference runs locally; no hosted speech API is required. Once the sequential path works on representative files, try `diarize_parallel.py` if the machine meets the stated 10 GB VRAM recommendation and throughput matters. No tagged release is listed, so record the tested repository commit and Python environment for repeatable deployment.
```

## Key Capabilities
```text
- Pipeline: faster-whisper provides ASR; CTC forced alignment puts transcript words on a timeline that can be matched to NeMo speaker segments.
- Speaker attribution: MarbleNet detects speech, TitaNet extracts speaker embeddings, and punctuation helps refine sentence boundaries around small timing offsets.
- Audio preprocessing: Demucs vocal separation can be bypassed with `--no-stem` when the extra processing is not worthwhile.
- Execution modes: `diarize.py` is the sequential entrypoint; experimental `diarize_parallel.py` runs Whisper and NeMo concurrently, with at least 10 GB of VRAM recommended.
- Inference controls: The CLI defaults to `medium.en` and exposes model, language, device, numeral handling, and batching controls.
- Dependency management: Installation uses `constraints.txt`; Demucs, deepmultilingualpunctuation, and ctc-forced-aligner are fetched from Git repositories.
```

## Quick Start / Clone
```bash
pip install cython
```
