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

BREAKING: prepare for getting rid of ONNX runtime #1541

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
- feat(utils): add `"soft"` option to `Powerset.to_multilabel`
- improve(pipeline): compute `fbank` on GPU when requested
- fix(pipeline): fix `AgglomerativeClustering` to honor `num_clusters` when provided
- BREAKING(pipeline): rename `WeSpeakerPretrainedSpeakerEmbedding` to `ONNXWeSpeakerPretrainedSpeakerEmbedding`
- BREAKING(setup): remove `onnxruntime` dependency.
You can still use ONNX `hbredin/wespeaker-voxceleb-resnet34-LM` but you will have to install `onnxruntime` yourself.

## Version 3.0.1 (2023-09-28)

Expand Down
16 changes: 11 additions & 5 deletions pyannote/audio/pipelines/speaker_verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def __call__(
return embeddings


class WeSpeakerPretrainedSpeakerEmbedding(BaseInference):
class ONNXWeSpeakerPretrainedSpeakerEmbedding(BaseInference):
"""Pretrained WeSpeaker speaker embedding

Parameters
Expand All @@ -398,7 +398,7 @@ class WeSpeakerPretrainedSpeakerEmbedding(BaseInference):

Usage
-----
>>> get_embedding = WeSpeakerPretrainedSpeakerEmbedding("hbredin/wespeaker-voxceleb-resnet34-LM")
>>> get_embedding = ONNXWeSpeakerPretrainedSpeakerEmbedding("hbredin/wespeaker-voxceleb-resnet34-LM")
>>> assert waveforms.ndim == 3
>>> batch_size, num_channels, num_samples = waveforms.shape
>>> assert num_channels == 1
Expand All @@ -418,7 +418,7 @@ def __init__(
):
if not ONNX_IS_AVAILABLE:
raise ImportError(
f"'onnxruntime' must be installed to use '{embedding}' embeddings. "
f"'onnxruntime' must be installed to use '{embedding}' embeddings."
)

super().__init__()
Expand Down Expand Up @@ -745,7 +745,12 @@ def PretrainedSpeakerEmbedding(
>>> embeddings = get_embedding(waveforms, masks=masks)
"""

if isinstance(embedding, str) and "speechbrain" in embedding:
if isinstance(embedding, str) and "pyannote" in embedding:
return PyannoteAudioPretrainedSpeakerEmbedding(
embedding, device=device, use_auth_token=use_auth_token
)

elif isinstance(embedding, str) and "speechbrain" in embedding:
return SpeechBrainPretrainedSpeakerEmbedding(
embedding, device=device, use_auth_token=use_auth_token
)
Expand All @@ -754,9 +759,10 @@ def PretrainedSpeakerEmbedding(
return NeMoPretrainedSpeakerEmbedding(embedding, device=device)

elif isinstance(embedding, str) and "wespeaker" in embedding:
return WeSpeakerPretrainedSpeakerEmbedding(embedding, device=device)
return ONNXWeSpeakerPretrainedSpeakerEmbedding(embedding, device=device)

else:
# fallback to pyannote in case we are loading a local model
return PyannoteAudioPretrainedSpeakerEmbedding(
embedding, device=device, use_auth_token=use_auth_token
)
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ einops >=0.6.0
huggingface_hub >= 0.13.0
lightning >= 2.0.1
omegaconf >=2.1,<3.0
onnxruntime-gpu >= 1.16.0
pyannote.core >= 5.0.0
pyannote.database >= 5.0.1
pyannote.metrics >= 3.2
Expand Down
Loading