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:
You will need:
/home/pi/Downloads/client_secret.json
/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
sudo /opt/AlexaPi/src/scripts/setup.sh
sudo bash /opt/AlexaPi/src/scripts/auth_assistant.sh
sudo bash /opt/AlexaPi/src/scripts/install_assistant.sh
/home/pi/.asoundrc
and /var/lib/AlexaPi/.asoundrc
for the bootup-service - change both if necessary), but you might have to adjust the card- and device-ids according to the output of aplay -l && arecord -l
on your Pi.sudo systemctl start AlexaPi.service
.python /opt/AlexaPi/src/main.py
.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.
To start AssistantPi in debugging mode, stop the service (if running) and run the script with the -d
flag:
sudo systemctl stop AlexaPi.service
python /opt/AlexaPi/src/main.py -d
To start the embedded Google Assistant SDK, run
/opt/AlexaPi/env/bin/python -m googlesamples.assistant --credentials /etc/opt/AlexaPi/assistant_credentials.json
# same as running
### source /opt/AlexaPi/env/bin/activate
### python -m googlesamples.assistant --credentials /etc/opt/AlexaPi/assistant_credentials.json
and type assistant_record into the prompt to start a conversation. For more information on Assistant Troubleshooting, check here.
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
.
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).
To change the hotwords (currently Alexa and Google), either change both these files before running the setup:
.../src/config.template.yaml
(phrase and phrase_assistant) and .../src/keyphrase.list
or /etc/opt/AlexaPi/config.yaml
and /opt/AlexaPi/src/keyphrase.list
after setup.
In the config.yaml
, you may use a single String or an Array of Strings for your phrase_assistant (only). Every string there will trigger Assistant, everything else in your keyphrase.list
will trigger Alexa.
In the keyphrase.list
, you can also tweak the sensitivity of the hotword recognition. From the CMUSphinx Wiki:
Threshold must be tuned for every keyphrase on a test data to get the right balance missed detections and false alarms. You can try values like 1e-5 to 1e-50. For the best accuracy it is better to have keyphrase with 3-4 syllables. Too short phrases are easily confused.
You can also combine wakewords, e.g. "ok google" and/or "hey google". 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/
The default language coming with Pocketsphinx for the hotword recognition is US English. If you want to change it (which might be necessary if your hotwords aren't recognized well), head over to CMUSphinx Downloads page and get the model files for your language. In particular, you have to place the following files
in /usr/local/lib/python2.7/dist-packages/pocketsphinx/model/
and the contents of
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,
/etc/opt/AlexaPi/config.yaml
language
and dictionary
attributes in pocketsphinx
configuration/usr/local/lib/python2.7/dist-packages/pocketsphinx/model/
:
cd /home/pi/Downloads
wget http://dl.xtools.at/pocketsphinx-german.zip
sudo unzip pocketsphinx-german.zip -d /usr/local/lib/python2.7/dist-packages/pocketsphinx/model/
sudo nano /etc/opt/AlexaPi.config.yaml