Skip to main content

This repository contains a Python sample for the Google Assistant API.

See Getting Started with the Raspberry Pi 3 for instructions on how to run the sample on supported hardware.

Prerequisites

  • Python (3.x prefered)

  • Google API Console Project w/ Google Assistant API enabled.

  • OAuth client ID credentials with application type Other.

  • Use a new virtualenv (recommended):

    # python3 (recommended)
    sudo apt-get update
    sudo apt-get install python3-dev python3-venv
    python3 -m venv env
    env/bin/python -m pip install --upgrade pip setuptools
    source env/bin/activate
    
    # python2
    sudo apt-get update
    sudo apt-get install python-dev python-virtualenv
    virtualenv env --no-site-packages
    env/bin/python -m pip install --upgrade pip setuptools
    source env/bin/activate

Setup

  • Install the sample dependencies:

    sudo apt-get install portaudio19-dev libffi-dev libssl-dev
  • Install the latest Google Assistant SDK and samples package from PyPI:

    python -m pip install --upgrade google-assistant-sdk[samples]
    • Or if working from this repository’s sources, run:

      python -m pip install --upgrade -e ".[samples]"
  • Authorize access to the Google Assistant API:

    python -m googlesamples.assistant.auth_helpers --client-secrets client_secret_XXXX.json
    Please go to this URL: ...
    Enter the authorization code:
  • Verify audio setup:

    # Record a 5 sec sample and play it back
    python -m googlesamples.assistant.audio_helpers

Run the Sample

  • Record a voice query and the program should play back the Google Assistant’s answer:

    python -m googlesamples.assistant
  • Record and send pre-recorded audio to the Assistant:

    python -m googlesamples.assistant -i in.wav
  • Save Assistant response to a file:

    python -m googlesamples.assistant -o out.wav

Troubleshooting

  • Verify 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
  • Run the sample with verbose logging enabled:

    python -m googlesamples.assistant --verbose

For Maintainers

See MAINTAINER.md for more documentation on the development, maintainance and release of the Python package itself.

Contributing

Contributions to this repository are always welcome and highly encouraged.

See CONTRIBUTING.md for more information on how to get started.

License

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.

Metadata

Release files for google-assistant-sdk 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for google-assistant-sdk 0.2.0
File Size Uploaded
google-assistant-sdk-0.2.0.tar.gz 55.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for google-assistant-sdk 0.2.0
File Interpreter ABI Platform
google_assistant_sdk-0.2.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 83.0 kB

Release files / google-assistant-sdk-0.2.0.tar.gz

Download URL google-assistant-sdk-0.2.0.tar.gz
Size 55.5 kB
Tags Source
SHA-256 checksum
How to use checksums
82eb624e67caf371c3a30dfcdf6aae491d904ed75155c75e6952e7446c6d748e
BLAKE2b-256 checksum
How to use checksums
caf5b16846ed1ca88117e1ff3a73e7cebd5aa6e232c61be5a07cd7869cf97574
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / google_assistant_sdk-0.2.0-py2.py3-none-any.whl

Download URL google_assistant_sdk-0.2.0-py2.py3-none-any.whl
Size 27.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
a2763f886a3fc1509c7f2d7693b97cd36d35bde97ffbd14278ac0ed1b3d496a0
BLAKE2b-256 checksum
How to use checksums
dc2834a99c18d20c67ba36c7fa45ba374b66473d46e82aa4bb9092c77a485fc9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page