This project is a deep learning-based web application that detects user emotions in real-time and selects background music tailored to their mood. Using facial emotion recognition and music recommendations, it brings a personalized, interactive music experience to users. Ideal for improving focus, relaxation, and enjoyment based on the user's emotional state.
- Real-Time Emotion Detection: Uses a webcam to capture facial expressions, which are analyzed by a deep learning model.
- Music Recommendations: Suggests background music that aligns with the detected emotions.
- Seamless Integration: Automatically updates music suggestions based on changing emotions.
- Simple User Interface: Easy-to-use design that makes real-time feedback and control intuitive.
-
Frontend:
- React.js: For a dynamic, responsive UI to capture and display emotions in real time.
- JavaScript/HTML/CSS: Core web technologies for handling webcam input, interactions, and layout.
-
Backend:
- Flask/FastAPI: Serves as an API backend to handle emotion detection and music recommendation logic.
- TensorFlow/Keras: For building and running the emotion recognition model.
- Spotify API: Fetches playlists and songs based on mood tags, providing the music selection.
-
Data & Model:
- FER-2013 Dataset: Used for training the emotion detection model.
- Emotion Detection Model: A Convolutional Neural Network (CNN) trained on the FER-2013 dataset for classifying facial emotions.
- Python 3.7+
- Node.js & npm
- Spotify Developer Account
-
Clone the Repository:
git clone https://github.com/your-username/emotion-music-selector.git cd emotion-music-selector -
Backend Setup:
- Install Dependencies:
pip install -r requirements.txt
- Train/Load the Model:
- Either train the model using the FER-2013 dataset or load a pre-trained model.
- Place the model file in the
modelsdirectory.
- Install Dependencies:
-
Spotify API Setup:
- Register on Spotify Developer Dashboard and create an app to get your API keys.
- Create a
.envfile in the root directory with:SPOTIFY_CLIENT_ID=your_client_id SPOTIFY_CLIENT_SECRET=your_client_secret
-
Frontend Setup:
- Navigate to Frontend:
cd frontend - Install Dependencies:
npm install
- Run Frontend:
npm start
- Navigate to Frontend:
-
Start the Backend Server:
- Navigate back to the main directory and run:
python app.py
- Navigate back to the main directory and run:
-
Open in Browser:
- Go to
http://localhost:3000to interact with the application.
- Go to
- Access Webcam: Grant permission to access the webcam, which will capture facial expressions in real-time.
- Emotion Detection: The app detects your current emotion based on facial analysis and displays it.
- Music Selection: Depending on your mood, the app fetches a playlist from Spotify and begins playback.
| Emotion | Music Category |
|---|---|
| Happy | Upbeat, Pop, Dance |
| Sad | Acoustic, Slow |
| Angry | Heavy Rock |
| Neutral | Chill, Lo-Fi |
| Surprised | Random/Experimental |
- Additional Emotions: Support a wider range of emotions.
- Improved Model: Fine-tune the model with a larger, diverse dataset.
- Enhanced Music Mapping: Allow users to customize their music preferences for each emotion.
- Fork the repository.
- Create a new branch for your feature (
git checkout -b feature-branch). - Commit your changes (
git commit -m 'Add new feature'). - Push to the branch (
git push origin feature-branch). - Open a Pull Request.
This project is licensed under the MIT License.
- FER-2013 Dataset
- Spotify API
- Inspiration from various emotion-based music recommendation research papers