From aadc57c8cee896fa652cb85ea83ad650996b44a2 Mon Sep 17 00:00:00 2001 From: t1m0thyj Date: Thu, 12 Oct 2017 11:20:46 -0400 Subject: [PATCH 1/3] Add instructions for setting up on Raspbian in voicekit branch. --- HACKING.md | 95 ++++++++++++++++++++++++++++++++ systemd/voice-recognizer.service | 16 ++++++ 2 files changed, 111 insertions(+) create mode 100644 HACKING.md create mode 100644 systemd/voice-recognizer.service diff --git a/HACKING.md b/HACKING.md new file mode 100644 index 00000000..fc29b7a6 --- /dev/null +++ b/HACKING.md @@ -0,0 +1,95 @@ +# Setting up the image + +We recommend using [the images](https://aiyprojects.withgoogle.com/voice) we +provide. Those images are based on [Raspbian](https://www.raspberrypi.org/downloads/raspbian/), +with a few customizations and are tested on the Raspberry Pi 3. If you prefer +to setup Raspbian yourself, there are some manual steps you need to take. + +## Installing the dependencies + +First, make sure you have `git` installed and clone this repository in +`~/voice-recognizer-raspi`: + +```shell +sudo apt-get install git +cd +git clone https://github.com/google/aiyprojects-raspbian.git voice-recognizer-raspi +``` + +Then, install the project dependencies and setup the services: + +``` shell +cd ~/voice-recognizer-raspi +scripts/install-deps.sh +sudo scripts/install-services.sh +``` + +## Installing the Voice HAT driver and config + +To use the Voice HAT, you'll need to upgrade your kernel to 4.9, then adjust the +kernel and ALSA configuration: + +``` shell +sudo apt-get update +sudo apt-get install raspberrypi-kernel +sudo scripts/configure-driver.sh +sudo scripts/install-alsa-config.sh +sudo reboot +``` + +## Get cloud credentials + +To access the cloud services you need to register a project and generate +credentials for cloud APIs. This is documented in the +[setup instructions](https://aiyprojects.withgoogle.com/voice#users-guide-1-1--connect-to-google-cloud-platform) on the +webpage. + +# Making code changes + +If you edit the code on a different computer, you can deploy it to your +Raspberry Pi by running: + +``` shell +make deploy +``` + +You can find sample scripts in the `src` directory showing how to use the +Assistant SDK. + +To execute any of these scripts on the Raspberry Pi, login to it and run +(replacing the filename with the script you want to run): + +``` shell +cd ~/voice-recognizer-raspi +source env/bin/activate +python3 src/assistant_library_demo.py +``` + +If you want the voice recognizer service to run automatically when the Pi +boots, you need to have a file in the `src` directory named `main.py`. You can +make a copy of one of the sample scripts and rename it. Then run this command: + +``` shell +sudo systemctl enable voice-recognizer.service +``` + +# I18N + +Strings wrapped with `_()` are marked for translation: + +``` shell +# update catalog after string changed +pygettext3 -d voice-recognizer -p po src/main.py src/action.py + +# add new language +msgmerge po/de.po po/voice-recognizer.pot +# now edit po/de.po + +# update language +msgmerge -U po/de.po po/voice-recognizer.pot +# now edit po/de.po + +# create language bundle +mkdir po/de/LC_MESSAGES/ +msgfmt po/de.po -o po/de/LC_MESSAGES/voice-recognizer.mo +``` diff --git a/systemd/voice-recognizer.service b/systemd/voice-recognizer.service new file mode 100644 index 00000000..ba493d74 --- /dev/null +++ b/systemd/voice-recognizer.service @@ -0,0 +1,16 @@ +[Unit] +Description=voice recognizer +After=network.target ntpdate.service + +[Service] +Environment=VIRTUAL_ENV=/home/pi/voice-recognizer-raspi/env +Environment=PATH=/home/pi/voice-recognizer-raspi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +ExecStart=/home/pi/voice-recognizer-raspi/env/bin/python3 -u src/main.py +WorkingDirectory=/home/pi/voice-recognizer-raspi +StandardOutput=inherit +StandardError=inherit +Restart=always +User=pi + +[Install] +WantedBy=multi-user.target From d00749db84f6a29b575b13a11fa8d67ccd12228a Mon Sep 17 00:00:00 2001 From: t1m0thyj Date: Wed, 18 Oct 2017 08:35:43 -0400 Subject: [PATCH 2/3] Update HACKING.md based on feedback from drigz --- HACKING.md | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/HACKING.md b/HACKING.md index fc29b7a6..ea3c6153 100644 --- a/HACKING.md +++ b/HACKING.md @@ -26,12 +26,10 @@ sudo scripts/install-services.sh ## Installing the Voice HAT driver and config -To use the Voice HAT, you'll need to upgrade your kernel to 4.9, then adjust the -kernel and ALSA configuration: +To use the Voice HAT, your kernel needs to be 4.9 or later. This is available +on Raspbian 2017-07-05 and later. You'll also need to configure ALSA: ``` shell -sudo apt-get update -sudo apt-get install raspberrypi-kernel sudo scripts/configure-driver.sh sudo scripts/install-alsa-config.sh sudo reboot @@ -44,7 +42,7 @@ credentials for cloud APIs. This is documented in the [setup instructions](https://aiyprojects.withgoogle.com/voice#users-guide-1-1--connect-to-google-cloud-platform) on the webpage. -# Making code changes +## Making code changes If you edit the code on a different computer, you can deploy it to your Raspberry Pi by running: @@ -53,6 +51,8 @@ Raspberry Pi by running: make deploy ``` +## Running automatically + You can find sample scripts in the `src` directory showing how to use the Assistant SDK. @@ -72,24 +72,3 @@ make a copy of one of the sample scripts and rename it. Then run this command: ``` shell sudo systemctl enable voice-recognizer.service ``` - -# I18N - -Strings wrapped with `_()` are marked for translation: - -``` shell -# update catalog after string changed -pygettext3 -d voice-recognizer -p po src/main.py src/action.py - -# add new language -msgmerge po/de.po po/voice-recognizer.pot -# now edit po/de.po - -# update language -msgmerge -U po/de.po po/voice-recognizer.pot -# now edit po/de.po - -# create language bundle -mkdir po/de/LC_MESSAGES/ -msgfmt po/de.po -o po/de/LC_MESSAGES/voice-recognizer.mo -``` From 227e9adc7bae27dd1f97300f0e92d9cf7d38725c Mon Sep 17 00:00:00 2001 From: t1m0thyj Date: Wed, 18 Oct 2017 11:25:54 -0400 Subject: [PATCH 3/3] Changed header in HACKING.md for Voice HAT driver --- HACKING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HACKING.md b/HACKING.md index ea3c6153..645e1adb 100644 --- a/HACKING.md +++ b/HACKING.md @@ -24,7 +24,7 @@ scripts/install-deps.sh sudo scripts/install-services.sh ``` -## Installing the Voice HAT driver and config +## Configuring the Voice HAT driver To use the Voice HAT, your kernel needs to be 4.9 or later. This is available on Raspbian 2017-07-05 and later. You'll also need to configure ALSA: