audio-classification Β· audio Β· WASM Β· ~95 MB
Two people can say "I'm fine" and mean opposite things. This model listens to how something is said β the acoustics of the voice, not the transcript β and names the emotion: angry, happy, sad, fearful, disgust, or neutral. It's a wav2vec2 network that reads the raw waveform, running entirely on your device.
| Model | onnx-community/wav2vec2-base-Speech_Emotion_Recognition-ONNX |
|---|---|
| Task / pipeline | audio-classification |
| Architecture | wav2vec2-base with a sequence-classification head (Wav2Vec2ForSequenceClassification) β reads the raw 16 kHz waveform, no spectrogram step |
| Classes | 6 emotions: ANGRY, DISGUST, FEAR, HAPPY, NEUTRAL, SAD |
| Input | 16 kHz mono Float32Array, mean/variance normalised |
| Quantization | q8 (8-bit) ONNX |
| Backend | WebAssembly (runs anywhere; WebGPU used when an adapter exists) |
| Download | ~95 MB, cached after first load |
| License | Apache-2.0 (wav2vec2 base) |
| Web APIs | WebAssembly, Web Workers, Web Audio, MediaRecorder, Canvas β all Baseline widely available |
An honest caveat: emotion models learn from acted emotional speech. They pick up real acoustic cues (pitch, energy, tremor), but they are not a lie detector and real neutral speech can get surprising labels. Read the confidence bars, not just the top label β and treat this as a signal, not a verdict.
Pick a sample, drop an audio clip, or record yourself saying the same sentence in different tones, then hit Read emotion.
The model outputs a probability for every emotion class β a distribution, not a single answer. When the top two are close, the voice is ambiguous (or between emotions). Below are the raw class probabilities from your clip, and the waveform the network actually read (wav2vec2 works on the raw signal β there's no spectrogram in between).
| emotion | probability |
|---|
Tone carries meaning that transcripts throw away. Detecting it on-device means an app can react to how a user sounds without shipping their voice to a server β private by construction.
Read the emotion in a clip and see the full confidence distribution.
A call/feedback triage board β classify several clips and surface the ones that sound upset.
Emotion over time β slide a window across a clip and watch the feeling change.
Whisper transcript + voice emotion side by side: what was said vs how it sounded.
Classification is one call with Transformers.js. Feed a 16 kHz mono Float32Array:
import { pipeline } from "@huggingface/transformers";
const classify = await pipeline(
"audio-classification",
"onnx-community/wav2vec2-base-Speech_Emotion_Recognition-ONNX",
{ dtype: "q8" }, // downloads + caches ~95 MB once
);
const output = await classify(audio, { top_k: 6 });
// audio = Float32Array @ 16 kHz mono (decode with the Web Audio API)
// β [{ label: "ANGRY", score: 0.62 }, { label: "NEUTRAL", score: 0.15 }, β¦ ]
This page decodes files / mic recordings to 16 kHz mono with an OfflineAudioContext,
runs the pipeline inside a Web Worker so the UI never janks, and renders the full probability
distribution β not just the winner.