Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

Commit

Permalink
Python API and example source code for VisionKit
Browse files Browse the repository at this point in the history
This commit extends the original AIY projects
python API to include drivers, APIs and demos
for the AIY Projects Vision Kit.

https://aiyprojects.withgoogle.com/vision/
  • Loading branch information
Peter Malkin committed Dec 18, 2017
1 parent 3ce28a1 commit a4298c6
Show file tree
Hide file tree
Showing 53 changed files with 6,601 additions and 165 deletions.
38 changes: 4 additions & 34 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ 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`:
`~/AIY-projects-python`:

```shell
sudo apt-get install git
cd
git clone https://github.com/google/aiyprojects-raspbian.git voice-recognizer-raspi
git clone https://github.com/google/aiyprojects-raspbian.git AIY-projects-python
```

Then, install the project dependencies and setup the services:

``` shell
cd ~/voice-recognizer-raspi
cd ~/AIY-projects-python
scripts/install-deps.sh
sudo scripts/install-services.sh
```
Expand All @@ -31,21 +31,10 @@ on Raspbian 2017-07-05 and later. You'll also need to configure ALSA:

``` shell
sudo scripts/configure-driver.sh
sudo reboot
```

After your Pi has rebooted with the driver enabled, run:

```
cd ~/voice-recognizer-raspi
sudo scripts/install-alsa-config.sh
python3 checkpoints/check_audio.py
sudo reboot
```

Don't skip running `check_audio.py` before rebooting, as it has an important
effect on the state of ALSA, the sound architecture.

## Get cloud credentials

To access the cloud services you need to register a project and generate
Expand All @@ -71,7 +60,7 @@ 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
cd ~/AIY-projects-python
source env/bin/activate
python3 src/assistant_library_demo.py
```
Expand All @@ -83,22 +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
```

## Troubleshooting

If you're using the Voice Kit and see an error like:

``` shell
ALSA lib pcm.c:8403:(snd_pcm_set_params) Rate doesn't match (requested 16000Hz, get 48000Hz)
```
or
``` shell
arecord: set_params:1233: Sample format non available
Available formats:
- S32_LE
```
Try running `rm ~/.asoundrc && sudo reboot`. For more details, [see this GitHub
issue](https://github.com/google/aiyprojects-raspbian/issues/183).
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ check:
PYTHONPATH=$$PWD/src python3 -m unittest discover tests

deploy_scripts:
git ls-files | rsync -avz --exclude=".*" --exclude="*.desktop" --files-from - . pi@$(PI):~/AIY-voice-kit-python
git ls-files | rsync -avz --exclude=".*" --exclude="*.desktop" --files-from - . pi@$(PI):~/AIY-projects-python

deploy_shortcuts:
scp $(SHORTCUTS) pi@$(PI):~/Desktop
Expand Down
2 changes: 1 addition & 1 deletion checkpoints/check_wifi.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def check_wifi_is_connected():
"""Check wlan0 has an IP address."""
output = subprocess.check_output(['ifconfig', 'wlan0']).decode('utf-8')

return 'inet addr' in output
return 'inet ' in output


def check_can_reach_google_server():
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
google-assistant-grpc==0.0.2
grpc-google-cloud-speech-v1beta1==0.14.0
google-auth-oauthlib==0.1.0
google-auth-oauthlib==0.2.0
2 changes: 2 additions & 0 deletions scripts/install-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ sudo pip3 install --upgrade pip virtualenv
cd "${scripts_dir}/.."
virtualenv --system-site-packages -p python3 env
env/bin/pip install -r requirements.txt
echo "/home/pi/AIY-projects-python/src" > \
/home/pi/AIY-projects-python/env/lib/python3.5/site-packages/aiy.pth

# The google-assistant-library is only available on ARMv7.
if [[ "$(uname -m)" == "armv7l" ]] ; then
Expand Down
2 changes: 1 addition & 1 deletion scripts/install-services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ cd "$(dirname "${BASH_SOURCE[0]}")/.."
repo_path="$PWD"

for service in systemd/*.service; do
sed "s:/home/pi/voice-recognizer-raspi:${repo_path}:g" "$service" \
sed "s:/home/pi/AIY-projects-python:${repo_path}:g" "$service" \
> "/lib/systemd/system/$(basename "$service")"
done

Expand Down
2 changes: 1 addition & 1 deletion shortcuts/check_audio.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ Encoding=UTF-8
Type=Application
Name=Check audio
Comment=Check that the voiceHAT audio input and output are both working.
Exec=/home/pi/voice-recognizer-raspi/checkpoints/check_audio.py
Exec=/home/pi/AIY-projects-python/checkpoints/check_audio.py
Terminal=true
2 changes: 1 addition & 1 deletion shortcuts/check_cloud.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ Encoding=UTF-8
Type=Application
Name=Check Cloud
Comment=Check that the Cloud Speech API can be used.
Exec=/home/pi/voice-recognizer-raspi/checkpoints/check_cloud.py
Exec=/home/pi/AIY-projects-python/env/bin/python /home/pi/AIY-projects-python/checkpoints/check_cloud.py
Terminal=true
2 changes: 1 addition & 1 deletion shortcuts/check_wifi.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ Encoding=UTF-8
Type=Application
Name=Check WiFi
Comment=Check that the WiFi is working.
Exec=/home/pi/voice-recognizer-raspi/checkpoints/check_wifi.py
Exec=/home/pi/AIY-projects-python/checkpoints/check_wifi.py
Terminal=true
26 changes: 26 additions & 0 deletions src/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
This repository contains an easy-to-use API for the AIY Voice Kit.
You can use it to create voice commands with simple while loops - have a look at the [demos](https://github.com/google/aiyprojects-raspbian/tree/voicekit/src).
Documentation is at the [AIY Projects site](https://aiyprojects.withgoogle.com).

For guidelines on contributing, look at [CONTRIBUTING.md](CONTRIBUTING.md).
If you're using Raspbian instead of Google's provided image, read
[HACKING.md](HACKING.md) for information on getting started.

For returning users:
The old voice-recognizer demo remains in the [master branch](https://github.com/google/aiyprojects-raspbian/tree/master) of this project.
The new code is in the `voicekit` branch, and is included in images starting with aiyprojects-2017-09-11.img.

# Support

If you're having trouble assembling your Voice Kit or running the demos,
try the [AIY Forums](https://www.raspberrypi.org/forums/viewforum.php?f=114).

If you've found a bug in the AIY Voice Kit API or demos, you can look at the
[known issues](https://github.com/google/aiyprojects-raspbian/issues) or create
a new one, or even fix it yourself and send us a pull request.

If you've found a problem with the Assistant (for example, crashes in the
library or incorrect responses), you can try
[the G+ community](https://plus.google.com/communities/117537996116836200696),
[Stack Overflow](https://stackoverflow.com/questions/tagged/google-assistant-sdk),
or [the assistant-sdk-python repo](https://github.com/googlesamples/assistant-sdk-python/).
1 change: 1 addition & 0 deletions src/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See README.md
Loading

0 comments on commit a4298c6

Please sign in to comment.