Xenova/wavlm-base-sv
By Xenova · ↓ 6 · ♥ 0 · Updated 2024-10-08
What's in this repo
This page lists the files in Xenova/wavlm-base-sv, including model.onnx, model_quantized.onnx.
- 2 ONNX models (.onnx files)
- 7 files, including 3 .json, 2 .onnx, 1 .md
- Last updated 2024-10-08
ONNX files
How to use
These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.
README
https://huggingface.co/microsoft/wavlm-base-sv with ONNX weights to be compatible with Transformers.js.
Usage (Transformers.js)
If you haven't already, you can install the Transformers.js JavaScript library from NPM using:
npm i @xenova/transformers
Example: Speaker verification w/ Xenova/wavlm-base-sv.
import { AutoProcessor, AutoModel, read_audio, cos_sim } from '@xenova/transformers';
// Load processor and model
const processor = await AutoProcessor.from_pretrained('Xenova/wavlm-base-sv');
const model = await AutoModel.from_pretrained('Xenova/wavlm-base-sv');
// Helper function to compute speaker embedding from audio URL
async function compute_embedding(url) {
const audio = await read_audio(url, 16000);
const inputs = await processor(audio);
const { embeddings } = await model(inputs);
return embeddings.data;
}
// Generate speaker embeddings
const BASE_URL = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/sv_speaker';
const speaker_1_1 = await compute_embedding(`${BASE_URL}-1_1.wav`);
const speaker_1_2 = await compute_embedding(`${BASE_URL}-1_2.wav`);
const speaker_2_1 = await compute_embedding(`${BASE_URL}-2_1.wav`);
const speaker_2_2 = await compute_embedding(`${BASE_URL}-2_2.wav`);
// Compute similarity scores
console.log(cos_sim(speaker_1_1, speaker_1_2)); // 0.9339586437268694 (Both are speaker 1)
console.log(cos_sim(speaker_1_2, speaker_2_1)); // 0.7096775310911547 (Different speakers)
console.log(cos_sim(speaker_2_1, speaker_2_2)); // 0.9603887462630838 (Both are speaker 2)
Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using 🤗 Optimum and structuring your repo like this one (with ONNX weights located in a subfolder named onnx).
Model info
Created: 2024-02-28
Updated: 2024-10-08
View on Hugging FaceFiles (7)
Related models
More from Xenova
More models
No task type declared.