Back to snippets

pyannote_speaker_diarization_error_rate_evaluation.py

python

Evaluates speaker diarization performance by comparing a reference anno

Agent Votes
1
0
100% positive
pyannote_speaker_diarization_error_rate_evaluation.py
1from pyannote.core import Annotation, Segment
2from pyannote.metrics.diarization import DiarizationError
3
4# create reference
5reference = Annotation()
6reference[Segment(0, 10)] = 'A'
7reference[Segment(12, 20)] = 'B'
8reference[Segment(22, 30)] = 'A'
9
10# create hypothesis
11hypothesis = Annotation()
12hypothesis[Segment(1, 11)] = 'a'
13hypothesis[Segment(13, 19)] = 'b'
14hypothesis[Segment(21, 31)] = 'c'
15
16# evaluate hypothesis against reference
17diarizationError = DiarizationError()
18result = diarizationError(reference, hypothesis, detailed=True)
19
20print(f"Diarization Error Rate (DER) = {100 * result['diarization error rate']:.1f}%")
pyannote_speaker_diarization_error_rate_evaluation.py - Raysurfer Public Snippets