← All models

audio-classification (speaker-embedding) Β· audio Β· WASM/WebGPU Β· ~102 MB

Speaker verification β€” same voice, or not?

WavLM-SV turns a voice clip into a 512-number embedding β€” a point in "voice space" where the same speaker's clips land close together and different speakers land apart. Compare two clips and you get a similarity signal: likely the same speaker, or likely not. It runs entirely on your device β€” the audio and the embeddings never leave the tab. This is voice similarity, not identification, lookup, or surveillance.

At a glance

ModelXenova/wavlm-base-plus-sv β€” WavLMForXVector (VoxCeleb speaker verification)
Taskaudio-classification (speaker embedding / x-vector) β€” no pipeline task, loaded via AutoModelForXVector
RuntimeTransformers.js 3.7.5 (registers WavLMForXVector; there is no audio-xvector pipeline)
Input16 kHz mono audio (decoded in-page) β†’ the WavLM feature extractor
Output[1, 512] β€” the speaker embedding; L2-normalized, then compared by cosine similarity
Quantizationq8 ONNX
BackendWebAssembly (WebGPU when a real adapter is available)
Download~102 MB, cached after first load
LicenseMIT (ONNX export) Β· WavLM weights (microsoft/wavlm-base-plus-sv)
Web APIsWebAssembly, Web Workers, Web Audio (decode), MediaRecorder (optional mic) β€” all Baseline widely available

Run it

Pick a clip for each side (or record/upload your own), then compare. The model embeds each voice and the page measures the cosine similarity of the two embeddings β€” a same/different SIGNAL, not a verdict.

Voice A

Upload clip

Voice B

Upload clip

Everything runs on your device β€” the clips and the embeddings never leave the tab. Voice similarity is a fuzzy signal that varies with recording, noise, and phrasing; never treat it as identity or a security decision. Sample voices: Voice 1 is a public-domain JFK speech; the others are the neutral speech clips already bundled with the showcase's ASR demos.

See inside

The model doesn't decide "same or different" β€” it outputs a 512-number vector per clip. All the page does is measure the angle between the two vectors (cosine similarity) and compare it to a threshold. Below are the two real embeddings (first 128 of 512 dims shown) β€” bars up for positive dimensions, down for negative. Same-speaker clips have visibly similar patterns.

Compare two voices to see their embeddings.

Why it matters

A speaker embedding is the building block behind "is this the same voice?" β€” and doing it on-device means the biometric never touches a server. Once a voice is a 512-number point you can compare, cluster, and threshold, all client-side:

These are similarity tools. Real voice authentication needs consent, liveness / anti-spoofing, bias auditing, and calibration this demo deliberately does not provide.

Use cases

Basics

Two clips in, one similarity number out β€” see same vs different in "voice space".

Practical

On-device "voice unlock" concept β€” enrol a reference voice, then check a probe against a threshold (a signal, never a verdict).

Wild

Impersonation & look-alikes β€” find the different speakers the model scores as suspiciously close.

Multi-model

VAD β†’ embed: trim silence with voice-activity detection first, then embed only the speech.

How the API works

transformers.js registers WavLMForXVector but has no audio-xvector pipeline, so we load the model + processor directly. The two things a pipeline would hide β€” feature extraction and L2-normalizing the output β€” are a few lines:

import { AutoModelForXVector, AutoProcessor } from "@huggingface/transformers";

const processor = await AutoProcessor.from_pretrained("Xenova/wavlm-base-plus-sv");
const model = await AutoModelForXVector.from_pretrained("Xenova/wavlm-base-plus-sv", { dtype: "q8" });

// audioA / audioB are 16 kHz mono Float32Arrays (decoded in-page)
const { embeddings: eA } = await model(await processor(audioA));
const { embeddings: eB } = await model(await processor(audioB));

const similarity = cosine(l2norm(eA.data), l2norm(eB.data)); // ∈ [-1, 1]; β‰₯0.86 β‡’ likely same speaker

Both embeddings are computed in a Web Worker so the UI never blocks, and the model is cached by Transformers.js, so a returning visit auto-initialises with no re-download.

References