This project is an application that detects a user's emotions from their facial expressions and recommends music based on their expression. The system processes webcam images to identify emotions and uses Spotify's API to play songs that match the detected emotion.
Oluwapelumi Adesiyan
Polina Belova
Gabriella Codrington
Maya Mabry
This system consists of three interconnected components:
- Machine Learning Client - Captures webcam images, detects facial emotions using DeepFace, and requests matching songs from Spotify's API.
- Web Application - A Flask-based frontend that lets users capture images, trigger emotion detection, and view their emotion history with recommended songs.
- MongoDB Database - Stores emotion detection history and song recommendations for user tracking and review.
Ensure the following tools are installed:
- Python 3.11+
- MongoDB
- Spotify Developer Account (for API access)
- Docker and Docker Compose
.
├── web-app/ # Flask frontend
│ ├── app.py # Main web app logic
│ ├── auth.py # User authentication
│ ├── requirements.txt
│ ├── templates/ # HTML templates
│ ├── Dockerfile
│ └── static/ # CSS and JavaScript
├── machine-learning/ # Emotion detection service
│ ├── face_recog.py # Facial emotion detection
│ ├── get_playlist.py # Spotify API integration
│ └── requirements.txt
│ ├── Dockerfile
└── README.md # You are here
└── docker-compose.yml
Create a .env
file in your project root folder with the following variables:
CLIENT_ID=your_client_ID
CLIENT_SECRET=your_client_secret
MONGO_URI=mongodb+srv://username:password@cluster.example.mongodb.net/?retryWrites=true&w=majority
SECRET_KEY=your_secret_key
Visit Emotify, deployed using DigitalOcean, at http://165.22.180.89:5001/.
-
Clone the repository:
git clone https://github.com/software-students-spring2025/5-final-five-timers-club.git cd 5-final-five-timers-club
-
Create environment variables file:
cp .env.example .env
-
Edit the
.env
file with your development configuration. -
Build and start the containers using Docker Compose:
docker-compose up -d --build
-
The application will be running at http://127.0.0.1:5001
-
To stop the containers:
docker-compose down
Make sure to install pytest
pip install pytest
cd web-app
pytest tests
cd machine-learning
pytest tests
- User Authentication - Register and login to track your history
- Facial Emotion Detection - Detects emotions from webcam images (happy, sad, angry, fearful, surprised, disgusted, neutral)
- Music Recommendations - Suggests songs from Spotify based on your detected emotion
- History - Review your past detected emotions and recommended songs
- Flask - Python web framework
- DeepFace - Deep learning facial recognition and emotion detection
- Spotify Web API - Music recommendation engine
- MongoDB - Database for emotion and song history
- Flask-Login - User authentication system
- OpenCV - Image processing