Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve(pipeline): do not extract embeddings in SpeakerDiarization pipeline when max_speakers is 1 #1686

Merged
merged 5 commits into from
May 19, 2024

Conversation

hbredin
Copy link
Member

@hbredin hbredin commented Apr 11, 2024

This PR avoids the costly speaker embedding extraction step when the speaker diarization pipeline is used for voice activity detection with max_speakers = 1.

from pyannote.audio import Pipeline
from pyannote.audio.sample import SAMPLE_FILE
from pyannote.audio.pipelines.utils.hook import ProgressHook

pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization-3.1")

with ProgressHook() as hook:
    speaker_diarization = pipeline(SAMPLE_FILE, hook=hook)

# segmentation         ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:01
# speaker_counting     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
# embeddings           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:10
# discrete_diarization ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00

with ProgressHook() as hook:
    voice_activity_detection = pipeline(SAMPLE_FILE, max_speakers=1, hook=hook)

# segmentation         ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:01
# speaker_counting     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
# discrete_diarization ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
# Look ma! No costly embeddings step!

It can be tested with

pip install https://github.com/pyannote/pyannote-audio/archive/feat/skip-embedding-when-max-speakers-is-1.tar.gz

@hbredin hbredin merged commit 5e03622 into develop May 19, 2024
4 checks passed
@hbredin hbredin deleted the feat/skip-embedding-when-max-speakers-is-1 branch May 19, 2024 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant