Feature Extraction
Transformers
Safetensors
resemblyzer
audio
speaker-embedding
speaker-verification
custom_code
Instructions to use prj-beatrice/resemblyzer-torch-native with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use prj-beatrice/resemblyzer-torch-native with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="prj-beatrice/resemblyzer-torch-native", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("prj-beatrice/resemblyzer-torch-native", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Resemblyzer
resemble-ai/Resemblyzer, adapted to use with only torch, torchaudio, and transformers.
import soundfile as sf
import torch
from transformers import AutoModel
device = "cuda" if torch.cuda.is_available() else "cpu"
wav, sr = sf.read("audio.wav", dtype="float32")
wav = torch.from_numpy(wav)
model = AutoModel.from_pretrained(
"prj-beatrice/resemblyzer-torch-native", trust_remote_code=True
).eval().to(device)
with torch.inference_mode():
embedding = model(wav.to(device), sampling_rate=sr).embeddings[0]
The result matches this code:
from resemblyzer import VoiceEncoder, preprocess_wav
# Non-16 kHz input is resampled differently, so exact agreement is not expected.
assert sr == 16_000
reference = torch.from_numpy(
VoiceEncoder().embed_utterance(preprocess_wav("audio.wav"))
)
torch.testing.assert_close(embedding.cpu(), reference)
Padded batches use a waveform tensor [batch_size, max_length] and an input_lengths tensor [batch_size].
License
Resemblyzer components are Apache-2.0, WebRTC VAD components are BSD-3-Clause, and the wrapper is MIT-licensed; see LICENSE.
- Downloads last month
- 36