The "pick-me-up" project introduces a Discord bot that creates personalized music playlists by blending users' preferred genres. To enhance the experience, the bot considers the users' current activities, such as studying or gaming. The back-end server implements a recommender system that analyzes users' genre preferences and interacts with the Spotify API to generate a customized playlist that aligns with their preferences and current context. Once the playlist is compiled, the bot utilizes the Google API to retrieve the YouTube URLs of the recommended tracks. These URLs are then sent back to the Discord bot, allowing them to be played in the voice channel.
- python3
- Docker and docker-compose (optional)
- npm
- Discord bot token
- API keys from Spotify and Google
-
Navigate to folder
bot
-
Add a
.env
file in thebot
folder containing: TOKEN="OBTAIN TOKEN FROM DISCORD DEVELOPER PORTAL" CLIENT_ID="OBTAIN CLIENT ID FROM DISCORD DEVELOPER PORTAL" -
Run
npm install
-
Run
npm start
-
Enter
/join
in the Discord server text channel
-
Create a python environment (one time instruction):
python3 -m venv env
-
Activate it using:
source env/bin/activate
orenv\Scripts\activate
-
Navigate to
backend
-
Install the requirements (one time instruction):
pip install -r requirements.txt
-
Run the migrations from the
backend/src
folder:python manage.py migrate
-
Add
env
file in thebackend
folder containing: YOUTUBE_API_KEY='OBTAIN KEY FROM YOUTUBE DATA API' SPOTIFY_CLIENT_ID='OBTAIN CLIENT ID FROM SPOTIFY DEVELOPER DASHBOARD' SPOTIFY_CLIENT_SECRET='OBTAIN CLIENT SECRET FROM SPOTIFY DEVELOPER DASHBOARD' -
Run the server from the
backend/src
folder:python manage.py runserver
The server runs on http://127.0.0.1:8000/ -
Run the unit tests from
backend/src
with:python manage.py test
- Alternatively, the server can run in a docker container with:
docker-compose up --build
.
├── .env
├── home
│ ├── __init__.py
│ ├── apps.py
│ ├── recommender.py
│ ├── test
│ │ ├── __init__.py
│ │ └── tests.py
│ ├── urls.py
│ └── views.py
├── manage.py
├── pickmeup
│ ├── __init__.py
│ ├── asgi.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── static
└── websocket
├── __init__.py
├── echo.py
├── routing.py
└── test
├── __init__.py
└── tests.py
The back-end server is implemented with the Django
framework and follow the corresponding files structure. The pickmeup
folder contains files related to the the server settings and configuration, while the home
and websocket
folders contain Django
apps.
The websocket
app was created to receive a live audio streams from the Discord app. However, due to changes in our user study design, there was no longer a need for the audio stream. Initially, this would have been used to apply ML on the steam data to recommend music based on identified emotions.
The home
app hosts the code of your recommender in recommender.py
, while url.py
and views.py
contain the code for the API endpoints and request handling.
Lastly, the .env
file contains the YOUTUBE_API_KEY
, SPOTIFY_CLIENT_ID
, SPOTIFY_CLIENT_SECRET
needed to query the Youtube and Spotify APIs in order to create a new playlist recommendation.