加载中…
加载中…
facebook/wav2vec2-base fine-tuned on Speech Commands v0.02 to
recognise 35 spoken English words: yes, no, up, down, left, right, on, off, stop, go, forward,
backward, follow, learn, the digits zero to nine, and bed, bird, cat, dog, happy, house, marvin,
sheila, tree, visual, wow.
Try it: speech-commands-demo · Code: github.com/dpontejs/classificacao_voz
from transformers import pipeline
classifier = pipeline("audio-classification", model="diegomponte/wav2vec2-base-speech-commands-35")
classifier("my_recording.wav", top_k=3)
# [{'label': 'yes', 'score': 0.99}, ...]
In the browser, with Transformers.js and the int8
ONNX export in onnx/:
import { pipeline } from "@huggingface/transformers";
const classifier = await pipeline(
"audio-classification", "diegomponte/wav2vec2-base-speech-commands-35", { dtype: "q8" },
);
await classifier(float32Audio16kHz, { top_k: 3 });
Input should be one second of 16 kHz mono audio with a single word. For longer recordings, cut the second around the word first (the demo keeps the loudest second).
Official test split: 11,005 clips from speakers never seen in training.
| Metric | Value |
|---|---|
| Accuracy | 97.72% |
| Macro F1 | 0.975 |
| Validation accuracy (best epoch) | 97.75% |
The ONNX exports were measured on the same test split with ONNX Runtime:
| File | Size | Accuracy |
|---|---|---|
model.safetensors (PyTorch) |
378 MB | 97.72% |
onnx/model.onnx (fp32) |
379 MB | 97.72% |
onnx/model_quantized.onnx (int8, transformer MatMuls only) |
122 MB | 97.71% |
Quantizing every layer, including the convolutional feature encoder, gave a 95 MB file but dropped accuracy to 78.4%, so the convolutions stay in fp32.
Hardest words by F1: "tree" (0.91), "forward" (0.95), "learn" (0.95). Most errors are between words that sound alike: "tree" ↔ "three" (25 of the errors) and "off" heard as "up" (10).
This is the 35-word task. It is not comparable to the 12-class keyword-spotting benchmark (10 words + "unknown" + "silence") reported by SUPERB and many papers.
Wav2Vec2ForSequenceClassification (projection to 256, mean pooling over time, linear
classifier). The convolutional feature encoder is frozen; the transformer and head are trained.Apache-2.0, like the base model facebook/wav2vec2-base.
Trained on Speech Commands by Pete Warden, released under CC-BY-4.0.
facebook/wav2vec2-base