This repository contains a reference sample for the google-assistant-library
Python package.
It demonstrates: - Initialization of the Assistant - Basic event handling including hotword detection.
- Python >= 3.4
- Raspberry Pi 3 running Rasbian (or any other
linux-arm7l
SBC) - A Google API Console Project
- A Google account
Install Python 3
Ubuntu/Debian GNU/Linux:
sudo apt-get update sudo apt-get install python3 python3-venv
Create a new virtual environment (recommended):
python3 -m venv env env/bin/python -m pip install --upgrade pip setuptools source env/bin/activate
Follow the steps to configure the project and the Google account.
Download the
client_secret_XXXXX.json
file from the Google API Console Project credentials section and generate credentials usinggoogle-oauth-tool
:pip install --upgrade google-auth-oauthlib[tool] google-oauthlib-tool --client-secrets path/to/client_secret_XXXXX.json --scope https://www.googleapis.com/auth/assistant-sdk-prototype --save --headless
Install the sample dependencies using pip:
pip install --upgrade -r requirements.txt
Run the hotword sample. The sample waits for the "Ok Google" hotword, then records a voice query and plays back the Google Assistant's answer:
python -m hotword
If audio is not working, verify the ALSA setup:
# Play a test sound speaker-test -t wav # Record and play back some audio using ALSA command-line tools arecord --format=S16_LE --duration=5 --rate=16k --file-type=raw out.raw aplay --format=S16_LE --rate=16k --file-type=raw out.raw
See also the troubleshooting section of the official documentation.
Copyright (C) 2017 Google Inc.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.