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 β¦