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

fix: compute fbank on selected device #1529

Merged
merged 2 commits into from
Nov 7, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- BREAKING(pipeline): remove `logging_hook` (use `ArtifactHook` instead)
- fix(pipeline): add missing "embedding" hook call in `SpeakerDiarization`
- feat(utils): add `"soft"` option to `Powerset.to_multilabel`
- improve(pipeline): compute `fbank` on GPU when requested

## Version 3.0.1 (2023-09-28)

Expand Down
7 changes: 4 additions & 3 deletions pyannote/audio/pipelines/speaker_verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ def compute_fbank(
for waveform in waveforms
]
)

return features - torch.mean(features, dim=1, keepdim=True)

def __call__(
Expand All @@ -578,12 +579,12 @@ def __call__(
batch_size, num_channels, num_samples = waveforms.shape
assert num_channels == 1

features = self.compute_fbank(waveforms)
features = self.compute_fbank(waveforms.to(self.device))
_, num_frames, _ = features.shape

if masks is None:
embeddings = self.session_.run(
output_names=["embs"], input_feed={"feats": features.numpy()}
output_names=["embs"], input_feed={"feats": features.numpy(force=True)}
)[0]

return embeddings
Expand All @@ -606,7 +607,7 @@ def __call__(

embeddings[f] = self.session_.run(
output_names=["embs"],
input_feed={"feats": masked_feature.numpy()[None]},
input_feed={"feats": masked_feature.numpy(force=True)[None]},
)[0][0]

return embeddings
Expand Down
Loading