Downloads · 30 days
0
RayyanAhmed9477/speech-emotion-classification
speech-emotion-classification is a machine learning model from RayyanAhmed9477. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for tensorflow. The card lists the license as mit.
Downloads · 30 days
0
Access
Public
Updated Nov 3, 2025
Repo size
257 MB
Likes
1
Public
Click a slice to open those files.
.h5128 MB · 50%
From the Hugging Face model README
Detect emotions from speech using advanced deep learning models
</div>This repository contains a sophisticated deep learning model for speech emotion classification. The model is designed to detect and classify emotions from audio recordings with high accuracy using advanced neural network architectures. It combines acoustic features from both Mel-frequency cepstral coefficients (MFCCs) and mel-spectrograms to analyze emotional content in speech.
The model was trained on the RAVDESS (Ryerson Audio-Visual Database of Emotional Speech and Song) dataset, which contains high-quality recordings of professional actors expressing different emotions. The dataset includes 8 distinct emotions:
| Metric | Value |
|---|---|
| Test Accuracy | ~42.13% |
| Precision (weighted) | ~72.53% |
| Recall (weighted) | ~42.13% |
| F1-Score (weighted) | ~40.90% |
git clone https://github.com/your-username/speech_emotion_classification.git
cd speech_emotion_classification
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
Or install the dependencies manually:
pip install tensorflow numpy librosa scikit-learn huggingface_hub pandas matplotlib seaborn
import librosa
import numpy as np
from tensorflow import keras
# Load the pre-trained model
model = keras.models.load_model('./path/to/model.keras')
# Load an audio file
audio_path = 'path/to/audio.wav'
y, sr = librosa.load(audio_path, sr=None)
# Extract features
mfcc_features = librosa.feature.mfcc(y=y, sr=sr, n_mfcc=13)
spectrogram_features = librosa.feature.melspectrogram(y=y, sr=sr)
# Normalize and reshape features according to your preprocessing pipeline
# (Implementation depends on how the model was trained)
# Make prediction
# For multi-modal models, pass both feature arrays: [mfcc_features_reshaped, spec_features_reshaped]
predictions = model.predict([mfcc_features_reshaped, spec_features_reshaped])
# Get emotion with highest probability
emotion_labels = ['neutral', 'calm', 'happy', 'sad', 'angry', 'fearful', 'disgust', 'surprised']
predicted_emotion = emotion_labels[np.argmax(predictions)]
print(f"Predicted emotion: {predicted_emotion}")
python auto_train.py
python test_prediction_pipeline.py
streamlit run app.py
The model uses a sophisticated multi-modal architecture:
speech_emotion_classification/
├── app.py # Streamlit web application
├── auto_train.py # Automated training script
├── debug_labels.py # Label debugging utilities
├── driver.py # Main execution script
├── push_to_hub.py # Hugging Face model upload script
├── split_model.py # Model splitting utilities
├── test_*.py # Test files
├── requirements.txt # Project dependencies
├── README.md # This file
└── ...
To evaluate the model on custom audio files:
python test_prediction_pipeline.py
This will run the model on the test dataset and provide detailed performance metrics.
To ensure reproducible results:
import numpy as np
import tensorflow as tf
import random
np.random.seed(42)
tf.random.set_seed(42)
random.seed(42)
Contributions are welcome! Here's how you can contribute:
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)Please make sure to update tests as appropriate and follow the existing code style.
git clone https://github.com/Rayyan9477/speech_emotion_classification.git
cd speech_emotion_classification
pip install -r requirements.txt
pip install -r requirements-dev.txt # For development dependencies
This project is licensed under the MIT License - see the LICENSE file for details.
If you use this model in your research, please cite:
@software{speech_emotion_classification,
author = {AI Research Team},
title = {Speech Emotion Classification Model},
year = {2025},
url = {https://github.com/your-username/speech_emotion_classification}
}