Skip to content
This repository was archived by the owner on Oct 19, 2023. It is now read-only.

Commit f00df5f

Browse files
committed
google-assistant-sdk: sync hotword sample
library-commit: f11eb210784825fde0d41b121863df1008edffc9 Bug: 71360271 Change-Id: I9ee81a9b8694d3c6982fb9c263ee051427549d84
1 parent 36b596e commit f00df5f

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

Diff for: google-assistant-sdk/CHANGELOG.rst

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Changelog
22
=========
33

4+
0.4.1
5+
-----
6+
- Update outdated `hotword` sample.
7+
48
0.4.0
59
-----
610
- Add Device actions handling to samples.

Diff for: google-assistant-sdk/googlesamples/assistant/library/hotword.py

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
23
# Copyright (C) 2017 Google Inc.
34
#
45
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,15 +13,22 @@
1213
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1314
# See the License for the specific language governing permissions and
1415
# limitations under the License.
16+
17+
1518
from __future__ import print_function
19+
1620
import argparse
1721
import os.path
1822
import json
23+
1924
import google.auth.transport.requests
2025
import google.oauth2.credentials
26+
2127
from google.assistant.library import Assistant
2228
from google.assistant.library.event import EventType
2329
from google.assistant.library.file_helpers import existing_file
30+
31+
2432
DEVICE_API_URL = 'https://embeddedassistant.googleapis.com/v1alpha2'
2533

2634

@@ -41,14 +49,18 @@ def process_device_actions(event, device_id):
4149

4250
def process_event(event, device_id):
4351
"""Pretty prints events.
52+
4453
Prints all events that occur with two spaces between each new
4554
conversation and a single space between turns of a conversation.
55+
4656
Args:
4757
event(event.Event): The current event to process.
4858
"""
4959
if event.type == EventType.ON_CONVERSATION_TURN_STARTED:
5060
print()
61+
5162
print(event)
63+
5264
if (event.type == EventType.ON_CONVERSATION_TURN_FINISHED and
5365
event.args and not event.args['with_follow_on_turn']):
5466
print()
@@ -59,8 +71,10 @@ def process_event(event, device_id):
5971

6072
def register_device(project_id, credentials, device_model_id, device_id):
6173
"""Register the device if needed.
74+
6275
Registers a new assistant device if an instance with the given id
6376
does not already exists for this model.
77+
6478
Args:
6579
project_id(str): The project ID used to register device instance.
6680
credentials(google.oauth2.credentials.Credentials): The Google
@@ -79,6 +93,7 @@ def register_device(project_id, credentials, device_model_id, device_id):
7993
r = session.post(base_url, data=json.dumps({
8094
'id': device_id,
8195
'model_id': device_model_id,
96+
'client_type': 'SDK_LIBRARY'
8297
}))
8398
if r.status_code != 200:
8499
raise Exception('failed to register device: ' + r.text)
@@ -98,22 +113,27 @@ def main():
98113
help='Path to store and read OAuth2 credentials')
99114
parser.add_argument('--device_model_id', type=str,
100115
metavar='DEVICE_MODEL_ID', required=True,
101-
help='The device model ID registered with Google.')
116+
help='The device model ID registered with Google')
102117
parser.add_argument('--project_id', type=str,
103118
metavar='PROJECT_ID', required=False,
104-
help='The project ID used to register device '
105-
+ 'instances.')
119+
help=('The project ID used to register'
120+
'device instances'))
121+
106122
args = parser.parse_args()
107123
with open(args.credentials, 'r') as f:
108124
credentials = google.oauth2.credentials.Credentials(token=None,
109125
**json.load(f))
126+
110127
with Assistant(credentials, args.device_model_id) as assistant:
111128
events = assistant.start()
129+
112130
print('device_model_id:', args.device_model_id + '\n' +
113131
'device_id:', assistant.device_id + '\n')
132+
114133
if args.project_id:
115134
register_device(args.project_id, credentials,
116135
args.device_model_id, assistant.device_id)
136+
117137
for event in events:
118138
process_event(event, assistant.device_id)
119139

Diff for: google-assistant-sdk/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def samples_requirements():
3939

4040
setup(
4141
name='google-assistant-sdk',
42-
version='0.4.0',
42+
version='0.4.1',
4343
author='Google Assistant SDK team',
4444
author_email='[email protected]',
4545
description='Samples and Tools the Google Assistant SDK',

0 commit comments

Comments
 (0)