-
Notifications
You must be signed in to change notification settings - Fork 694
Update to google-assistant-{library,grpc}==0.1.0 #207
Conversation
This doesn't update from v1alpha1 of the gRPC API to v1alpha2, which is to follow.
Actually I think we did update the library in this image: https://dl.google.com/dl/aiyprojects/vision/aiyprojects-2017-12-18.img.xz |
@drigz I zip downloaded https://github.com/drigz/aiyprojects-raspbian/tree/upgrade-assistant and copied the changed files. Then ran sudo rm -rf env followed by scripts/install-deps.sh. Version 0.1.0 of the assistant was installed. Ran through all 3 amended assistant demo's and they all worked. Well done you. BUT the volume of the assistant's voice is barely a whisper. On the forum we have posts from people who have upgrade to the latest version of the assistant and are reporting the same problem https://www.raspberrypi.org/forums/viewtopic.php?f=114&t=200498 I turned my volume up to max and that made the assistant voice audible - but if you run a local command the TTS volume is speaker destroying. I will raise an issue at the assistant site and copy it through to here. |
@drigz It turns out that what you have to do is tell the assistant to turn up the volume to max by saying "Ok Google turn the volume up to maximum" I've closed the issue I raised at the assistant repo. |
@PeterMalkin Just checked the install_deps.sh on the new image - code is
|
|
||
|
||
def _get_model_id(credentials, session, project_id): | ||
model_id = "%s-%s" % (project_id, _DEVICE_MODEL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was smart to concatenate project_id in there! Since the model namespace is global (not per project) this ensure there will be no conflict :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not especially smart, I just followed the suggestion in the docs :)
src/aiy/assistant/device_helpers.py
Outdated
} | ||
r = session.post(_get_api_url(project_id, "deviceModels"), | ||
data=json.dumps(payload)) | ||
if r.status_code == 409: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you shouldn't need to "update" it unless you change the list of traits (which is already empty) for this type of device.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/aiy/assistant/device_helpers.py
Outdated
project_id = _get_project_id() | ||
model_id = model_id or _get_model_id(credentials, session, project_id) | ||
|
||
device_id = "%s-%06d" % (model_id, random.randrange(1000000)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use the uuid
package?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, thanks.
src/aiy/assistant/device_helpers.py
Outdated
device_id = "%s-%06d" % (model_id, random.randrange(1000000)) | ||
payload = { | ||
"id": device_id, | ||
"model_id": model_id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you also need to specific the client_type
(SDK_LIBRARY
or SDK_SERVICE
):
https://developers.google.com/assistant/sdk/reference/device-registration/model-and-instance-schemas#device_instance_json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I see in the docs, it looks like clientType
is Optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've specified it as SDK_SERVICE to stay on the safe side (the assistant library will create its own device with SDK_LIBRARY).
src/assistant_library_demo.py
Outdated
@@ -60,7 +61,8 @@ def process_event(event): | |||
|
|||
def main(): | |||
credentials = aiy.assistant.auth_helpers.get_assistant_credentials() | |||
with Assistant(credentials) as assistant: | |||
device_id, model_id = aiy.assistant.device_helpers.get_ids(credentials) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not that when using the google-assistant-library
it generates its own ID (and you have no way to pass another one).
@@ -90,7 +91,8 @@ def process_event(assistant, event): | |||
|
|||
def main(): | |||
credentials = aiy.assistant.auth_helpers.get_assistant_credentials() | |||
with Assistant(credentials) as assistant: | |||
device_id, model_id = aiy.assistant.device_helpers.get_ids(credentials) | |||
with Assistant(credentials, model_id) as assistant: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't you pass the device_id
there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you mean - this is using the library like the other examples. I'll use the device_id once I switch to v1alpha2
You should be able to change the language in the "settings" of the Assistant apps, when using the gRPC API you can pass it as a field of |
@proppy , as you said that I could not find how to to specify the language code for Google Assistant |
@tei-chino we recently published an update for the See googlesamples/assistant-sdk-python#146 (comment) for more details. Let's move the discussion there if you encounter any other issues. |
@drigz I have also tested on an AIY Voice Kit, using your repo and
This is the only error I ran into. The other example files work without issue. Device: Pi3 |
I believe that |
Thank for your information. I will invest that do see if it is possible to specify the language for aiy code. Would you like tell me it is any planning to update aiy code to specify the language. |
I think the _speech.py only can speak diffirent languages, we want to the Assistant to understand different language. This is a new function of v1alpha2, but the aiyprojects-raspbian project have not been updated yet to support that. |
@tei-chino I'm talking about the I think that https://developers.google.com/assistant/sdk/reference/rpc/google.assistant.embedded.v1alpha2#google.assistant.embedded.v1alpha2.DialogStateIn is related to the user request, so that would be where to specify the language used by the user to interact with the assistant. I'm pretty new to the codebase so I might be wrong tho. EDIT: As stated by OP
So probably not the good place to discuss this. |
Also, swap the ID order in the demos (as it was wrong) and import the right requests package rather than relying on other modules to import it.
This doesn't update from v1alpha1 of the gRPC API to v1alpha2, which is to follow, but appears to be mostly search-and-replace.
I've not yet tested this on the Voice Kit hardware (or even on a machine with a microphone - I only have access to a Chromebook right now). I'm concerned that upgrading the library breaks the button+library demo as reported in #204. However, that's separate to the Device / Model ID logic.
The Device ID is currently unused, but it may be required for the gRPC API, and would be required if we want to use Device Actions, so it makes sense to keep it.
@proppy, how can we specify the language? I can't see any way to specify it for the Google Assistant Library, and the gRPC docs still say only en-US is supported.