Skip to content

Instructions to build a pi-based mobile device that can record, analyze and identify music on the go, similar to the famous "Shazam" app for smartphones.

Notifications You must be signed in to change notification settings

chriskalv/shazamPi_Zero

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 

Repository files navigation

shazamPi Zero

A mobile device to record, analyze and identify music on the go, similar to the famous "Shazam" app for smartphones.

It is supposed to be a gadget, which can be taken to places, where carrying a phone with you does not really make sense (like festivals, for example), but you still want to be able to identify tracks that are being played.

The code is entirely python-based and the device is fairly easy to build. There is not even any soldering required if you have the pre-soldered WH model of the Pi Zero.

Hardware



Close-up of the assembled device Red means recording
Finished device inside 3D-printed case & fanny pack Blue means ready



Functionality

  1. On booting up the device by switching on the power supply:

    • Power-saving measures are activated.
    • The shazampi.py script is started.
    • Once everything is operational, a blue LED on the ReSpeaker board lights up, signaling the device is 'ready to be used'.
  2. On pushing the button on the ReSpeaker board, the device checks for an internet connection.

    • If there is no internet connection (= the user is away from home):
      • An audio clip is recorded while a red LED illuminates (as seen on the picture above).
      • After recording, the new file is stored on the microSD card.
      • Once finished, the device reverts back to the 'ready to be used' status (blue LED).
    • If there is an internet connection (= the user is home):
      • All previously recorded clips are analyzed for artist and track name data, while green LEDs illuminate.
      • All analysis results are stored in a log file and sent via eMail.
      • All analyzed clips are moved to a seperate directory on the microSD card, so they won't be analyzed a second time.
      • Once finished, the devices reverts back to the 'ready to be used' status (blue LED).

Setup

  1. Flash Pi OS onto the microSD card (SSH enabled), assemble the hardware and make the device connect to your WiFi.
  2. sudo apt-get update && sudo apt-get upgrade -y
  3. Install Seeed ReSpeaker 2-Mics Pi HAT with these Instructions and manage settings:
    • Adjust the left/right input db gain to an appropriate level, depending on the desired usage environment (loud music = low/no db gain needed)
    • Restore your alsamixer configuration automatically after reboot. How this is done is described here.
  4. Install shazam library with these Instructions.
  5. Copy the shazampi.py file to your device (I used /var/shazampi/) and edit the script as well as your folder structure:
    • Create directories for new recordings, old recording and logs in your shazampi folder.
    • Edit global settings at the top of shazampi.py to your needs.
    • Make sure to edit permissions of your newly created files and folders, so the script can read, write and execute adequately without printing errors (sudo chmod 777 -R /<insertyourshazampifolderhere>/ will do).
  6. Copy the apa102.py library for the LED control of the ReSpeaker HAT into the same directory as your shazampi.py file.
  7. Reduce power consumption of your device with these Instructions:
    • Disable HDMI input/output
    • Disable bluetooth
    • Disable Pi board LED
    • Throttle CPU
  8. Make shazampi.py autostart on bootup. If you do not know how, take a look here.

Case

The 3D-printed case for this device, which was integrated into a fanny pack (as you can see on the pictures), was created by a friend of mine. As soon as he uploads the model to Thingiverse, I will link it here.

About

Instructions to build a pi-based mobile device that can record, analyze and identify music on the go, similar to the famous "Shazam" app for smartphones.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages