Project Overview
This project is a smart music player powered by a Raspberry Pi 4B 8GB that detects a user's facial expression and plays music that matches their mood. It combines computer vision, machine learning, and Python to create an interactive, personalized music experience.
Features
- Real-Time Mood Detection: Analyzes facial expressions to determine emotions such as happiness, sadness, and surprise.
- Automated Music Recommendation: Plays mood-aligned music from a predefined playlist.
- Raspberry Pi Powered: Designed for smooth operation on a Raspberry Pi, ensuring portability and efficiency.
- Customizable Playlists: Easily modify playlists and mood-matching logic.
How It Works
- Face Detection & Emotion Analysis: Utilizes OpenCV and MediaPipe for accurate facial landmark detection.
- Mood Classification: Maps detected emotions to mood categories (Happy, Sad, Surprised), with neutral as the default.
- Music Playback: Plays a suitable playlist using a Python-based audio player.
Course Corrections
The first design leaned on a single music source, and real use exposed the flaw: playback APIs restrict,
throttle, or drop streams depending on platform and session state, so the player would pass a demo and fail
in a living room. The architecture changed direction: playback was re-routed behind a backend abstraction
that resolves the best available stream at runtime: browser-resolved streams, yt-dlp, and local libraries,
with cross-platform audio fallbacks and session telemetry to surface silent failures. The lesson stuck:
the fallback path is a first-class feature, not an afterthought.
Technologies Used
- Python: Core scripting language.
- OpenCV: For face detection and image processing.
- TensorFlow/Keras: Pre-trained models for emotion recognition.
- MediaPipe: Provides efficient facial landmark detection.
- Raspberry Pi 4B 8GB: Hardware platform ensuring portability and performance.