Fun with the AIY Kit

4 min read

Have you ever wanted to make your own Google Home? While it won't have nearly the same features, you can build your own with Google's AIY (artificial intelligence yourself) Kit! In this post I recount my experience attempting to reproduce the Google Home's ability to play music on demand.

As funny as it sounds, I remember the day I heard about the AIY Kit even though it was over a year ago. A bunch of my friends and I were at Denny's obscenely late and we were catching up on tech projects. That's when I head that Google was releasing a new DIY project that turns a Raspberry Pi into a cardboard lite version of a Google Home (some assembly obviously required). The Cambridge Microcenter was already taking reservations for the kit so I claimed mine and had my friend who lived in the area pick it up for me. While I eventually ended up living with someone who was gifted a Google Home, I did get to play around with it for a sufficient time. I'll cover what I was able to get it to do and obviously the numerous interesting gotchas I ran into (based on both memory and my thankfully detailed README).

Source Code

The code for my project can be found at https://gitlab.com/chowner/My-AIY.


As you might be able to tell by the funky nails, I built my AIY during a Halloween party as that's when my friend brought it to me.

What can it do?

Basic Google Assistant abilities

As part of the default image, the AIY can do regular Google Assistant stuff (minus things that need Google Home integration). Personally, I had fun using Google Assistant's Easter eggs, but it can do other things like conversions, setting timers, etc. As I found out surprisingly, out of the box it can't play music though the Assistant (more on that below).

Music (from your Google Music library only)

I wanted to integrate with Google Music and hook this up to my Bluetooth speaker to play songs with voice commands but alas, the Assistant does not seem to have Google Music functionality built-in. Instead, it says the functionality is supported when asking it to "play some music", but it gets confused when asked to play a genre, album, song, etc. I used this repo to start and added my own tweaks for more music stream control and support for playing individual songs from a Google Music library. As a note, the repo documentation is slightly out of date now that actor.add_keyword is deprecated in the AIY code.

Voice shutdown

"Hey Google, shut down"

Pretty basic, but useful for when you don't want to leave it running all day. Also cooler than just unplugging it.

Package upgrades

"Hey Google, self upgrade"

So I can make sure all the apt packages installed are the latest and greatest.

Dependencies

For the music to work, I needed to install gmusicapi with

pip install gmusicapi

and vlc with

sudo apt-get install vlc

Issues + Workarounds

Music: Streaming music over Bluetooth

TL;DR: If you're using a Raspberry Pi 3, DO NOT use the built-in Bluetooth!! When I was setting this up over a year ago, the RasPi 3 had issues with the built-in Bluetooth. Using it, I was able to play music through my UE BOOM 2 speaker (although the sound quality wasn't that great due to a known issue with WiFi and Bluetooth compatibility on RasPi 3s), but it cut out eventually with the following in journalctl:

<working fine for the stream besides a few skipped microseconds>
Nov 05 19:50:54 google-aiy kernel: Bluetooth: hci0 link tx timeout

It seems it wasn't an uncommon issue for others as well: https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=166564. My workaround was to use an external Bluetooth dongle (this is the one I ended up using), and to add the following line to the Pi's /boot/config.txt:

dtoverlay=pi3-disable-bt

This completely resolved the stream quality AND made it so the connection would stop randomly dying. Now the music will keep playing until I tell my AIY to stop the stream.

Music: PulseAudio is way too loud

On the Raspberry Pi 3, BlueZ is used as the Bluetooth stack. However, BlueZ >= v5.0 doesn’t support ALSA (Advanced Linux Sound Architecture), but PulseAudio does. BlueZ supports PulseAudio >= v5.0, resulting in the following : BlueZ → PulseAudio → ALSA Before you accidentally blow out your speaker after starting PulseAudio like I nearly did, I highly recommend you change the following under Element PCM in /usr/share/pulseaudio/alsa-mixer/paths/analog-output.conf.common from this:

volume = merge

To this:

volume = ignore
volume-limit = 0.005

I'm not sure why, but it is otherwise EXTEREMELY LOUD if you do not do this and you plan on connecting a Bluetooth device.

Conclusion

Overall, the AIY is fun to build and worth it nowadays, especially if you have a spare Raspberry Pi laying around. You can get the kit nowadays for pretty cheap on Amazon. Don't expect it to replace your Google Home or Alexa though.

Previous Post Next Post