Implementation:Speechbrain Speechbrain AMI Diarization Experiment
| Knowledge Sources | |
|---|---|
| Domains | Speaker_Diarization |
| Last Updated | 2026-02-09 00:00 GMT |
Overview
Concrete tool for speaker diarization using deep embeddings and spectral clustering provided by the SpeechBrain library.
Description
This script implements an end-to-end speaker diarization pipeline on the AMI Meeting Corpus. It extracts deep speaker embeddings (e.g., ECAPA-TDNN) from speech segments obtained via Oracle VAD (voice activity detection taken from ground truth), stores them as StatObject_SB objects, and then applies spectral clustering (or optionally other backends) to assign speaker labels. The pipeline iterates over individual recordings to reduce GPU memory demands. The final output is an RTTM-formatted speaker boundary file, and the system is evaluated using the Diarization Error Rate (DER) metric.
The recipe is based on the paper: N. Dawalatabad, M. Ravanelli, F. Grondin, J. Thienpondt, B. Desplanques, H. Na, "ECAPA-TDNN Embeddings for Speaker Diarization," arXiv:2104.01466, 2021.
Usage
Run as a standalone recipe script with a YAML hyperparameter file specifying the embedding model, clustering parameters, and dataset paths. Typical usage is for evaluating diarization performance on the AMI corpus with Oracle VAD conditions.
Code Reference
Source Location
- Repository: SpeechBrain
- File: recipes/AMI/Diarization/experiment.py
Signature
def compute_embeddings(wavs, lens):
"""Definition of the steps for computation of embeddings from the waveforms."""
...
def embedding_computation_loop(split, set_loader, stat_file):
"""Extracts embeddings for a given dataset loader."""
...
def prepare_subset_json(full_meta_data, rec_id, out_meta_file):
"""Prepares metadata for a given recording ID."""
...
def diarize_dataset(full_meta, split_type, n_lambdas, pval, n_neighbors=10):
"""Diarizes all the recordings in a given dataset using spectral clustering."""
...
Import
python experiment.py hparams/ecapa_tdnn.yaml
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| hparams_file | str | Yes | Path to YAML hyperparameter file (e.g., ecapa_tdnn.yaml) |
| wavs | torch.Tensor | Yes | Waveform tensor batch for embedding extraction |
| lens | torch.Tensor | Yes | Relative lengths of each waveform in the batch |
| full_meta | dict | Yes | Full JSON metadata containing all recordings |
| split_type | str | Yes | Dataset split identifier (e.g., "dev", "eval") |
| n_lambdas | int | Yes | Number of eigenvalues for spectral clustering tuning |
| pval | float | Yes | p-value threshold for spectral clustering |
Outputs
| Name | Type | Description |
|---|---|---|
| RTTM file | file | Speaker boundary file in RTTM format per recording |
| DER scores | float | Diarization Error Rate computed against ground truth |
| stat_obj | StatObject_SB | Stored embeddings object with modelset, segset, and stat1 |
Usage Examples
# Run the diarization experiment with ECAPA-TDNN embeddings
python experiment.py hparams/ecapa_tdnn.yaml
# With overrides
python experiment.py hparams/ecapa_tdnn.yaml --data_folder /path/to/AMI --output_folder results/