Work

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.

Role
Machine Learning Developer
Year
2024
Fields
AI / ML / Data / Optimization
Stack
  • Python
  • TensorFlow / Keras
  • LSTM
  • Librosa
  • Pydub
  • Streamlit
  • Pytest
  • GitHub Actions
The Voice Emotion Recognition app after analysing an uploaded recording: detected emotion Happy at 57.2% confidence
Upload, play back, analyse: the detected emotion and the model's confidence.

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

  1. Upload a voice recording.
  2. Silence is trimmed and the clip is cut to a fixed length.
  3. Each short frame becomes numbers that describe the voice's energy and tone.
  4. An LSTM reads the frames in order and scores six emotions.
  5. 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.

Start screen with an upload box for WAV, MP3, M4A, FLAC, OGG, AAC and AMR files
Start screen: seven audio formats, up to 15 MB.
Bar chart and table of confidence for all six emotions: Happy 57%, Angry 38%, the rest under 4%
Confidence for every emotion, as a chart and a detailed table.
The result on a phone: detected emotion, confidence bar and per-emotion chart
The result screen on mobile.
Detailed score table expanded on a phone, listing all six emotions by confidence
Detailed scores on mobile.

Faris Zaidan Nafis

Loading portfolio