feat: add exclusive_diarization flag (#1898)

This commit is contained in:
Hervé BREDIN authored and GitHub committed 2025-08-17 11:38:34 +02:00
1 parent 365704d336
commit 24f202dd51
1 file changed
+7
@@ -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"])