Music recommendation system based on emotion analysis using AI.
- Sentiment Analysis: Detects emotions in text using Hugging Face models
- Smart Recommendations: Suggests Spotify music based on your mood
- Modern Interface: Frontend built with React + TypeScript + Vite
- Python 3.8+
- Node.js 16+
- Spotify Developer Account
- Hugging Face Token
- Go to Spotify Developer Dashboard
- Create an application
- Copy your
Client IDandClient Secret
- Go to Hugging Face Settings
- Generate a new access token
Create a .env file in the backend/ folder:
cd backend
cp .env.example .envEdit the .env file with your real credentials:
SPOTIFY_CLIENT_ID=your_real_client_id
SPOTIFY_CLIENT_SECRET=your_real_client_secret
HF_API_TOKEN=your_real_hf_token.env file to Git. It's already included in .gitignore.
cd backend
# Create virtual environment
python -m venv venv
# Activate virtual environment
# Windows:
venv\Scripts\activate
# Linux/Mac:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Run server
uvicorn src.main:app --reloadThe backend will be available at: http://localhost:8000
cd frontend
# Install dependencies
npm install
# Run in development mode
npm run devThe frontend will be available at: http://localhost:5173
The emotion detection system is powered by a K-Means clustering analysis of 14,306 songs from the FMA dataset. The complete development process is documented in:
- Notebook:
notebooks/Rithma_song_rec_sys_ml_train.ipynb - Documentation: notebooks/README.md
- 7 distinct sonic clusters identified using K-Means
- Emotion-to-audio-feature mapping created
- Dynamic rules system for Spotify API recommendations
Want to understand how it all works? Read the LEARN.md guide!
This project follows security best practices:
- Credentials in environment variables (
.env) .envincluded in.gitignore.env.exampleas template without sensitive data- CORS configured for specific origins
- No secrets exposed in code
-
Verify that
.envis NOT in Git:git status # You should NOT see .env in the list -
If you accidentally uploaded credentials:
- Regenerate ALL credentials immediately
- Use
git filter-branchor BFG Repo-Cleaner to clean the history
- Start the backend
- Start the frontend
- Write how you feel (e.g., "I'm feeling very happy today")
- Receive a personalized music recommendation
Contributions are welcome. Please:
- Fork the project
- Create a branch for your feature (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is open source and available under the MIT License.
This project uses third-party APIs (Spotify and Hugging Face). Make sure to comply with their terms of service.