Welcome to the Emo-Music app! This app detects your mood based on the text you enter and recommends music accordingly. This Streamlit web application recommends YouTube music videos based on the user's input emotions. It leverages natural language processing (NLP) to detect emotions from text input and utilizes the YouTube Data API to fetch and display relevant music videos. Users can select their preferred language for recommendations and sort the suggested songs based on criteria like relevance, view count, rating, or date.
- Mood Detection: Enter your feelings or describe your day, and the app detects your emotions.
- Language Preference: Choose your preferred language for music recommendations.
- Emotion-based Music: Get song recommendations that match your current mood or help uplift your spirits.
- Interactive UI: Select and play recommended YouTube videos directly within the app.
- Streamlit: Framework for building interactive web applications with Python.
- Google Cloud Platform: Utilizes the YouTube Data API to fetch video recommendations.
- Transformers Library (Hugging Face): Uses pre-trained models for emotion detection in text inputs.
- Enter Your Mood: In the text box, type how you are feeling today.
- Select Language (Optional): Enter your preferred language for the song recommendations (or I am feeling lucky).
- Get Recommendations: Click the "Get Recommendations" button to see song recommendations based on your detected emotion.
- Choose Your Music: If you are feeling sad, you can choose between "Sad songs" or "Joyful/uplifting songs" from the dropdown menu.
- Play Music: Select a video from the recommendations and play it directly within the app.
Use the "Refresh" button in the sidebar to reset all recommendations and clear the current state, allowing you to start fresh.
This guide will help you set up and use the YouTube Data API to fetch YouTube video recommendations based on your queries.
-
Create a Google Cloud Project:
- Go to the Google Cloud Console.
- Click on the Select a project dropdown at the top of the page.
- Click New Project and fill in the required details.
- Click Create.
-
Enable YouTube Data API v3:
- In the Google Cloud Console, select your project.
- Navigate to APIs & Services > Library.
- Search for YouTube Data API v3 and click on it.
- Click Enable.
By following these steps, you should be able to set up and use the YouTube Data API to get video recommendations based on user input in your Streamlit app.
-
Create API Key:
- Go to APIs & Services > Credentials.
- Click Create Credentials and select API key.
- Your new API key will be created and displayed. Copy this key for use in your application.
-
Restrict API Key (Optional but recommended):
- In the Credentials page, click on the edit icon next to your API key.
- Under Key restrictions, select HTTP referrers (web sites).
- Add the URLs that will use this API key.
- Save your changes.
To interact with the YouTube Data API using Python, install the necessary libraries.
pip install google-api-python-client
## Installation
To run the app locally, follow these steps:
1. Clone the repository:
```bash
git clone https://github.com/yourusername/emotion-based-music-recommendations.git
- Navigate to the app directory:
cd emotion-based-music-recommendations
- Install the required dependencies:
pip install -r requirements.txt
- Run the app:
streamlit run front.py