At a glance
| 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.
Live 12-class voice command matrix
Ranked 12-class probability distribution
Run classification above to inspect all 12 SUPERB Keyword Spotting probabilities.
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.
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.
- Always-local voice gating — distinguish real commands from background speech (
_unknown_) and silence (_silence_) before invoking heavier ASR. - Zero external mel preprocessing — raw 16 kHz mono PCM goes straight into the 7-layer convolutional feature encoder.
- Auditable probabilities — inspect all 12 softmax classes, margin, and Shannon entropy in bits on every call.
3 · Use-case ladder
Basics · Time-Slice & Padding Lab
Sweep 0.3s, 0.6s, 1.0s, and 2.0s windows across head/center/tail/zero-pad framing to see how 1-second SUPERB pooling shifts logits.
Practical · Dataset Router & Gatekeeper
Queue multiple audio clips sequentially with a live confidence gate slider, mid-batch cancel, and formula-safe CSV / JSON manifest export.
Wild · Acoustic Stress & Trap Lab
Inject +10 dB/0 dB noise, 300–3400 Hz telephone bandpass, +12 dB clipping, -18 dB quiet, 0.85×/1.25× stretch, and silence/tone traps.
Multi-model · 136.7 MB Gate + Whisper Router
Chain Wav2Vec2 SUPERB KS (95.89 MB) with Whisper-Tiny EN (40.85 MB) to fast-path spoken commands and escalate _unknown_ speech to full ASR.
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 }, ...]