Skip to main content

Google Assistant API gRPC bindings

Project description

This package contains the generated Python bindings for the Google Assistant Service. It is part of the Google Assistant SDK.

This package should be compatible with POSIX platforms supporting gRPC and Python.

Installing

  • You can install using pip.:

    pip install --upgrade google-assistant-grpc

Authorization

Usage

  • Initialize the gRPC stubs using google.assistant.embedded.v1alpha1.embedded_assistant_pb2_grpc.:

    import google.assistant.embedded.v1alpha1.embedded_assistant_pb2_grpc
    assistant = embedded_assistant_pb2.EmbeddedAssistantStub(channel)
  • Call the Assist streaming method. It takes a generator of AssistRequest and returns a generator of AssistResponse.:

    assist_responses_generator = assistant.Assist(assist_requests_generator)
    start_acquiring_audio()
  • Send a AssistRequest message with audio configuration parameters followed by multiple outgoing AssistRequest messages containing the audio data of the Assistant request.:

    import google.assistant.embedded.v1alpha1.embedded_assistant_pb2
    
    def generate_assist_requests():
        yield embedded_assistant_pb2.AssistConfig(
            audio_in_config=embedded_assistant_pb2.AudioInConfig(
                encoding='LINEAR16',
                sample_rate_hertz=16000,
            ),
            audio_out_config=embedded_assistant_pb2.AudioOutConfig(
                encoding='LINEAR16',
                sample_rate_hertz=16000,
            ),
            device_config=embedded_assistant_pb2.DeviceConfig(
                device_id=device_id,
                device_model_id=device_model_id,
            )
        )
        for data in acquire_audio_data():
            yield embedded_assistant_pb2.AssistRequest(audio_in=data)
  • Handle the incoming stream of AssistResponse messages:

    • Stop recording when receiving a AssistResponse with the EventType message set to END_OF_UTTERANCE.

    • Get transcription of the user query from the SpeechRecognitionResult field.

    • Get conversation metadata like supplemental display text from the Assistant from the DialogStateOut field.

    • Extract the audio data of the Assistant response from the AudioOut field.

for assist_response in assist_response_generator:
    if resp.event_type == END_OF_UTTERANCE:
       stop_acquiring_audio()
    if resp.speech_results:
       print(' '.join(r.transcript for r in resp.speech_results)
    if resp.dialog_state_out.supplemental_display_text:
       print(resp.dialog_state_out.supplemental_display_text)
    if len(resp.audio_out.audio_data) > 0:
       playback_audio_data(resp.audio_out.audio_data)

Reference

For Maintainers

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

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.

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

google-assistant-grpc-0.2.1.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

google_assistant_grpc-0.2.1-py2.py3-none-any.whl (21.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file google-assistant-grpc-0.2.1.tar.gz.

File metadata

  • Download URL: google-assistant-grpc-0.2.1.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.4.3

File hashes

Hashes for google-assistant-grpc-0.2.1.tar.gz
Algorithm Hash digest
SHA256 23676343ee18cb84187cc4ff90e7702ccaa0114393bd2497fe84150702907578
MD5 cfd6ec9918fb0fa8dd5380e11e7061d0
BLAKE2b-256 358b479fb760a7da74392a16a37aa119652a130370e60e4c09b7189956259f97

See more details on using hashes here.

File details

Details for the file google_assistant_grpc-0.2.1-py2.py3-none-any.whl.

File metadata

  • Download URL: google_assistant_grpc-0.2.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.4.3

File hashes

Hashes for google_assistant_grpc-0.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 18a41f1d31a268e24c7b2e179b4c1374e2b1ba88f7069542850148408b52a454
MD5 2416f1b2db75386cfcf8fa979ee90db3
BLAKE2b-256 4b5d50dbb8197961acf8a4339e8950e0110159456c4ef48234751d1b5f2e919b

See more details on using hashes here.

Supported by

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