Spotify Vision is a project I created that allows users to control their Spotify Player using hand gestures. It leverages the Spotify API and computer vision technology. I trained an AI model using the Ultralytics YOLOv8 model to accurately recognize various hand gestures. These gestures include pausing and resuming a song, adding a song to a liked playlist, skipping a song, and closing the Spotify Player after use. In this article, I will provide instructions on how to successfully run the code. For a more detailed guide, visit my website.
To use the Spotify API, you must have a Spotify account with Spotify Premium, which is a subscription-based service. If you are a student, you can use your university email to get a discount. Once you have created a Spotify Premium account, we will need to get the Client ID and Client Secret in order to access the API with our Python code.
- Navigate to the Dashboard page on the Spotify for Developers site
- Click on the "Create App" button
- Provide a name and description for your app
- Set the "Redirect URIs" to http://localhost:8888/callback and http://localhost:8080 in the text field
- All the other fields can be left alone
- Check mark the agreement box
- Click the "Save" button
You will be automatically redirected to the Home page. Then, click on the "Settings" button located in the top right corner. This action will take you to the Basic Information page. On this page, please make sure to write down your Client ID. Additionally, you will need your Client Secret, so simply click on the "View client secret" link and take note of it.
In this section, we will set up the code to run the Spotify Vision project.
- Create a virtual Python environment using either venv or conda.
- Clone the project from GitHub.
- Install the required libraries using the following command: pip install -r requirements.txt.
- Open the spotifyvision.py file and replace the CLIENT_ID and CLIENT_SECRET with the ones you obtained from the Spotify API.
Before running the code, make sure to have your Spotify Player open (either on the desktop website or app).
- Run the code using the following command: python3 main.py.
- Select any available device shown in your list
- Select any available playlist shown in your list
After selecting a playlist, a song will start playing from it. The terminal will display the currently playing song.
The following hand gestures can be used to control the Spotify Player: