automatic-speech-recognition Β· audio Β· WASM (WebGPU when available) Β· ~95 MB
wav2vec2 is a different kind of speech model. Whisper, Moonshine and Distil-Whisper are seq2seq β a decoder generates text token by token (and can hallucinate). wav2vec2 is a CTC model: it labels every ~20 ms frame of audio with a single character (or a blank), then collapses that per-frame strip into words. No decoder, no autoregression, no invented words. Pick a clip and watch the collapse happen.
| Model | Xenova/wav2vec2-base-960h (facebook/wav2vec2-base-960h, English) |
|---|---|
| Task / pipeline | automatic-speech-recognition β but loaded as AutoModelForCTC so we can see the frames |
| Architecture | CTC (Connectionist Temporal Classification): a 12-layer transformer encoder over raw audio β per-frame logits across a 32-symbol vocab (blank + "|" word boundary + 26 letters + apostrophe). ~94M params. No decoder. |
| Quantization | q8 (8-bit) ONNX β onnx/model_quantized.onnx |
| Backend | WebAssembly (WebGPU when a real adapter is present), honest fallback |
| Download | ~95 MB (single encoder model), cached after first load |
| License | Apache-2.0 (facebook wav2vec2) |
| Web APIs | WebAssembly / WebGPU, Web Workers, Web Audio (decode + resample), MediaRecorder (mic) |
Choose audio β record from your mic, upload a file, or pick a sample. The page decodes it to 16 kHz mono, draws the waveform, and runs the CTC model in a Web Worker. wav2vec2 is trained on clean read speech, so it does best on clear speech (the JFK sample is ideal).
The bundled JFK speech clip alone is an inaugural excerpt (20 January 1961), spoken by John F. Kennedy β public domain, U.S. government work Β· JFK audio source and attribution record.
This context didn't grant mic access (common in headless / embedded views). wav2vec2 still works β use a sample above or Upload audio. For live recording, open this in a normal browser tab and allow the microphone when prompted.
This is what makes wav2vec2 different. Below is the model's raw per-frame argmax:
one cell per ~20 ms frame, showing the single character it thinks is most likely there. Most
frames are blank (Β·) β the model saying "nothing new here". Where a sound lands you get a
run of the same letter. The transcript is produced by two mechanical rules, no decoder involved:
(1) merge consecutive duplicates, (2) drop the blanks. Watch a run like
Β·Β· AA Β·Β· SS S Β·Β· KK collapse to ASK.
Raw per-frame argmax (β frames Β· ~β ms each):
β merge duplicates, drop blanks β
Because CTC labels frames instead of generating tokens, it has properties Whisper doesn't. It can't hallucinate a plausible-but-unspoken sentence when the audio is silent or noisy β worst case it emits blanks. And because every character is pinned to a frame, you get timing for free: exactly where in the audio each word (and letter) was said. That's the basis for forced alignment, karaoke, and pronunciation feedback.
One clip in, a transcript out β and the per-frame strip that produced it.
Forced alignment: real per-word timings, straight from the CTC frames.
Scrub the frames: hover the timeline and read the model's raw acoustic guess.
Transcribe with CTC β an on-device LLM cleans up punctuation & casing.
The one-liner is the ASR pipeline β but to see the frames we load the model directly and do the CTC collapse ourselves (which is exactly what the pipeline does internally):
import { AutoProcessor, AutoModelForCTC } from "@huggingface/transformers";
const processor = await AutoProcessor.from_pretrained("Xenova/wav2vec2-base-960h");
const model = await AutoModelForCTC.from_pretrained(
"Xenova/wav2vec2-base-960h",
{ device: "wasm", dtype: "q8" },
);
// audio = 16 kHz mono Float32Array
const inputs = await processor(audio);
const { logits } = await model(inputs); // shape [1, frames, 32]
// greedy CTC decode: argmax per frame, merge duplicates, drop the blank (id 0)
const ids = argmaxPerFrame(logits); // e.g. [0,0,7,7,0,12,...]
const text = collapse(ids); // "THE ..." β no decoder involved
Inference runs in a Web Worker so the UI never janks. The worker returns the raw per-frame argmax and real per-word timings (from the frame each character was emitted at) β nothing is faked or pre-computed.