PyShazam is a Python script that uses the Shazam API to capture audio from a microphone, identify the song being played, and display its album art cover. The script runs on Raspberry Pi or macOS devices.
- Python 3.7 or above
pyaudio
library for audio capturingwave
library for working with WAV audio filesshazamio
library for interacting with the Shazam APIPillow
library for displaying album art imagespydub
library for audio file handlingtime
library for managing delaysurllib
library for opening URLsos
library for file operations
-
Install Python 3: Visit the official Python website (https://www.python.org) and follow the instructions to download and install Python 3 for your operating system.
-
Install the required libraries: Open a terminal or command prompt and run the following command to install the necessary libraries:
pip install pyaudio wave shazamio Pillow pydub
-
Make sure you have a working microphone connected to your Raspberry Pi or macOS device.
-
Run the
pyshazam.py
script using Python:
python pyshazam.py
-
The script will start capturing audio from the microphone for 10 seconds at a time.
-
After each audio capture, the script will send the audio data to the Shazam API for song identification.
-
If a match is found, the script will display the album art cover of the identified song.
-
The script will wait for 10 seconds before capturing audio again.
-
To stop the script, press
Ctrl + C
in the terminal or command prompt.
-
You can adjust the duration of each audio capture by modifying the
capture_audio
function in the script. -
Additional customization options can be explored by referring to the documentation of the used libraries:
-
shazamio
: https://github.com/fr31/shazamio
This script is licensed under the MIT License.