Skip to main content

A Python library for interacting with Google Assistant API via text

Project description

gassist_text

A Python library for interacting with Google Assistant API via text.

Credits

Uses https://pypi.org/project/google-assistant-grpc/. See instructions there how to get credentials.json.

Code is essentially a copy of https://github.com/googlesamples/assistant-sdk-python/blob/master/google-assistant-sdk/googlesamples/assistant/grpc/textinput.py wrapped in a package.

Example

import json
import google.oauth2.credentials
with open('/path/to/credentials.json', 'r') as f:
    credentials = google.oauth2.credentials.Credentials(token=None, **json.load(f))

from gassist_text import TextAssistant
with TextAssistant(credentials) as assistant:
    print(assistant.assist('tell me a joke')[0])
    print(assistant.assist('another one')[0])

Limitations/Known issues

If you see the issued commands in My Google Activity the library is working fine. If the commands don't have the expected outcome, don't open an issue in this repository. You should instead report the issue directly to Google. Examples of known Google Assistant API issues:

  • Broadcast commands don't work unless speakers and device that runs this library are in the same network and IPv6 is disabled in the router
  • Most queries for media controls don't work
    • not working: e.g. play music on kitchen speaker, stop kitchen speaker
    • working: e.g. play news on kitchen speaker, play rain sounds on bedroom speaker
  • Routines don't work
  • Commands that need to verify your identity through voice match don't work

To get personal results working you need to create an OAuth client ID of Desktop app, see step by step instructions in this article.

Development environment

python3 -m venv .venv
source .venv/bin/activate
# for Windows CMD:
# .venv\Scripts\activate.bat
# for Windows PowerShell:
# .venv\Scripts\Activate.ps1

# Install dependencies
python -m pip install --upgrade pip
python -m pip install -e .

# Generate embedded_assistant_pb2.py and embedded_assistant_pb2_grpc.py
python -m pip install grpcio-tools
python -m grpc_tools.protoc -Isrc --python_out=src --grpc_python_out=src src/google/assistant/embedded/v1alpha2/embedded_assistant.proto

# Run pre-commit
python -m pip install pre-commit
pre-commit autoupdate
pre-commit install
pre-commit run --all-files

# Alternative: run formatter, lint
python -m pip install isort black flake8 ruff
isort . ; black . ; flake8 . ; ruff check . --fix

# Run tests
python -m pip install pytest
pytest

# Run command line interactive tool
python -m pip install click beautifulsoup4
python demo.py --display --audio_out

# Build package
python -m pip install build
python -m build

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gassist_text-0.0.14.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

gassist_text-0.0.14-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file gassist_text-0.0.14.tar.gz.

File metadata

  • Download URL: gassist_text-0.0.14.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for gassist_text-0.0.14.tar.gz
Algorithm Hash digest
SHA256 a8d0240ac29c024b736d0f5a18a2d03ad5706640dd36f565031bf86c35095d79
MD5 3fabe2fb14ca3ed47ab9d6683f10edf2
BLAKE2b-256 50ef9e6a3d4e20e34faab1a518440e9979e29db30a18bc02fe06ab28b89dc7b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for gassist_text-0.0.14.tar.gz:

Publisher: python-publish.yml on tronikos/gassist_text

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gassist_text-0.0.14-py3-none-any.whl.

File metadata

  • Download URL: gassist_text-0.0.14-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for gassist_text-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 a1f1ded85be6c88f5fbc2c6f99f16d4a2873b4554642b983ebc69cf2373cadc7
MD5 026a651bcd25fb79aa94cdb283e50913
BLAKE2b-256 243588b348fd79a9386093b17101de98569ce0d4ec40a41887a7d1cb96cc890f

See more details on using hashes here.

Provenance

The following attestation bundles were made for gassist_text-0.0.14-py3-none-any.whl:

Publisher: python-publish.yml on tronikos/gassist_text

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page