Aiyprojects-raspbian: Error when executing src/examples/voice/assistant_grpc_demo.py

Created on 12 Dec 2019  ·  14Comments  ·  Source: google/aiyprojects-raspbian

newbie here Help!!! Tried Re enabling Assistant API and i tried installing AIY os again and again 3 times no luck

Traceback (most recent call last):
File "src/examples/voice/assistant_grpc_demo.py", line 57, in
main()
File "src/examples/voice/assistant_grpc_demo.py", line 49, in main
language_code=args.language)
File "/home/pi/AIY-projects-python/src/aiy/assistant/grpc.py", line 258, in __init__
super().__init__(language_code, volume_percentage)
File "/home/pi/AIY-projects-python/src/aiy/assistant/grpc.py", line 94, in __init__
credentials = auth_helpers.get_assistant_credentials()
File "/home/pi/AIY-projects-python/src/aiy/assistant/auth_helpers.py", line 151, in get_assistant_credentials
return _try_to_get_credentials(credentials_file)
File "/home/pi/AIY-projects-python/src/aiy/assistant/auth_helpers.py", line 123, in _try_to_get_credentials
credentials = _credentials_flow_interactive(client_secrets)
File "/home/pi/AIY-projects-python/src/aiy/assistant/auth_helpers.py", line 75, in _credentials_flow_interactive
webbrowser.register('chromium-browser', None, webbrowser.Chrome('chromium-browser'), -1)
TypeError: register() takes from 2 to 3 positional arguments but 4 were given

Most helpful comment

I fixed the error for my setup with the Raspberry Pi 3B with AIY Voice Kit v1. In the file "/home/pi/AIY-projects-python/src/aiy/assistant/auth_helpers.py", I changed the last argument in webbrowser.register() (line 75) from "-1" to "preferred=True".

Here is the documentation that explains the options for webbrowser.register(). It looks like in Python 3.7, the webbrowser.register() "preferred" argument only takes keywords now.

Here is the full, edited file. GitHub wouldn't let me upload the file directly, so the file is on Google Drive.

Or, if you just want to edit the code directly, here is the new code for line 75 in the file "/home/pi/AIY-projects-python/src/aiy/assistant/auth_helpers.py":
webbrowser.register('chromium-browser', None, webbrowser.Chrome('chromium-browser'), preferred=True)
(Make sure to leave the spaces from the original line of code in front of the new code segment as spacing matters in Python).

Please let me know if it works or not, or if you have any questions.

All 14 comments

@vishwapinnawala Which version of voice kit do you have ?
Have you reflashed the kit with the image provided at https://github.com/google/aiyprojects-raspbian/releases/tag/v20191113 ?

V2 yes i tried reflashing several times and nothing seems to work

I'm getting an identical error with voice kit v1. I also tried reflashing the image with no success.

I fixed the error for my setup with the Raspberry Pi 3B with AIY Voice Kit v1. In the file "/home/pi/AIY-projects-python/src/aiy/assistant/auth_helpers.py", I changed the last argument in webbrowser.register() (line 75) from "-1" to "preferred=True".

Here is the documentation that explains the options for webbrowser.register(). It looks like in Python 3.7, the webbrowser.register() "preferred" argument only takes keywords now.

Here is the full, edited file. GitHub wouldn't let me upload the file directly, so the file is on Google Drive.

Or, if you just want to edit the code directly, here is the new code for line 75 in the file "/home/pi/AIY-projects-python/src/aiy/assistant/auth_helpers.py":
webbrowser.register('chromium-browser', None, webbrowser.Chrome('chromium-browser'), preferred=True)
(Make sure to leave the spaces from the original line of code in front of the new code segment as spacing matters in Python).

Please let me know if it works or not, or if you have any questions.

The above solved the problem of opening the browser and authenticating the voice kit as it takes me to the web page that says the process is complete, but then the next time I do "assistant_grpc_demo.py" again, it just starts this authentication process all over again instead of starting up like it is supposed to. (I had it working before.) I am stuck at this point for now.

i've removed and got alexapi installed so i gived it up😁

On Thu, Dec 26, 2019 at 7:16 PM stevesss notifications@github.com wrote:

The above solved the problem of the browser not authenticating the voice
kit, but it just keeps opening the browser over and over again and never
starts working (like it used to when i installed it before)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/google/aiyprojects-raspbian/issues/658?email_source=notifications&email_token=AK6X6CL2MWYUVAEBM7ATCILQ2SYTNA5CNFSM4J2AQYR2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHVS7YA#issuecomment-569061344,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AK6X6CNM3Y64K6ZL4EXNNUTQ2SYTNANCNFSM4J2AQYRQ
.

The above solved the problem of opening the browser and authenticating the voice kit as it takes me to the web page that says the process is complete, but then the next time I do "assistant_grpc_demo.py" again, it just starts this authentication process all over again instead of starting up like it is supposed to. (I had it working before.) I am stuck at this point for now.

I'm sorry to hear that stevesss. I just reflashed the image, created a new Google Cloud project and edited the auth_helpers.py file without success in replicating your problem. What Raspberry Pi and Voice Kit version are you using? I know it is a long process, but you might want to try reflashing your image.

Editing auth_helpers.py solved it for me too. But I get a seg fault, once I did the authorisation in the browser.

I'm having the same issue as @d3acon

I get a segmentation fault as well for every file except "assistant_grpc_demo.py"

I opened a new ticket for the seg fault, as this one is for the python problem.

i had the same error
pleasw try this

I fixed the error for my setup with the Raspberry Pi 3B with AIY Voice Kit
v1. In the file
"/home/pi/AIY-projects-python/src/aiy/assistant/auth_helpers.py", I changed
the last argument in webbrowser.register() (line 75) from "-1" to
"preferred=True".

Here is the documentation
https://docs.python.org/3/library/webbrowser.html#webbrowser.register
that explains the options for webbrowser.register(). It looks like in
Python 3.7, the webbrowser.register() "preferred" argument only takes
keywords now.

edit the code directly, here is the new code for line 75 in the file
"/home/pi/AIY-projects-python/src/aiy/assistant/auth_helpers.py":

webbrowser.register('chromium-browser', None,
webbrowser.Chrome('chromium-browser'), preferred=True)

(Make sure to leave the spaces from the original line of code in front of
the new code segment as spacing matters in Python).

On Thu, 13 Feb, 2020, 3:23 PM D0wneyJr, notifications@github.com wrote:

Traceback (most recent call last):
File
"/home/pi/AIY-voice-kit-python/src/examples/voice/assistant_grpc_demo.py",
line 57, in
main()
File
"/home/pi/AIY-voice-kit-python/src/examples/voice/assistant_grpc_demo.py",
line 49, in main
language_code=args.language)
File "/home/pi/AIY-projects-python/src/aiy/assistant/grpc.py", line 258,
in init
super().init(language_code, volume_percentage)
File "/home/pi/AIY-projects-python/src/aiy/assistant/grpc.py", line 94, in
init
credentials = auth_helpers.get_assistant_credentials()
File "/home/pi/AIY-projects-python/src/aiy/assistant/auth_helpers.py",
line 151, in get_assistant_credentials
return _try_to_get_credentials(credentials_file)
File "/home/pi/AIY-projects-python/src/aiy/assistant/auth_helpers.py",
line 123, in _try_to_get_credentials
credentials = _credentials_flow_interactive(client_secrets)
File "/home/pi/AIY-projects-python/src/aiy/assistant/auth_helpers.py",
line 75, in _credentials_flow_interactive
webbrowser.register('chromium-browser', None,
webbrowser.Chrome('chromium-browser'), -1)
TypeError: register() takes from 2 to 3 positional arguments but 4 were
given

I am using raspberry pi 4


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/google/aiyprojects-raspbian/issues/658?email_source=notifications&email_token=AOPJUC7KD35URZ4GCUAKVGDRCUKA7A5CNFSM4J2AQYR2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELUDHKA#issuecomment-585642920,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AOPJUC6TIB64HRHNXA5OPYTRCUKA7ANCNFSM4J2AQYRQ
.

i have raspberry pi 4

On Thu, 13 Feb 2020 at 16:43, 2000prasanth notifications@github.com wrote:

i had the same error
pleasw try this

I fixed the error for my setup with the Raspberry Pi 3B with AIY Voice Kit
v1. In the file
"/home/pi/AIY-projects-python/src/aiy/assistant/auth_helpers.py", I changed
the last argument in webbrowser.register() (line 75) from "-1" to
"preferred=True".

Here is the documentation
https://docs.python.org/3/library/webbrowser.html#webbrowser.register
that explains the options for webbrowser.register(). It looks like in
Python 3.7, the webbrowser.register() "preferred" argument only takes
keywords now.

edit the code directly, here is the new code for line 75 in the file
"/home/pi/AIY-projects-python/src/aiy/assistant/auth_helpers.py":

webbrowser.register('chromium-browser', None,
webbrowser.Chrome('chromium-browser'), preferred=True)

(Make sure to leave the spaces from the original line of code in front of
the new code segment as spacing matters in Python).

On Thu, 13 Feb, 2020, 3:23 PM D0wneyJr, notifications@github.com wrote:

Traceback (most recent call last):
File

"/home/pi/AIY-voice-kit-python/src/examples/voice/assistant_grpc_demo.py",
line 57, in
main()
File

"/home/pi/AIY-voice-kit-python/src/examples/voice/assistant_grpc_demo.py",
line 49, in main
language_code=args.language)
File "/home/pi/AIY-projects-python/src/aiy/assistant/grpc.py", line 258,
in init
super().init(language_code, volume_percentage)
File "/home/pi/AIY-projects-python/src/aiy/assistant/grpc.py", line 94,
in
init
credentials = auth_helpers.get_assistant_credentials()
File "/home/pi/AIY-projects-python/src/aiy/assistant/auth_helpers.py",
line 151, in get_assistant_credentials
return _try_to_get_credentials(credentials_file)
File "/home/pi/AIY-projects-python/src/aiy/assistant/auth_helpers.py",
line 123, in _try_to_get_credentials
credentials = _credentials_flow_interactive(client_secrets)
File "/home/pi/AIY-projects-python/src/aiy/assistant/auth_helpers.py",
line 75, in _credentials_flow_interactive
webbrowser.register('chromium-browser', None,
webbrowser.Chrome('chromium-browser'), -1)
TypeError: register() takes from 2 to 3 positional arguments but 4 were
given

I am using raspberry pi 4


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<
https://github.com/google/aiyprojects-raspbian/issues/658?email_source=notifications&email_token=AOPJUC7KD35URZ4GCUAKVGDRCUKA7A5CNFSM4J2AQYR2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELUDHKA#issuecomment-585642920
,
or unsubscribe
<
https://github.com/notifications/unsubscribe-auth/AOPJUC6TIB64HRHNXA5OPYTRCUKA7ANCNFSM4J2AQYRQ

.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/google/aiyprojects-raspbian/issues/658?email_source=notifications&email_token=AITNN3CTA6UOE4MB6NVVU7TRCUTNPA5CNFSM4J2AQYR2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELULCYI#issuecomment-585675105,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AITNN3DKEYYIU6T5UISTCATRCUTNPANCNFSM4J2AQYRQ
.

Was this page helpful?
0 / 5 - 0 ratings