Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

Update to google-assistant-{library,grpc}==0.1.0 #207

Merged
merged 2 commits into from
Jan 4, 2018

Conversation

drigz
Copy link
Member

@drigz drigz commented Dec 22, 2017

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.

This doesn't update from v1alpha1 of the gRPC API to v1alpha2, which is
to follow.
@PeterMalkin
Copy link
Contributor

Actually I think we did update the library in this image: https://dl.google.com/dl/aiyprojects/vision/aiyprojects-2017-12-18.img.xz

@sheridat
Copy link

sheridat commented Dec 23, 2017

@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.

@sheridat
Copy link

@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.

@sheridat
Copy link

sheridat commented Dec 24, 2017

@PeterMalkin Just checked the install_deps.sh on the new image - code is

The google-assistant-library is only available on ARMv7.
if [[ "$(uname -m)" == "armv7l" ]] ; then
  env/bin/pip install google-assistant-library==0.0.3
fi



def _get_model_id(credentials, session, project_id):
model_id = "%s-%s" % (project_id, _DEVICE_MODEL)
Copy link
Member

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 :)

Copy link
Member Author

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 :)

}
r = session.post(_get_api_url(project_id, "deviceModels"),
data=json.dumps(payload))
if r.status_code == 409:
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

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))
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, thanks.

device_id = "%s-%06d" % (model_id, random.randrange(1000000))
payload = {
"id": device_id,
"model_id": model_id,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Member Author

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).

@@ -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)
Copy link
Member

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:
Copy link
Member

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?

Copy link
Member Author

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

@proppy
Copy link
Member

proppy commented Dec 26, 2017

@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.

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 DialogStateIn https://developers.google.com/assistant/sdk/reference/rpc/google.assistant.embedded.v1alpha2#google.assistant.embedded.v1alpha2.DialogStateIn

@tei-chino
Copy link

@proppy , as you said that I could not find how to to specify the language code for Google Assistant
Library in the document, the DialogStateIn is only available for Google Assistant Service, but [Release Notes] (https://developers.google.com/assistant/sdk/release-notes) said that Google Assistant Library has supported for more languages.

@proppy
Copy link
Member

proppy commented Dec 28, 2017

@tei-chino we recently published an update for the hotword sample that should allow you to set the language appropriatly.

See googlesamples/assistant-sdk-python#146 (comment) for more details. Let's move the discussion there if you encounter any other issues.

@ScriptAutomate
Copy link

@drigz I have also tested on an AIY Voice Kit, using your repo and upgrade-assistant branch. All of the demos work -- this includes the src/assistant_library_with_button_demo.py which does have one error when using Ctrl+c:

^CException ignored in: <module 'threading' from '/usr/lib/python3.5/threading.py'>
Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 1288, in _shutdown
    t.join()
  File "/usr/lib/python3.5/threading.py", line 1054, in join
    self._wait_for_tstate_lock()
  File "/usr/lib/python3.5/threading.py", line 1070, in _wait_for_tstate_lock
    elif lock.acquire(block, timeout):
KeyboardInterrupt

This is the only error I ran into. The other example files work without issue.

Device: Pi3
OS: Raspbian Stretch

@deviantony
Copy link

@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.

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 DialogStateIn https://developers.google.com/assistant/sdk/reference/rpc/google.assistant.embedded.v1alpha2#google.assistant.embedded.v1alpha2.DialogStateIn

I believe that
https://github.com/google/aiyprojects-raspbian/blob/voicekit/src/aiy/_apis/_speech.py should be updated to use google.assistant.embedded.v1alpha2 instead of google.assistant.embedded.v1alpha1 in order to specify the language to use.

@tei-chino
Copy link

@proppy, 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 DialogStateIn https://developers.google.com/assistant/sdk/reference/rpc/google.assistant.embedded.v1alpha2#google.assistant.embedded.v1alpha2.DialogStateIn

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.

@tei-chino
Copy link

@deviantony I believe that
https://github.com/google/aiyprojects-raspbian/blob/voicekit/src/aiy/_apis/_speech.py should be updated to use google.assistant.embedded.v1alpha2 instead of google.assistant.embedded.v1alpha1 in order to specify the language to use.

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.

@deviantony
Copy link

deviantony commented Jan 2, 2018

@tei-chino I'm talking about the AssistantSpeechRequest class (https://github.com/google/aiyprojects-raspbian/blob/voicekit/src/aiy/_apis/_speech.py#L359) which I believe is related to Google Assistant.

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

This doesn't update from v1alpha1 of the gRPC API to v1alpha2

So probably not the good place to discuss this.

@drigz drigz mentioned this pull request Jan 3, 2018
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 pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants