Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
google-assistant-grpc
Advanced tools
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_.
.. note:: The Google Assistant Service is available for non-commercial use
_.
.. _Python: https://www.python.org/ .. _gRPC: https://www.grpc.io .. _Google Assistant Service: https://developers.google.com/assistant/sdk/guides/service/python/ .. _Google Assistant SDK: https://developers.google.com/assistant/sdk .. _non-commercial use: https://developers.google.com/assistant/sdk/terms-of-service
You can install using pip <https://pip.pypa.io/>
_.::
pip install --upgrade google-assistant-grpc
Follow the steps to configure the Actions Console project and the Google account <https://developers.google.com/assistant/sdk/guides/service/python/embed/config-dev-project-and-account>
_.
Follow the steps to register a new device model and download the client secrets file <https://developers.google.com/assistant/sdk/guides/service/python/embed/register-device>
_.
Generate device credentials using google-oauthlib-tool
:
pip install --upgrade google-auth-oauthlib[tool] google-oauthlib-tool --client-secrets path/to/client_secret_.json --scope https://www.googleapis.com/auth/assistant-sdk-prototype --save --headless
Load the device credentials using google.oauth2.credentials <https://google-auth.readthedocs.io/en/latest/reference/google.oauth2.credentials.html>
_.::
import io import google.oauth2.credentials
with io.open('/path/to/credentials.json', 'r') as f: credentials = google.oauth2.credentials.Credentials(token=None, **json.load(f))
Initialize the gRPC channel using google.auth.transport.grpc <https://google-auth.readthedocs.io/en/latest/reference/google.auth.transport.grpc.html>
_.
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:
AssistResponse
_ with the EventType
_ message set to END_OF_UTTERANCE
.SpeechRecognitionResult
_ field.DialogStateOut
_ field.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)
.. _Assist: https://developers.google.com/assistant/sdk/reference/rpc/google.assistant.embedded.v1alpha2#embeddedassistant .. _AssistRequest: https://developers.google.com/assistant/sdk/reference/rpc/google.assistant.embedded.v1alpha2#google.assistant.embedded.v1alpha2.AssistRequest .. _AssistResponse: https://developers.google.com/assistant/sdk/reference/rpc/google.assistant.embedded.v1alpha2#google.assistant.embedded.v1alpha2.AssistResponse .. _EventType: https://developers.google.com/assistant/sdk/reference/rpc/google.assistant.embedded.v1alpha2#eventtype .. _AudioOut: https://developers.google.com/assistant/sdk/reference/rpc/google.assistant.embedded.v1alpha2#google.assistant.embedded.v1alpha2.AudioOut .. _SpeechRecognitionResult: https://developers.google.com/assistant/sdk/reference/rpc/google.assistant.embedded.v1alpha2#speechrecognitionresult .. _DialogStateOut: https://developers.google.com/assistant/sdk/reference/rpc/google.assistant.embedded.v1alpha2#dialogstateout
gRPC reference sample <https://github.com/googlesamples/assistant-sdk-python/tree/master/google-assistant-sdk/googlesamples/assistant/grpc>
_.Google Assistant Service reference <https://developers.google.com/assistant/sdk/reference/rpc/>
_.See MAINTAINER.md <MAINTAINER.md>
_ for more documentation on the
development, maintainance and release of the Python package itself.
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.
FAQs
Google Assistant API gRPC bindings
We found that google-assistant-grpc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.