← All models

automatic-speech-recognition Β· audio Β· WASM (WebGPU when available) Β· ~95 MB

wav2vec2 β€” speech to text, one character per frame

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.

At a glance

ModelXenova/wav2vec2-base-960h (facebook/wav2vec2-base-960h, English)
Task / pipelineautomatic-speech-recognition β€” but loaded as AutoModelForCTC so we can see the frames
ArchitectureCTC (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.
Quantizationq8 (8-bit) ONNX β€” onnx/model_quantized.onnx
BackendWebAssembly (WebGPU when a real adapter is present), honest fallback
Download~95 MB (single encoder model), cached after first load
LicenseApache-2.0 (facebook wav2vec2)
Web APIsWebAssembly / WebGPU, Web Workers, Web Audio (decode + resample), MediaRecorder (mic)

Run it

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).

or a sample:

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.

JFK β€” inaugural (11s)

Transcript

Transcribe a clip to see the text here.

See inside β€” the CTC collapse

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.

emitted character ␣ word boundary · blank frame
Transcribe a clip to see its per-frame argmax and the collapse.

Why it matters

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.

Use cases

Basics

One clip in, a transcript out β€” and the per-frame strip that produced it.

Practical

Forced alignment: real per-word timings, straight from the CTC frames.

Wild

Scrub the frames: hover the timeline and read the model's raw acoustic guess.

Multi-model

Transcribe with CTC β†’ an on-device LLM cleans up punctuation & casing.

How the API works

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.

References