{"id":23662884,"url":"https://github.com/lahi-ru/emotion_based_music_player","last_synced_at":"2025-10-26T02:39:51.059Z","repository":{"id":262863390,"uuid":"888595520","full_name":"LAHI-RU/Emotion_Based_Music_Player","owner":"LAHI-RU","description":"A web-based music player that selects songs based on the user’s detected emotion using AI-powered emotion recognition.","archived":false,"fork":false,"pushed_at":"2025-05-06T18:49:28.000Z","size":22,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-20T18:58:26.277Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LAHI-RU.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-11-14T17:06:35.000Z","updated_at":"2025-05-06T18:49:32.000Z","dependencies_parsed_at":"2025-05-20T18:51:55.133Z","dependency_job_id":null,"html_url":"https://github.com/LAHI-RU/Emotion_Based_Music_Player","commit_stats":null,"previous_names":["lahi-ru/emotion_based_music_player"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LAHI-RU/Emotion_Based_Music_Player","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LAHI-RU%2FEmotion_Based_Music_Player","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LAHI-RU%2FEmotion_Based_Music_Player/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LAHI-RU%2FEmotion_Based_Music_Player/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LAHI-RU%2FEmotion_Based_Music_Player/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LAHI-RU","download_url":"https://codeload.github.com/LAHI-RU/Emotion_Based_Music_Player/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LAHI-RU%2FEmotion_Based_Music_Player/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270385016,"owners_count":24574537,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-14T02:00:10.309Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-29T05:15:16.374Z","updated_at":"2025-10-26T02:39:46.026Z","avatar_url":"https://github.com/LAHI-RU.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🎵 Emotion-Based Music Player\n\nA machine learning application that detects emotions from facial expressions and plays music matching your mood using the Spotify API.\n\n![Emotion Music Player Demo](https://media.giphy.com/media/placeholder/giphy.gif)\n\n## ✨ Features\n\n- **Real-time Emotion Detection**: Uses computer vision to analyze facial expressions via webcam\n- **Music Recommendation Engine**: Selects music that matches your current emotional state\n- **Spotify Integration**: Plays tracks directly on your Spotify account\n- **Responsive Web Interface**: Clean, intuitive design that updates in real-time\n\n## 🧠 Emotions Detected\n\n- 😠 Angry\n- 🤢 Disgust\n- 😨 Fear\n- 😊 Happy\n- 😢 Sad\n- 😲 Surprise\n- 😐 Neutral\n\n## 🚀 Installation\n\n### Prerequisites\n\n- Python 3.8+\n- Webcam\n- Spotify account (Free or Premium)\n- Spotify Developer account with registered application\n\n### Step 1: Clone the repository\n\n```bash\ngit clone https://github.com/yourusername/emotion-based-music-player.git\ncd emotion-based-music-player\n```\n\n### Step 2: Set up a virtual environment\n\n```bash\npython -m venv venv\n```\n\nActivate the virtual environment:\n\n**Windows**\n```bash\nvenv\\Scripts\\activate\n```\n\n**macOS/Linux**\n```bash\nsource venv/bin/activate\n```\n\n### Step 3: Install dependencies\n\n```bash\npip install -r requirements.txt\n```\n\n### Step 4: Configure Spotify API credentials\n\n1. Create a Spotify Developer account at [developer.spotify.com](https://developer.spotify.com/)\n2. Create a new application in the Spotify Developer Dashboard\n3. Set the Redirect URI to `http://127.0.0.1:8000/callback`\n4. Note your Client ID and Client Secret\n5. Create a `config.py` file in the project root:\n\n```python\n# Spotify API credentials\nSPOTIFY_CLIENT_ID = \"your-client-id-here\"\nSPOTIFY_CLIENT_SECRET = \"your-client-secret-here\"\nSPOTIFY_REDIRECT_URI = \"http://127.0.0.1:8000/callback\"\n\n# Emotion detection settings\nEMOTION_DETECTION_INTERVAL = 5  # Detect emotion every 5 seconds\nCAMERA_INDEX = 0  # Default camera (usually the webcam)\n\n# Flask app settings\nDEBUG = True\nPORT = 8000\n```\n\n### Step 5: Create default album art\n\nRun the following script to create a default album art image:\n\n```bash\npython generate_default_album.py\n```\n\n## 📊 Usage\n\n1. Start the application:\n```bash\npython app.py\n```\n\n2. Open your browser and go to:\n```\nhttp://127.0.0.1:8000\n```\n\n3. Click \"Start Detection\" to enable the webcam and begin emotion detection\n4. Open the Spotify application on your device (to act as a playback device)\n5. The system will detect your emotion and play appropriate music automatically\n\n## 🔧 How It Works\n\n1. **Emotion Detection**: The application uses OpenCV for face detection and DeepFace for emotion classification.\n2. **Music Selection**: Based on detected emotions, the application:\n   - First attempts to find matching songs from your personal playlists\n   - Falls back to your liked songs library if no playlist matches\n   - Uses Spotify's recommendation API as a final fallback\n3. **Playback**: The selected track is played on your active Spotify device\n\n## 🧩 Project Structure\n\n```\nemotion-music-player/\n├── app.py                # Main application file\n├── emotion_detector.py   # Emotion detection module\n├── music_player.py       # Music recommendation and playback\n├── config.py             # Configuration settings\n├── requirements.txt      # Dependencies\n├── static/               # Static files for web interface\n│   ├── css/              # Stylesheets\n│   ├── js/               # JavaScript files\n│   └── img/              # Images\n└── templates/            # HTML templates\n    └── index.html        # Main interface\n```\n\n## 🛠️ Customization\n\n### Emotion-Music Mapping\n\nEdit the `emotion_features` and `emotion_genres` dictionaries in `music_player.py` to customize the audio features and genres associated with each emotion.\n\n### Interface\n\nModify the CSS in `static/css/style.css` to change the appearance of the web interface.\n\n## 🤝 Contributing\n\nContributions are welcome! Here's how you can contribute:\n\n1. Fork the repository\n2. Create a feature branch: `git checkout -b feature-name`\n3. Commit your changes: `git commit -m 'Add some feature'`\n4. Push to the branch: `git push origin feature-name`\n5. Submit a pull request\n\n## 📝 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## 🙏 Acknowledgements\n\n- [DeepFace](https://github.com/serengil/deepface) for facial emotion recognition\n- [Spotipy](https://github.com/plamere/spotipy) for Spotify API integration\n- [Flask](https://flask.palletsprojects.com/) for the web framework\n- [OpenCV](https://opencv.org/) for computer vision capabilities\n\n## 📧 Contact\n\nFor questions or feedback, please contact:\n- Your Name - [Lahiru Bandara](mailto:lahiiru.dananjaya@gmail.com)\n- Project Link: [https://github.com/LAHI-RU/emotion-based-music-player](https://github.com/LAHI-RU/emotion-based-music-player)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flahi-ru%2Femotion_based_music_player","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flahi-ru%2Femotion_based_music_player","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flahi-ru%2Femotion_based_music_player/lists"}