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

Commit 2d7f009

Browse files
committed
google-assistant-sdk/pushtotalk: add device-model-id flag
Bug: 67009650 Change-Id: I97d1ee58147ebcad3e68ec3bdf37c2d9b73b09d8
1 parent a736160 commit 2d7f009

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

google-assistant-sdk/googlesamples/assistant/grpc/pushtotalk.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class SampleAssistant(object):
5555
"""Sample Assistant that supports conversations and device actions.
5656
5757
Args:
58-
device_id: identifier of the device.
58+
device_model_id: identifier of the device model.
59+
device_id: identifier of the registered device instance.
5960
conversation_stream(ConversationStream): audio stream
6061
for recording query and playing back assistant answer.
6162
channel: authorized gRPC channel for connection to the
@@ -64,8 +65,9 @@ class SampleAssistant(object):
6465
device_handler: callback for device actions.
6566
"""
6667

67-
def __init__(self, device_id, conversation_stream, channel, deadline_sec,
68-
device_handler):
68+
def __init__(self, device_model_id, device_id, conversation_stream,
69+
channel, deadline_sec, device_handler):
70+
self.device_model_id = device_model_id
6971
self.device_id = device_id
7072
self.conversation_stream = conversation_stream
7173

@@ -192,6 +194,7 @@ def gen_converse_requests(self):
192194
),
193195
converse_state=converse_state,
194196
device_config=embedded_assistant_pb2.DeviceConfig(
197+
device_model_id=self.device_model_id,
195198
device_id=self.device_id,
196199
)
197200
)
@@ -212,9 +215,12 @@ def gen_converse_requests(self):
212215
default=os.path.join(click.get_app_dir('google-oauthlib-tool'),
213216
'credentials.json'),
214217
help='Path to read OAuth2 credentials.')
218+
@click.option('--device-model-id', required=True,
219+
metavar='<device model id>',
220+
help='Unique device model identifier.')
215221
@click.option('--device-id', required=True,
216-
metavar='<device id>', show_default=True,
217-
help='Unique device instance identifier.')
222+
metavar='<device id>',
223+
help='Unique registered device instance identifier.')
218224
@click.option('--verbose', '-v', is_flag=True, default=False,
219225
help='Verbose logging.')
220226
@click.option('--input-audio-file', '-i',
@@ -252,7 +258,7 @@ def gen_converse_requests(self):
252258
help='gRPC deadline in seconds')
253259
@click.option('--once', default=False, is_flag=True,
254260
help='Force termination after a single conversation.')
255-
def main(api_endpoint, credentials, device_id, verbose,
261+
def main(api_endpoint, credentials, device_model_id, device_id, verbose,
256262
input_audio_file, output_audio_file,
257263
audio_sample_rate, audio_sample_width,
258264
audio_iter_size, audio_block_size, audio_flush_size,
@@ -342,7 +348,7 @@ def onoff(on):
342348
else:
343349
logging.info('Turning device off')
344350

345-
with SampleAssistant(device_id, conversation_stream,
351+
with SampleAssistant(device_model_id, device_id, conversation_stream,
346352
grpc_channel, grpc_deadline,
347353
device_handler) as assistant:
348354
# If file arguments are supplied:

google-assistant-sdk/nox.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def migrate_credentials(old, new):
6868
temp_dir = tempfile.mkdtemp()
6969
audio_out_file = os.path.join(temp_dir, 'out.raw')
7070
session.run('python', '-m', 'googlesamples.assistant.grpc.pushtotalk',
71+
'--device-model-id', 'test-device-model',
7172
'--device-id', 'test-device',
7273
'-i', 'tests/data/whattimeisit.riff',
7374
'-o', audio_out_file)

0 commit comments

Comments
 (0)