Skip to content

Facial emotion detection system that recommends personalized music via MusicGen and Spotify API integration.

Notifications You must be signed in to change notification settings

Janvi-M/Mood-Melody

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

12 Commits
ย 
ย 
ย 
ย 

Repository files navigation

MoodMelody: Emotion-Driven Music Tool ๐ŸŽต ๐ŸŽญ

MoodMelody uses AI to analyze your emotional state through your webcam and provides music recommendations or generates custom music to match or improve your mood.

๐ŸŒŸ Features

  • Emotion Detection: Analyzes your facial expressions to detect your current emotion using DeepFace
  • Spotify Integration: Recommends songs from Spotify based on your detected emotion
    • Search by artist
    • Filter by language preference
    • Option to "shift your mood" to more positive emotions
  • AI Music Generation: Creates custom music compositions that dynamically transition through emotional states
    • Uses Facebook's MusicGen model to generate unique music pieces
    • Creates a musical journey from your current emotion to a more positive state
  • Music Visualization: View waveform or spectrogram visualizations of your generated music
  • Download Support: Save your AI-generated music for later use

๐Ÿ“‹ Requirements

This application requires the following Python packages:

  • streamlit
  • opencv-python
  • pillow
  • numpy
  • torch
  • torchaudio
  • soundfile
  • colorama
  • spotipy
  • deepface
  • transformers
  • pandas

๐Ÿš€ Setup and Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/mood-melody.git
    cd mood-melody
    
  2. Install dependencies:

    pip install streamlit opencv-python pillow numpy torch torchaudio soundfile colorama spotipy deepface transformers pandas
    
  3. Add your Spotify API credentials:

  4. Run the application:

    streamlit run mood-melody.py
    

๐Ÿ’ป Usage

  1. Launch the application
  2. Click "Detect Emotion" to take a photo using your webcam
  3. Choose between "Get Spotify Recommendations" or "Generate Custom Music"
  4. For Spotify recommendations:
    • Optionally select "Shift my mood" to get more uplifting music
    • Enter an artist name if you have a preference
    • Choose a language if desired
  5. For custom music generation:
    • Click "Generate Music" to create a unique composition
    • The app will show progress as it creates each segment
    • Visualize the audio with waveform or spectrogram options
    • Download your music when complete

๐Ÿง  How It Works

Emotion Detection

The app uses DeepFace to analyze facial expressions and determine your dominant emotion from categories like happy, sad, angry, etc.

Music Recommendation

The app maps emotions to musical qualities and searches Spotify for matching songs. If you choose to "shift your mood," it will recommend music with more positive emotional qualities.

Music Generation

  1. Creates a dynamic path of emotions starting from your detected state
  2. Gradually transitions toward more positive emotional states
  3. Generates musical segments for each emotion using MusicGen
  4. Combines segments into a cohesive musical journey
  5. Provides visualization tools to see the audio structure

๐Ÿ”ฎ Future Enhancements

  • Improved emotional analysis with multiple frames for better accuracy
  • Genre preferences for music recommendations
  • Social sharing options
  • Custom emotion transition paths
  • Voice mood detection option

๐Ÿ‘ Acknowledgements

About

Facial emotion detection system that recommends personalized music via MusicGen and Spotify API integration.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages