Tested on:RPi3; Google AIY voice HAT v1
Hardware:Google AIY voice HAT and a MAX 98357A DAC
Ghettoblaster, tools
RPi3 with peripherals
0

A voice-controlled boombox with the Google AIY voice HAT


Thanks to a broken boombox i got from a friend, i could build a prototype for an intelligent, portable music player. The prototype is based on a Raspberry Pi 3 and the Google AIY voice HAT. The device requires an internet connection for accessing youtube with the comfortable MPS-Youtube, a terminal based youtube music player. While Google AIY voice has no problem accessing songs with english titles, titles in other languages or fantasy names work badly.
Thanks to mikerr for the code example on the RaspberryPi.org forums!

Assembly
First, the Google AIY voice HAT needs to be extended for stereo audio output, see tutorial Google AIY voice HAT with stereo audio. Then, i used a Dremel to cut out space for the RPi and the HAT:

Ghettoblaster Teile

Ghettoblaster Teile

Note the foam pads on the speakers for protecting the Raspberry Pi against vibrations. The prototype needs to be handled with care:
Ghettoblaster Prototyp

Ghettoblaster Prototyp

Installation
Follow the AIY voice installation instructions from Google. Then, enter in the terminal

and replace the line

with

Now, perform these operations:

To run aiy_music_player.py, assistant.json needs to be in /home/pi as shown in the Google installation instructions.

Run the boombox
Start the intelligent boombox by entering

Open the activation link shown in the terminal in a browser, then enter the activation code from the website in the terminal. Now, say Ok Google, then play Bob Marley to start a tune. For stopping the song, say Ok Google, then stop.
For using the boombox outside, aiy_music_player.py needs to be started automatically, for example with an entry in .bashrc. Additionally, a smartphone with a Wireless Access Point (WAP) is required, which needs to be configured in wpa_supplicant.conf.

Code explained
The function process_event processes voice commands. The voice command play executes the function play, which first extracts the track to search for on Youtube and then passes it to a mpsyt terminal process:

ToDo

  • add LiIon batteries
  • voice commands for next and previous song
  • physical buttons for on/off, volume up/down ect.
  • Smartphone audio streaming
  • accessing local Youtube playlists
  • other languages?
  • level audio volume

Full script
Click on Full Script to show all of the code.

Links
Google AIY voice installation: https://aiyprojects.withgoogle.com/voice/
GitHub MPS-Youtube: https://github.com/mps-youtube/mps-youtube
Tutorial Google AIY voice HAT with stereo audio: http://www.knight-of-pi.org/raspberry-pi-and-google-aiy-voice-hat-stereo-audio-with-the-max-98357a-dac/
mikerr post in the RaspberryPi forum: https://www.raspberrypi.org/forums/viewtopic.php?f=114&t=182665

Knight of Pi

Johannes Bergs aka Knight of Pi. Diploma in Bioinformatics, some Webdesign and Python coding then. Living in the beautiful city of Vienna.

Comment

Time limit is exhausted. Please reload CAPTCHA.