Views
No views yet
facebook/wav2vec2-base-960h fine-tuned for 8-class speech emotion recognition on
RAVDESS.angry, calm, disgust, fearful, happy, neutral, sad, surprised1import torch
2from transformers import Wav2Vec2ForSequenceClassification, Wav2Vec2FeatureExtractor
3
4MODEL_ID = "sbh013/wav2vec2-ser-ravdess-optimized"
5feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained(MODEL_ID)
6model = Wav2Vec2ForSequenceClassification.from_pretrained(MODEL_ID)
7model.eval()
8
9import librosa
10waveform, _ = librosa.load("speech.wav", sr=16000, mono=True)
11inputs = feature_extractor(waveform, sampling_rate=16000, return_tensors="pt", padding=True)
12
13with torch.no_grad():
14 probs = torch.softmax(model(**inputs).logits, dim=-1).squeeze().numpy()
15
16id2label = model.config.id2label
17print({id2label[i]: float(probs[i]) for i in range(len(probs))})| Setting | Value |
|---|---|
| Backbone | facebook/wav2vec2-base-960h |
| CNN feature encoder | Frozen |
| Epochs | 25 |
| LR (encoder / head) | 2e-5 / 5e-5 |
| Batch size | 8, grad accumulation 2 (effective 16) |
| LR schedule | Cosine, 6% warmup |
| Class weights | Inverse frequency, extra boost on sad/angry |
| Augmentation | Noise, gain, small time shift (70% of training batches) |
| Precision | fp32 |
| Split | Speaker-independent — 19 train / 2 val / 3 test actors |
| Emotion | Precision | Recall | F1 |
|---|---|---|---|
| angry | 0.917 | 0.458 | 0.611 |
| calm | 0.810 | 0.708 | 0.756 |
| disgust | 0.947 | 0.750 | 0.837 |
| fearful | 0.679 | 0.792 | 0.731 |
| happy | 0.500 | 0.833 | 0.625 |
| neutral | 0.588 | 0.833 | 0.690 |
| sad | 0.500 | 0.292 | 0.368 |
| surprised | 0.724 | 0.875 | 0.793 |
sad is the weakest class, frequently confused with fearful and neutral.