Recognize a person’s emotion from his/her speech.
Voice often reflects underlying emotion through tone and pitch. By converting audio signals to numerical values, we can extract features from the sound file and annotate as necessary. Using a supervised learning approach, we can train classifiers to learn and detect emotions.
For this project we will use a modified (reduced sample rate) version of Ryerson Audio-Visual Database of Emotional Speech and Song (RAVDESS) dataset, which can be downloaded from here. This dataset has 7356 files rated by 247 individuals 10 times on emotional validity, intensity, and genuineness.
We will use librosa 0.8.0, which is a Python library for analyzing audio and music as well as pysoundfile -0.10.2 library.
Steps:
- Load required libraries
- Define a function for features extraction from audio files
- Define a dictionary for emotions
- Define a function to create a dataset by loading audio files and extracting features from those files.
- Load, create and split dataset
- Initialize feedforward ANN model: Multi-layer Perceptron classifier
- Train and test the model
- Measure performance
- Future improvement: Parameter optimization, Different classifier (XGB)
Accuracy
Python 3.8, (Jupyter Notebook), pandas-1.1.1, numpy-1.19.1, scipy-1.5.2, scikit-learn-0.23.2, matplotlib-3.3.1, librosa 0.8.0, pysoundfile -0.10.2
We have reproduced the code for educational and learning purposes only. Original article can be found here.