Python script that listens by microphone what you play, obtains track details from Shazam, displays fullscreen album art, scrobbles to last.fm and sets color of lamps connected to Home Assistant.
HTML page is optimized only for 1920x1080 resolution. If you want to use it on other display then change songhtml1.html
- download all files to home directory
- install all necessary libraries in #includes
- get last.fm API key and secret and fill it into py code
- get authorization key from Home Assistant and codes of entities you want to control and insert it to code
- allow listen-loop.sh to run: sudo chmod +x listen-loop.sh
- install chromium and get proper location by whereis chromium and modify py script if necessary
You may need to adjust line with arecord. Either parameter with correct device may be needed by adding -d "hw:0,0" or similar, or you may need to set microphone as default recording device, or you may need to adjust recording rate in parameter -r. Please do not ask about it, I cannot support. It took me lot of experimenting to get it working for my particular configuration.
Run script as python3 ./listen-show-scrobble-setlamps.py
the script is not failproof, it may end with error if no image is provided by shazam, therefore it is better to run it in loop by ./listen-loop.sh