From 24f202dd51b8738019b059a7dedc84bb49b3aadc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20BREDIN?= Date: Sun, 17 Aug 2025 11:38:34 +0200 Subject: [PATCH] feat: add `exclusive_diarization` flag (#1898) --- src/pyannote/audio/pipelines/speaker_diarization.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pyannote/audio/pipelines/speaker_diarization.py b/src/pyannote/audio/pipelines/speaker_diarization.py index edcd17b2..d835f893 100644 --- a/src/pyannote/audio/pipelines/speaker_diarization.py +++ b/src/pyannote/audio/pipelines/speaker_diarization.py @@ -452,6 +452,7 @@ class SpeakerDiarization(SpeakerDiarizationMixin, Pipeline): num_speakers: Optional[int] = None, min_speakers: Optional[int] = None, max_speakers: Optional[int] = None, + exclusive_diarization: bool = False, return_embeddings: bool = False, hook: Optional[Callable] = None, ) -> Annotation: @@ -467,6 +468,9 @@ class SpeakerDiarization(SpeakerDiarizationMixin, Pipeline): Minimum number of speakers. Has no effect when `num_speakers` is provided. max_speakers : int, optional Maximum number of speakers. Has no effect when `num_speakers` is provided. + exclusive_diarization : bool, optional + Enforce exclusive diarization, i.e. only one speaker can be active at a time. + Defaults to False, i.e. overlapping speech is allowed. return_embeddings : bool, optional Return representative speaker embeddings. hook : callable, optional @@ -535,6 +539,9 @@ class SpeakerDiarization(SpeakerDiarizationMixin, Pipeline): # shape: (num_frames, 1) # dtype: int + if exclusive_diarization: + count.data = np.minimum(count.data, 1).astype(np.int8) + # exit early when no speaker is ever active if np.nanmax(count.data) == 0.0: diarization = Annotation(uri=file["uri"])