Model reference · open weights
wav2vec-english-speech-emotion-recognition is an open-weight audio or speech model from r-f. AxForge deploys and operates it for you on dedicated EU-owned hardware — with the licence handled where one is required.
Available as managed deployment — configured and operated for you on dedicated EU hardware, quoted per deployment.
What it is
| Maker | r-f |
|---|---|
| Type | Audio & music |
| Task | Speech→text |
| Runs with | transformers |
| Released | 2022-09-22 |
| Popularity | 2k downloads / month |
| Licence | Open weights |
About
The model is a fine-tuned version of jonatasgrosman/wav2vec2-large-xlsr-53-english for a Speech Emotion Recognition (SER) task.
Several datasets were used the fine-tune the original model:
7 labels/emotions were used as classification labels
emotions = ['angry' 'disgust' 'fear' 'happy' 'neutral' 'sad' 'surprise']
It achieves the following results on the evaluation set:
pip install transformers librosa torch
from transformers import *
import librosa
import torch
feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained("r-f/wav2vec-english-speech-emotion-recognition")
model = Wav2Vec2ForCTC.from_pretrained("r-f/wav2vec-english-speech-emotion-recognition")
def predict_emotion(audio_path):
audio, rate = librosa.load(audio_path, sr=16000)
inputs = feature_extractor(audio, sampling_rate=rate, return_tensors="pt", padding=True)
with torch.no_grad():
outputs = model(inputs.input_values)
predictions = torch.nn.functional.softmax(outputs.logits.mean(dim=1), dim=-1) # Average over sequence length
predicted_label = torch.argmax(predictions, dim=-1)
emotion = model.config.id2label[predicted_label.item()]
return emotion
emotion = predict_emotion("example_audio.wav")
print(f"Predicted emotion: {emotion}")
>> Predicted emotion: angry
The following hyperparameters were used during training:
| Step | Training Loss | Validation Loss | Accuracy |
|---|---|---|---|
| 500 | 1.8124 | 1.365212 | 0.486258 |
| 1000 | 0.8872 | 0.773145 | 0.79704 |
| 1500 | 0.7035 | 0.574954 | 0.852008 |
| 2000 | 0.6879 | 1.286738 | 0.775899 |
| 2500 | 0.6498 | 0.697455 | 0.832981 |
| 3000 | 0.5696 | 0.33724 | 0.892178 |
| 3500 | 0.4218 | 0.307072 | 0.911205 |
| 4000 | 0.3088 | 0.374443 | 0.930233 |
| 4500 | 0.2688 | 0.260444 | 0.936575 |
| 5000 | 0.2973 | 0.302985 | 0.92389 |
| 5500 | 0.1765 | 0.165439 | 0.961945 |
| 6000 | 0.1475 | 0.170199 | 0.961945 |
| 6500 | 0.1274 | 0.15531 | 0.966173 |
| 7000 | 0.0699 | 0.103882 | 0.976744 |
| 7500 | 0.083 | 0.104075 | 0.97463 |
From the published model card. Full card on the HuggingFace links in the sidebar.
Using it via the API
Once AxForge deploys wav2vec-english-speech-emotion-recognition for you, it answers on the OpenAI-compatible API — the same base URL and keys as every other model. (wav2vec-english-speech-emotion-recognition below is illustrative; you get the exact model name on deployment.)
$ curl -sS https://api.axforge.ai/v1/audio/transcriptions \ -H "Authorization: Bearer $AXFORGE_API_KEY" \ -F model="wav2vec-english-speech-emotion-recognition" -F file=@audio.mp3
Create an account — your API key is available in the console. 5M tokens/month currently included with every new account at launch.