Using this open-source model in production?
Consider switching to
pyannoteAI for better and faster options.
Relies on pyannote.audio 2.1: see
installation instructions.
This model is based on the
canonical x-vector TDNN-based architecture, but with filter banks replaced with
trainable SincNet features. See
XVectorSincNet architecture for implementation details.
1# 1. visit hf.co/pyannote/embedding and accept user conditions
2# 2. visit hf.co/settings/tokens to create an access token
3# 3. instantiate pretrained model
4from pyannote.audio import Model
5model = Model.from_pretrained("pyannote/embedding",
6 use_auth_token="ACCESS_TOKEN_GOES_HERE")
1from pyannote.audio import Inference
2inference = Inference(model, window="whole")
3embedding1 = inference("speaker1.wav")
4embedding2 = inference("speaker2.wav")
5# `embeddingX` is (1 x D) numpy array extracted from the file as a whole.
6
7from scipy.spatial.distance import cdist
8distance = cdist(embedding1, embedding2, metric="cosine")[0,0]
9# `distance` is a `float` describing how dissimilar speakers 1 and 2 are.
Using cosine distance directly, this model reaches 2.8% equal error rate (EER) on VoxCeleb 1 test set.
This is without voice activity detection (VAD) nor probabilistic linear discriminant analysis (PLDA).
Expect even better results when adding one of those.
1import torch
2inference.to(torch.device("cuda"))
3embedding = inference("audio.wav")
1from pyannote.audio import Inference
2from pyannote.core import Segment
3inference = Inference(model, window="whole")
4excerpt = Segment(13.37, 19.81)
5embedding = inference.crop("audio.wav", excerpt)
6# `embedding` is (1 x D) numpy array extracted from the file excerpt.
1from pyannote.audio import Inference
2inference = Inference(model, window="sliding",
3 duration=3.0, step=1.0)
4embeddings = inference("audio.wav")
5# `embeddings` is a (N x D) pyannote.core.SlidingWindowFeature
6# `embeddings[i]` is the embedding of the ith position of the
7# sliding window, i.e. from [i * step, i * step + duration].
1@inproceedings{Bredin2020,
2 Title = {{pyannote.audio: neural building blocks for speaker diarization}},
3 Author = {{Bredin}, Herv{\'e} and {Yin}, Ruiqing and {Coria}, Juan Manuel and {Gelly}, Gregory and {Korshunov}, Pavel and {Lavechin}, Marvin and {Fustes}, Diego and {Titeux}, Hadrien and {Bouaziz}, Wassim and {Gill}, Marie-Philippe},
4 Booktitle = {ICASSP 2020, IEEE International Conference on Acoustics, Speech, and Signal Processing},
5 Address = {Barcelona, Spain},
6 Month = {May},
7 Year = {2020},
8}
1@inproceedings{Coria2020,
2 author="Coria, Juan M. and Bredin, Herv{\'e} and Ghannay, Sahar and Rosset, Sophie",
3 editor="Espinosa-Anke, Luis and Mart{\'i}n-Vide, Carlos and Spasi{\'{c}}, Irena",
4 title="{A Comparison of Metric Learning Loss Functions for End-To-End Speaker Verification}",
5 booktitle="Statistical Language and Speech Processing",
6 year="2020",
7 publisher="Springer International Publishing",
8 pages="137--148",
9 isbn="978-3-030-59430-5"
10}
This repository is an unmodified copy of
pyannote/embedding
at commit
4db4899737a38b2d618bbd74350915aa10293cb2, mirrored on 2026-08-13 so that it can be fetched without
the upstream access form. No weights, configuration or licence terms were changed;
all credit and the original licence remain with the upstream authors.