Downloads · 30 days
16
3% of all-time downloads
vishrutjha/pph-emotion-classification-model
pph-emotion-classification-model is a audio classification model from vishrutjha. Use it for the audio classification task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as mit.
This model performs audio emotion classification while simultaneously predicting continuous arousal and valence values. It combines multiple audio features (Wav2Vec2, MFCC, and prosodic features) to achieve robust emo…
Downloads · 30 days
16
3% of all-time downloads
All-time downloads
537
Public
Parameters
2.9M
11.8 MB on disk
Likes
2
Public
Click a slice to open those files.
.safetensors11.8 MB · 99%
From the Hugging Face model README
This model performs audio emotion classification while simultaneously predicting continuous arousal and valence values. It combines multiple audio features (Wav2Vec2, MFCC, and prosodic features) to achieve robust emotion recognition.
from pipeline_emotion_av import pipeline
# Create pipeline
emotion_pipeline = pipeline(
"audio-emotion-classification",
model="pricklypearhealth/emotion-av-model"
)
# Process audio
result = emotion_pipeline("path/to/audio.wav", return_all_scores=True)
print(result)
from modeling_emotion_av import EmotionAVModel
from feature_extraction_emotion_av import EmotionAVFeatureExtractor
# Load model and feature extractor
model = EmotionAVModel.from_pretrained("pricklypearhealth/emotion-av-model")
feature_extractor = EmotionAVFeatureExtractor.from_pretrained("pricklypearhealth/emotion-av-model")
# Process audio file
features = feature_extractor.from_file("path/to/audio.wav", return_tensors="pt")
result = model.predict_emotion(features["input_features"])
print(f"Emotion: {result['emotion']}")
print(f"Confidence: {result['confidence']:.4f}")
print(f"Arousal: {result['arousal']:.4f}")
print(f"Valence: {result['valence']:.4f}")
Input Audio (16kHz)
↓
Feature Extraction:
├── Wav2Vec2 (768 features)
├── MFCC (13 features)
└── Prosodic (6 features)
↓
Combined Features (787 dims)
↓
Dual Branch Network:
├── Emotion Branch → 6-class Classification
└── AV Branch → 2D Regression (Arousal, Valence)
This model supports the Hugging Face Inference API. You can use it directly:
import requests
import base64
# Encode audio file
with open("audio.wav", "rb") as f:
audio_bytes = f.read()
audio_b64 = base64.b64encode(audio_bytes).decode()
# Make API request
response = requests.post(
"https://api-inference.huggingface.co/models/pricklypearhealth/emotion-av-model",
headers={"Authorization": "Bearer YOUR_HF_TOKEN"},
json={"inputs": audio_b64}
)
result = response.json()
print(result)
[
{
"label": "happy",
"score": 0.8542,
"arousal": 0.7234,
"valence": 0.9123,
"all_scores": [
{ "label": "happy", "score": 0.8542 },
{ "label": "neutral", "score": 0.0892 },
{ "label": "sad", "score": 0.0456 }
]
}
]
For production use, you can deploy this model on Hugging Face Inference Endpoints:
import requests
import base64
# Encode audio file
with open("audio.wav", "rb") as f:
audio_bytes = f.read()
audio_b64 = base64.b64encode(audio_bytes).decode()
# Make request to your Inference Endpoint
response = requests.post(
"https://YOUR_ENDPOINT_URL.endpoints.huggingface.cloud",
headers={
"Authorization": "Bearer YOUR_HF_TOKEN",
"Content-Type": "application/json",
},
json={
"inputs": audio_b64,
"parameters": {
"return_all_scores": True,
"sampling_rate": 16000
}
}
)
result = response.json()
print(result)
If you use this model, please cite:
@misc{emotion-av-model,
title={Audio Emotion Classification with Arousal-Valence Prediction},
author={Your Name},
year={2024},
url={https://huggingface.co/pricklypearhealth/emotion-av-model}
}