AssistantPi is basically a tweak of AlexaPi allowing you to run Google Assistant and Amazon's Alexa on a Raspberry Pi. It includes the Google Assistant SDK and uses AlexaPi's hotword recognition to activate either Assistant or Alexa. The installer provides an easy way to get everything set up in just under an hour.
This is just an experimental proof-of-concept without broad support.
Credits / Further Resources:
- AlexaPi on Github
- AlexaPi Installation Guide
- Google Assistant SDK on Github
- Google Assistant SDK Getting Started Guide
You will need:
- A Raspberry Pi and an SD Card with a fresh install of Raspbian Jessie Lite
- Audio peripherals:
- external speaker with 3.5mm Jack
- USB microphone
- Have your Raspberry Pi running Raspbian ready and connected to the Internet. Use a fresh install of Raspbian Jessie Lite without Pixel.
- Follow this Google Guide and place the Google Assistant Credentials JSON in
/home/pi/Downloads/client_secret.json
- Prepare Amazon AVS Credentials as described in Step 1 of AlexaPi Installation Guide, you'll need them during Installation. Even if you only want Google Assistant, this has to be done for AlexaPi to work properly.
- Connect your audio peripherals (i.e. USB-Mic and Speaker via Jack).
- Clone this repository to
/opt
directory and rename the folder to AlexaPi (both important, it will fail otherwise). These commands will do that for you:
cd /opt
sudo git clone https://github.com/xtools-at/AssistantPi.git AlexaPi
- Run the setup and go through all the steps. This will take a while, approx. 35min with a somewhat good Internet connection.
sudo /opt/AlexaPi/src/scripts/setup.sh
- If Authentication with Google Assistant API fails during setup, try to run it manually with
sudo bash /opt/AlexaPi/src/scripts/auth_assistant.sh
- If Google Assistant setup crashes, do what the Error message says and restart with
sudo bash /opt/AlexaPi/src/scripts/install_assistant.sh
- Proceed with Step 3 of AlexaPi Installation Guide.
- Make sure to check Configure Google Assistant Audio Output too. The config file is already in place for you (
/home/pi/.asoundrc
and/var/lib/AlexaPi/.asoundrc
for the bootup-service), but you might have to adjust the card- and device-ids according to the output ofaplay -l && arecord -l
on your Pi. - Trigger Assistant and Alexa with the hotwords Google and Alexa.
Bringing your AssistantPi up-to-date is just one command away:
sudo bash /opt/AlexaPi/src/scripts/update.sh
This updates both AssistantPi and the tweaked Assistant SDK without having you to go through the installation process again.
Make sure you've been to sudo raspi-config
, Advanced Options > Audio and have set the desired audio output (i.e. 3.5mm Jack, not HDMI).
The base audio config is done for you in the setup for both AlexaPi and Assistant. However, if encountering any audio issues in playback or recording, make sure to check by here:
If Google Assistant audio output is choppy or truncated, check the following. Make sure to run source /opt/AlexaPi/env/bin/activate
before running the samples there, to target AssistantPi's Python environment.
You can set the values for the Block- and Flush size in the AssistantPi config, either before Installation in /opt/AlexaPi/src/config.template.yaml
or afterwards in /etc/opt/AlexaPi/config.yaml
. Go find the attribute sound > assistant
and use your values for block_size
and flush_size
.
To change the hotwords (currently Alexa and Google), change both these files before running the setup:
.../src/config.template.yaml
(phrase and phrase_assistant) and .../src/keyphrase.list
In the latter, you can also tweak the sensitivity of the hotword recognition. See here for more information on this topic.
Also make sure that your new hotwords are included in the language model. Check the following directory for a file with .dict
or .dic
extension and add your hotwords if not already there: /usr/local/lib/python2.7/dist-packages/pocketsphinx/model/
If you want to change the language for the hotword recognition (which might be necessary if your hotwords aren't recognized well), head over to CMU Sphinx download page and get the model files for your language. In particular, you have to place the following files
- FILENAME.lm.bin
- FILENAME.dic
in /usr/local/lib/python2.7/dist-packages/pocketsphinx/model/
and the contents of
- FILENAME.tar.gz
in /usr/local/lib/python2.7/dist-packages/pocketsphinx/model/[lng-lng]
(where [lng-lng] is the language code of your imported language, e.g. 'de-de')
Make sure, that FILENAME.dic
contains your desired hotwords (i.e. Alexa and Google for default settings), if not, add them.
Afterwards,
- change
/etc/opt/AlexaPi/config.yaml
- find
language
anddictionary
attributes inpocketsphinx
configuration - change language to your language code (e.g. 'de-de', see above)
- change dictionary to your FILENAME.dic (e.g. 'cmusphinx-voxforge-de.dic')
- find
- Download package from here and unzip.
- Move contents to
/usr/local/lib/python2.7/dist-packages/pocketsphinx/model/
- Edit your config.yaml and include new values
sudo nano /etc/opt/AlexaPi.config.yaml
#...
# find pocketsphinx > language, change to 'de-de'
# find pocketsphinx > dictionary, change to 'cmusphinx-voxforge-de.dic'