Speech Emotion Recognition
Upload a speech recording and a small stacked LSTM classifies it into one of six emotions: neutral, happy, sad, angry, fear or disgust. It started as a notebook experiment and was rebuilt into a tested, deployed Streamlit app.

01 / Problem
The original work lived in notebooks. Turning it into an app meant keeping the exact preprocessing the trained model expects, while splitting inference out so it can be tested and deployed on its own.
02 / How it works
- Upload a voice recording.
- Silence is trimmed and the clip is cut to a fixed length.
- Each short frame becomes numbers that describe the voice's energy and tone.
- An LSTM reads the frames in order and scores six emotions.
- The app shows the top emotion and the confidence for each.
03 / Tech & why
- Pydub + FFmpeg
- Decodes 7 formats (WAV, MP3, M4A, FLAC, OGG, AAC, AMR), trims silence and fixes the length at 180,000 samples, as the model expects.
- Librosa
- ZCR, RMS energy and 13 MFCCs for each of 352 frames: a 352 × 15 input that captures how something is said, not what.
- TensorFlow / Keras LSTM
- LSTM(64) → LSTM(64) → softmax over 6 emotions, 53,894 parameters, trained on RAVDESS, CREMA-D, TESS and SAVEE.
- Model contract checks
- Before predicting, the app checks input shape (352 × 15), output (6 classes) and label order, so a wrong checkpoint fails loudly.
- Pytest + Ruff + GitHub Actions
- Every push lints, tests upload validation, preprocessing, feature shapes and labels, loads the model and runs a test prediction.
04 / Results
- Live web app that classifies speech into six emotions.
- Inference separated from the notebook, with tests and CI on every push.
05 / Evaluation
0.94 is a historical score, not the live model's
Re-checking the old notebook, I found two class names swapped in the report, an early-stopping callback watching a metric that didn't exist, and a deployed checkpoint different from the one evaluated.
- Validation accuracy (notebook)
- 0.94 on 263 samples
- Macro F1 (notebook)
- ≈ 0.93
- Model size
- 53,894 parameters
- Training data
- 4 acted-speech datasets
06 / Limitations
An experiment, not an emotion detector
Trained on acted speech from female speakers only. Language, microphone and noise all change the result, and confidence scores are not calibrated. Not for medical, hiring or other high-stakes decisions.



