pyannote-metrics

4.0.0 · active · verified Thu Apr 09

pyannote.metrics is an open-source Python library, currently at version 4.0.0, designed for reproducible evaluation, diagnostic, and error analysis of speaker diarization systems. It provides a comprehensive set of evaluation metrics and a command-line interface, making it a critical tool for researchers in the field of speech processing. The library maintains a steady release cadence with regular updates and occasional major version changes that introduce breaking modifications.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to compute the Diarization Error Rate (DER) using `pyannote.metrics`. It involves creating `Annotation` objects for both the reference and hypothesis, defining temporal `Segment`s with speaker labels, and then instantiating and calling the `DiarizationErrorRate` class.

from pyannote.core import Segment, Annotation
from pyannote.metrics.diarization import DiarizationErrorRate

# Define a reference (ground truth) annotation
reference = Annotation(uri='file1')
reference[Segment(0, 10)] = 'A'
reference[Segment(12, 20)] = 'B'
reference[Segment(24, 27)] = 'A'
reference[Segment(30, 40)] = 'C'

# Define a hypothesis (system output) annotation
hypothesis = Annotation(uri='file1')
hypothesis[Segment(2, 13)] = 'a'
hypothesis[Segment(13, 14)] = 'd'
hypothesis[Segment(14, 20)] = 'b'
hypothesis[Segment(22, 38)] = 'c'
hypothesis[Segment(38, 40)] = 'd'

# Instantiate the Diarization Error Rate metric
metric = DiarizationErrorRate()

# Compute the DER
der_value = metric(reference, hypothesis)
print(f"Diarization Error Rate: {der_value:.3f}")

view raw JSON →