A simple project for classifying speech emotion using audio features and machine learning.
- Extracts audio features (e.g., MFCC, chroma, spectral contrast)
- Trains and evaluates classifiers with Random Forest Classifier
- Inference pipeline for single-track emotion prediction
- Basic web app with Flask and Javascript with uploading/recording feature
Link to the dataset used: https://www.kaggle.com/datasets/uwrfkaggler/ravdess-emotional-speech-audio.
- Python>=3.10, <3.14
- librosa, numpy, pandas, scikit-learn, matplotlib, flask, etc. See requirements.txt for details.
- Set up virtual env:
# create
python -m venv /path/to/new/virtual/environment
# activate (for windows)
venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Run web app:
python -m web.app- Prepare audio dataset: create a directory containing subdirectories. Audio files need to in wav format and be put in the subdirectories. change folder path in
src/main.py. Example:
kaggle/actor_1 # put audio files inside /actor_1- Train and test model:
# Change directory:
cd src
# Run and visualize training result
python main.py-
Add commands for single audio emotion classification.
-
Improve web app user interface.
-
Denoise before processing audio.
-
Train more advanced models (e.g. CNN) on audio waveform/spectrograms
speech-emotion-classifier/
├── .gitignore
├── legacy/ # Legacy code
├── model/
│ └── emotion_classifier.pkl
├── README.md
├── requirements.txt
├── src/
│ ├── extract_features.py
│ ├── main.py
│ ├── README.md
│ ├── train_model.py
│ └── waveform_spectrogram.py
└── web/
├── app.py
├── classify.py
├── static/
│ ├── script.js
│ └── style.css
└── templates/
└── index.html