Capstone project for Electric Sheep Africa
---
title: MoodMix
emoji: 🎵
colorFrom: gray
colorTo: green
sdk: docker
app_port: 7860
---
# MoodMix
A mood-to-Spotify playlist generator that uses machine learning to detect emotion from speech or text input and creates a curated Spotify playlist based on the detected mood.
## Features
- **Speech Emotion Recognition** — Record your voice via microphone; a CNN analyzes mel-spectrogram features to classify emotion (96.4% accuracy)
- **Text Emotion Classification** — Type how you're feeling; a TF-IDF + Logistic Regression model classifies the sentiment (86.7% accuracy)
- **Spotify Integration** — Automatically creates a playlist with 10 tracks matching the detected mood using Spotify's search API
- **Streamlit UI** — Dark-themed interface with Font Awesome icons, mood-colored cards, and track previews
## Emotion Classes
| Emotion | Search Query | Description |
|---------|-------------|-------------|
| Happy | upbeat, feel-good | Upbeat and joyful |
| Sad | emotional, melancholy | Melancholic and reflective |
| Angry | intense, heavy | Intense and powerful |
| Calm | relaxing, peaceful | Peaceful and relaxed |
| Fearful | dark, tense, suspenseful | Tense and uneasy |
| Surprised | surprising, energetic | Bright and unexpected |
| Disgusted | dark, industrial | Harsh and abrasive |
## Project Structure
```
moodmix/
├── app.py # Streamlit entry point
├── requirements.txt # Dependencies
├── .env # Spotify API credentials (not tracked)
├── .gitignore
├── config/
│ └── mood_features.json # Mood-to-query mappings and icons
├── data/
│ ├── TESS/ # TESS audio dataset (not tracked, ~2800 WAVs)
│ ├── text_emotion/ # Text emotion dataset (train/test/val)
│ └── processed/ # Preprocessed numpy arrays (not tracked)
├── models/
│ ├── speech_mood_model.pth # Trained CNN weights (32 MB)
│ ├── text_mood_pipeline.pkl# Text model + vectorizer
│ └── text_history.pkl # Text train …