audio-classification · 12-layer Wav2Vec2-Base · 20 ms CNN frames · 12 classes · WASM q8 · 95.89 MB · Apache-2.0

Wav2Vec2-Base SUPERB KS: 95.89 MB Spoken Command Classifier

Self-supervised Wav2Vec2-Base fine-tuned on the SUPERB Keyword Spotting benchmark (superb/wav2vec2-base-superb-ks, Apache-2.0) classifies 16 kHz mono audio into 12 Google Speech Commands v1 labels — 10 spoken commands (yes, no, up, down, left, right, on, off, stop, go) plus _unknown_ and _silence_ — directly on your device.

At a glance

Wav2Vec2-Base SUPERB Keyword Spotting model specifications and browser contract
HF ONNX artifact Xenova/wav2vec2-base-superb-ks (q8 · 95.89 MB = 95,885,969 B onnx/model_quantized.onnx · apache-2.0)
Upstream checkpoint superb/wav2vec2-base-superb-ks (apache-2.0 · 12 Transformer layers, 12 heads, hidden_size: 768, 7-layer CNN encoder, weighted layer sum → classifier_proj_size: 256)
Task & runtime audio-classification · shared @huggingface/transformers@3.7.5 via lib/webai.js · CPU wasm
12 output classes yes, no, up, down, left, right, on, off, stop, go, _unknown_, _silence_ (16 kHz mono Float32Array PCM, do_normalize: false)

1 · Classify spoken commands or live microphone

Ledgered audio: JFK inaugural excerpt (20 Jan 1961, public domain) and LibriSpeech test-clean 61-70968-0000 (Paul-Gabriel Wiener, CC BY 4.0) · audio credits, plus deterministic in-memory JS PCM waveforms and live microphone capture for saying commands directly.

Initialise Wav2Vec2-Base SUPERB KS (95.89 MB q8 WASM) above to classify commands locally.

Loading sample…

Live 12-class voice command matrix

Ranked 12-class probability distribution

Run classification above to inspect all 12 SUPERB Keyword Spotting probabilities.

Top-1 class–
Top-1 score–
Entropy–
Latency–
Clip duration–
Runtime · NaN check–

2 · See inside: 20 ms CNN frame envelope & pooled representation

Wav2Vec2's 7-layer 1D CNN feature encoder processes raw 16 kHz waveforms with a 25 ms receptive field (400 samples) and a 20 ms hop (320 samples → 50 frames/s). SUPERB computes a learned weighted sum across all 12 Transformer layers, mean-pools over frames, and projects 768 → 256 → 12 logits.

CNN frames (20 ms hop)–
Frame rate50.0 Hz
Command prob mass–
Audio RMS / Peak–

Why Wav2Vec2-Base SUPERB KS matters

Unlike spectrogram-based keyword models, Wav2Vec2 learns frame representations directly from raw waveform samples using self-supervised contrastive pretraining, then adapts cleanly to 12-way command spotting with explicit _unknown_ and _silence_ rejection classes.

3 · Use-case ladder

4 · How the API works

import { pipeline } from "@huggingface/transformers@3.7.5";

const classifier = await pipeline(
  "audio-classification",
  "Xenova/wav2vec2-base-superb-ks",
  { device: "wasm", dtype: "q8" },
);

const scores = await classifier(pcm16k, { top_k: 12 });
// → [{ label: "_unknown_", score: 0.99 }, { label: "go", score: 0.004 }, ...]

5 · Inspect worker, WAV decoder & mic code

Show the code · worker.js — ensureLoaded() (epoch-guarded Transformers.js 3.7.5 q8 pipeline)
Show the code · wav2vec2-base-superb-ks-core.mjs — parseWavToMono16k() (multi-bit-depth WAV parser)
Show the code · wav2vec2-base-superb-ks.js — createMicRecorder() (live command capture & cleanup)