This blog post is a follow-up to my post from last week about installing a Snips satellite using a Google AIY Voice Kit + Raspberry Pi Zero. In the previous post, we have been dealing with the basic setup of a Snips satellite. Today we want to improve this satellite by adding some optional gimmicks. First of all we want to activate the LED illuminated arcade button that is part of the Google AIY Voice Kit. After that we want to launch Squeezelite on the satellite, a music playback client controlled via Logitech's Media Server - and now controllable by your voice.

LED illuminated Arcade Button

I made use of the Google AIY Python Bindings for the following implementation. Generally it is possible to work exclusively with the Python library RPi.GPIO. The Google AIY Python library also uses RPi.GPIO internally, but already offers various helper functions. From the Google AIY project I only use the functions for accessing and controlling the hardware connected to the Google AIY Voice Kit, i.e. LED and button. The Google Cloudspeech API and Google Assistant API is not used, because we have Snips for all that.

As already described in the last part, Google has published the drivers and libraries for Google AIY at https://github.com/google/aiyprojects-raspbian . If not already done, clone this repository on your satellite device and run sudo python3 setup.py install. This will take some time, especially on a Raspberry Pi Zero. Maybe this is a good moment to improve your assistant on the Snips Console and maybe even define a new skill.

If you still have the repository checked out from the first part and so you save yourself a new git clone, don't forget to switch back to the default branch: git checkout aiyprojects. Otherwise the described installation will fail.

If the installation routine was successful, we need a little helper service to establish the link between the MQTT message bus and GPIO. I published an implementation in Python that activates and deactivates the LED according to the MQTT messages. Additionally you can press the arcade button to start a conversation with Snips. Clone the repository from https://gitlab.smb-tec.com/snips.ai/snips-google-aiy.git and start the installation as described below. Don't forget to set up this helper as a system service on your satellite to run it permanently in the background. This installation will also need some time on your RPi0...

Since the Google AIY Voice Kit has only one LED, it is sadly not possible to visualize that many different modes. The topics / intents of interest that I've implemented so far are hermes/hotword/default/detected (LED.ON), hermes/hotword/toggleOn (LED.OFF) and hermes/asr/textCaptured (LED.BEACON). Here is a sample implementation

Take a look at the lines 70 to 80 in main.py for the final implementation.

If you want to trigger a Snips conversation not only with your hotword, e.g. Hey Snips, but also by pressing the arcade button, you have to simulate a "successfull result" of the Snips hotword service. This means that we have to publish a message to a MQTT topic, in this case the topic of interest is hermes/hotword/default/detected. It is important that the payload of the message contains the correct siteId and modelId. The following snippet shows an example implementation.

See lines 82 - 86 in main.py for the final implementation.

In case you haven't seen it yet: the provided implementation tries to read and use the existing configuration in /etc/snips.toml. This has the advantage that you don't have to duplicate all the Snips configuration. If your satellite configuration is correct, then this helper should also work.

... and finally - if activated - it looks like this

Squeezelite Snips Satellite

Since I already have several Squeezelite clients installed in my household, it was obvious to make this Google AIY Voice Kit based Snips satellite a client for the Logitech Media Server as well. Although the Logitech Media Server has become quite antiquated, it still works well and runs out of the box on my Synology NAS. For me the highlights are: Spotify support through a 3rd party plugin, multi-room audio sync and a nice iOS client. (these are certainly features that provide other products as well - this is not about pros or cons either).

The installation itself is pretty straightforward. We download the precompiled binary for the ARM platform. Furthermore we need the service configuration to run the Squeezelite client in the background.

You may want to customize the name under which the client registers on the server (-n xxx) or specify a specific LMS server IP (-s ip:port). I launch the Squeezelite client in autodiscovery mode, because I only have one LMS server in the local network and it can be found easily.

The results

A video is worth a thousand words - take a look yourself. I think that result is very convincing for this rather small effort. You can now put a lot of brain power into improving the skill for controlling the Logitech Media Server. This skill will be covered in a follow up blog post.

Lars Martin

I have been developing software for 20 years - mostly on the basis of the JVM. In the recent past I've been doing a methamorphosis towards polyglot projects. In my spare time, I enjoy Smart Home and Home Automation.

Blog Comments powered by Disqus.