How to install Google assistant on raspberry pi, also known as google home. this is a early adoption of inter grading google home to our raspberry pi, more tutorials will follow soon. thanks for the view!!
This Method is depreciated, please check this post for updated release
Requirements:
USB Microphone ► http://amzn.to/2qCx4zY
Raspberry Pi 3 ► http://amzn.to/2oquADd
websites:
developer console
https://console.cloud.google.com/cloud-resource-manager
google assistant tutoral
command line:
sudo apt-get install python3-dev python3-venv
sudo apt-get install portaudio19-dev libffi-dev libssl-dev
python3 -m venv env env/bin/python -m pip install pip
setuptools --upgrade source env/bin/activate
python -m pip install google-assistant-sdk[samples]
python -m googlesamples.assistant
When I run “env/bin/python -m pip install pip setuptools –upgrade” i get following error:
Exception:
Traceback (most recent call last):
File “/home/pi/env/lib/python3.4/site-packages/pip/basecommand.py”, line 122, in main
status = self.run(options, args)
File “/home/pi/env/lib/python3.4/site-packages/pip/commands/install.py”, line 269, in run
InstallRequirement.from_line(name, None))
File “/home/pi/env/lib/python3.4/site-packages/pip/req.py”, line 173, in from_line
return cls(req, comes_from, url=url, prereleases=prereleases)
File “/home/pi/env/lib/python3.4/site-packages/pip/req.py”, line 71, in __init__
req = pkg_resources.Requirement.parse(req)
File “/home/pi/env/lib/python-wheels/setuptools-5.5.1-py2.py3-none-any.whl/pkg_resources.py”, line 2793, in parse
reqs = list(parse_requirements(s))
File “/home/pi/env/lib/python-wheels/setuptools-5.5.1-py2.py3-none-any.whl/pkg_resources.py”, line 2708, in parse_requirements
raise ValueError(“Missing distribution spec”, line)
ValueError: (‘Missing distribution spec’, ‘–upgrade’)
Storing debug log for failure in /home/pi/.pip/pip.log
any help?
same problem i use the script in the video instead i had encountered error on the
“python -m pip install google-assistant-sdk[samples]”
Failed building wheel for grpcio
Command “/usr/bin/python -u -c “import setuptools, tokenize;__file__=’/tmp/pip-build-zzQ9Ir/grpcio/setup.py’;f=getattr(tokenize, ‘open’, open)(__file__);code=f.read().replace(‘\r\n’, ‘\n’);f.close();exec(compile(code, __file__, ‘exec’))” install –record /tmp/pip-HCBc9x-record/install-record.txt –single-version-externally-managed –compile” failed with error code 1 in /tmp/pip-build-zzQ9Ir/grpcio/
There’s an error in the line with the hyphens
I recommend you type out the entire line, making sure there are two hyphens “–” before upgrade.
env/bin/pip install pip setuptools –upgrade
env/bin/pip install pip setuptools –upgrade
use this command
When I run the last command, my terminal shows this and it won’t work:
INFO:root:Connecting to embeddedassistant.googleapis.com
Traceback (most recent call last):
File “/usr/lib/python3.4/runpy.py”, line 170, in _run_module_as_main
“__main__”, mod_spec)
File “/usr/lib/python3.4/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/home/pi/env/lib/python3.4/site-packages/googlesamples/assistant/__main__.py”, line 320, in
main()
File “/home/pi/env/lib/python3.4/site-packages/click/core.py”, line 722, in __call__
return self.main(*args, **kwargs)
File “/home/pi/env/lib/python3.4/site-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/home/pi/env/lib/python3.4/site-packages/click/core.py”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/pi/env/lib/python3.4/site-packages/click/core.py”, line 535, in invoke
return callback(*args, **kwargs)
File “/home/pi/env/lib/python3.4/site-packages/googlesamples/assistant/__main__.py”, line 272, in main
flush_size=audio_flush_size
File “/home/pi/env/lib/python3.4/site-packages/googlesamples/assistant/audio_helpers/__init__.py”, line 179, in __init__
blocksize=int(block_size/2), # blocksize is in number of frames.
File “/home/pi/env/lib/python3.4/site-packages/sounddevice.py”, line 1491, in __init__
**_remove_self(locals()))
File “/home/pi/env/lib/python3.4/site-packages/sounddevice.py”, line 918, in __init__
samplerate)
File “/home/pi/env/lib/python3.4/site-packages/sounddevice.py”, line 2598, in _get_stream_parameters
info = query_devices(device)
File “/home/pi/env/lib/python3.4/site-packages/sounddevice.py”, line 725, in query_devices
raise PortAudioError(‘Error querying device {0}’.format(device))
sounddevice.PortAudioError: Error querying device -1
Even if I run the same command again and again, it won’t work 🙁
The command “env/bin/python -m pip setuptools –upgrade” is wrong. If you look at what is actually typed in the video it is “env/bin/pip install setuptools –upgrade”. Correcting the step to that worked for me.
env/bin/python -m pip install pip setuptools –upgrade do not copy that!! onlu write manualy
env/bin/python -m pip install pip setuptools –upgrade this causes an error. I copied it straight from your description I think you meant to type:
env/bin/python -m pip install pip setuptools –-upgrade please correct your description.
when i run this command ( python -m pip install google-assistant-sdk[samples] ) i get error
Exception:
Traceback (most recent call last):
File “/home/pi/env/lib/python3.4/site-packages/pip/basecommand.py”, line 215, in main
status = self.run(options, args)
File “/home/pi/env/lib/python3.4/site-packages/pip/commands/install.py”, line 342, in run
prefix=options.prefix_path,
File “/home/pi/env/lib/python3.4/site-packages/pip/req/req_set.py”, line 784, in install
**kwargs
File “/home/pi/env/lib/python3.4/site-packages/pip/req/req_install.py”, line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File “/home/pi/env/lib/python3.4/site-packages/pip/req/req_install.py”, line 1064, in move_wheel_files
isolated=self.isolated,
File “/home/pi/env/lib/python3.4/site-packages/pip/wheel.py”, line 345, in move_wheel_files
clobber(source, lib_dir, True)
File “/home/pi/env/lib/python3.4/site-packages/pip/wheel.py”, line 323, in clobber
shutil.copyfile(srcfile, destfile)
File “/usr/lib/python3.4/shutil.py”, line 108, in copyfile
with open(dst, ‘wb’) as fdst:
PermissionError: [Errno 13] Permission denied: ‘/home/pi/env/lib/python3.4/site-packages/__pycache__/sounddevice.cpython-34.pyc’
encountered this error on the last script
python -m googlesamples.assistant
INFO:root:Connecting to embeddedassistant.googleapis.com
Traceback (most recent call last):
File “/usr/lib/python3.4/runpy.py”, line 170, in _run_module_as_main
“__main__”, mod_spec)
File “/usr/lib/python3.4/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/home/pi/env/lib/python3.4/site-packages/googlesamples/assistant/__main__.py”, line 320, in
main()
File “/home/pi/env/lib/python3.4/site-packages/click/core.py”, line 722, in __call__
return self.main(*args, **kwargs)
File “/home/pi/env/lib/python3.4/site-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/home/pi/env/lib/python3.4/site-packages/click/core.py”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/pi/env/lib/python3.4/site-packages/click/core.py”, line 535, in invoke
return callback(*args, **kwargs)
File “/home/pi/env/lib/python3.4/site-packages/googlesamples/assistant/__main__.py”, line 272, in main
flush_size=audio_flush_size
File “/home/pi/env/lib/python3.4/site-packages/googlesamples/assistant/audio_helpers/__init__.py”, line 179, in __init__
blocksize=int(block_size/2), # blocksize is in number of frames.
File “/home/pi/env/lib/python3.4/site-packages/sounddevice.py”, line 1491, in __init__
**_remove_self(locals()))
File “/home/pi/env/lib/python3.4/site-packages/sounddevice.py”, line 1017, in __init__
‘Error opening {0}’.format(self.__class__.__name__))
File “/home/pi/env/lib/python3.4/site-packages/sounddevice.py”, line 2671, in _check
raise PortAudioError(msg)
sounddevice.PortAudioError: Error opening RawStream: Invalid sample rate
Try to configure your audio device correctly, the manual as writen on
https://developers.google.com/assistant/sdk/prototype/getting-started-pi-python/configure-audio
change your card & device number of mic to 1,0 and speaker 0,0
I did follow the manual but I have the same issue
Adjust the configuration for your speaker and microphone
test your configuration with this 2 commands
(env) pi @ MagicMirror: ~ $ arecord –format = S16_LE –duration = 5 –rate = 16000 –file-type = raw out.raw
you will see this ::
Recording raw data ‘out.raw’: Signed 16 bit Little Endian, Rate 16000 Hz, Mono
(env) pi @ MagicMirror: ~ $ aplay –format = S16_LE –rate = 16000 out.raw
Playing raw data ‘out.raw’: Signed 16 bit Little Endian, Rate 16000 Hz, Mono
if you understand what you record then it means that it will work
# sudo reboot
# source env / bin / activate
and try again
googlesamples-assistant-pushtotalk –project-id mmm-test –device-model-id mmm-test-idetc..
I have tested the audio using these commands but I am still unable to get the assistant to work.
Excellent tutorial.
However Same error messages as above on the last command.
If you get around to resolving I’d be keen to know.
this is awesome. i had a few issues getting the mic setup but the instructions linked in these comments helped. updating .asoundrc in /home/pi got it for me.
now i’m just having an issue with the sound cutting in and out on playback.
when running
python -m googlesamples.assistant.auth_helpers –client_secrets /home/pi/Downloads/client_secret_”blah blah blah”apps.googleusercontent.com.json
I get and error message
home/pi/env/bin/python: No module named googlesamples.assistant.auth_helpers
(env)
All installs of packages and such seemed to work with no errors. Any thoughts?
I found something helpful on stack overflow. Seems google changed up some things in the 10 days since the last comments. here is a link https://stackoverflow.com/questions/44056237/google-assistant-no-module-named-googles
yup they did, i just released a new video on that, which includes voice activiation
Hi Novaspirit,
I could not fix this issue same solution. Did you do something different . What did you paste at the terminal?
Thanks
Hello, I fixed my first question. But Now I got a new message. Where is “Enter the authorization code: ” Where can I find it.
Authorization code is attached in the link. link is attached just one line above the code entering lines. When you typed that line, there will be attached a link. That link contains code.
when i am running
pi@raspberrypi:~ $ sudo python -m googlesamples.assistant
its gives
/usr/bin/python: No module named googlesamples
what to do now rest everything goes fine in my case
If this “pi@raspberrypi:~ $ sudo python -m googlesamples.assistant” is a cut and paste from you terminal window it does not look like you have initiated the python environment the was in the instructions.
Do you have an idea this error message?
/home/pi/env/bin/python: Error while finding spec for ‘googlesamples.assistant’ (: googlesamples.assistant.__spec__ is None)
same error here… looks like something related to path or env… or google changed something !
Same here, doesn’t work!
same here
Hey guys
I’m encountering this error:
(env) pi@raspberrypi:~ $ python -m googlesamples.assistant/home/pi/env/bin/python: Error while finding spec for ‘googlesamples.assistant’ (: googlesamples.assistant.__spec__ is None)
What’s going on here?
I had same problems,you should type all of the codes from the beginning (do not copy even one of them)
On the last line of code it simply says: /home/pi/env/bin/python: No module named googlesamples.assistant.auth_helpers. Can anybody help me with this? I have repeated the process many times in different ways to change it but it always comes up with this.
Same here
Same here. ( /home/pi/env/bin/python: No module named googlesamples.assistant.auth_helpers)
you need to install oauth: pip install oauthlib
greetz 🙂
Google changed the way to get token, please use this method to get the token.
pip install –upgrade google-auth-oauthlib[tool]
google-oauthlib-tool –client-secrets path/to/client_secret_XXXXX.json –scope https://www.googleapis.com/auth/assistant-sdk-prototype –save –headless
After a long time & having many problems with google assistant project & searching a lot (because I’m a immature) finally I can install it on raspberry pi3 by following this steps :
1) Sudo apt-get install python3-dev python3-venv
2) Sudo apt-get install portaudio19-dev libffi-dev libssl-dev
3) python3 -m venv env
4) env/bin/pip install setuptools –upgrade
5) source env/bin/activate
6) python3 -m pip install google-assistant-sdk[samples]
7) pip install –upgrade google-auth-oauthlib[tool]
8) google-oauthlib-tool –client-secrets path/to/client_secret_XXXXX.json –scope https://www.googleapis.com/auth/assistant-sdk-prototype –save –headless
9) editting /home/pi/.asoundrc (pi@raspberrypi:~ $ nano /home/pi/.asoundrc) like following :
pcm.!default {
type asym
capture.pcm “usb_mic”
playback.pcm “jack_speaker”
}
pcm.usb_mic {
type plug
slave {
pcm “hw:1,0”
}
}
pcm.jack_speaker {
type plug
slave {
pcm “hw:0,0”
}
}
10) googlesamples-assistant-pushtotalk
Hi,..
Already follow the instruction, but after google-assistant-demo i got this error
E0827 23:50:45.125859138 2539 handshake.c:128] Security handshake failed: {“created”:”@1503877845.125705649″,”description”:”Handshake read failed”,”file”:”../../third_party/grpc/src/core/lib/security/transport/handshake.c”,”file_line”:237,”referenced_errors”:[{“created”:”@1503877845.125687367″,”description”:”FD shutdown”,”file”:”../../third_party/grpc/src/core/lib/iomgr/ev_epoll_linux.c”,”file_line”:1045}]}
Dani, did you ever find solution for this “Security handshake failed” problem?
I have noticed you don’t monetize your blog, don’t waste your traffic, you can earn additional cash
every month because you’ve got hi quality content.
If you want to know how to make extra $$$, search for: Mertiso’s tips best adsense alternative
hy
i followed all the steps and get now:
Error: invalid_scope
after i followed the link,
is this tutorial outdated (02/2018) and i should have installed an other library ? but the update cmd should fix that ?
in detail google returns:
Some requested scopes were invalid. {invalid=[https://www.google.com/auth/assistant-sdk-prototype]}
can sb help me ?
i am getting this error
No module named googlesamples.assistant.__main__; ‘googlesamples.assistant’ is a package and cannot be directly executed
any one help me to solve this
I typed the following to get to the activation website:
(env) pi@raspberrypi:~/env/bin $
$pip install google-auth-oauthlib[tool]
$pip install google-oauthlib-tool
$python3 google-oauthlib-tool –client-secrets /home/pi/Desktop/client_secret_XXXX.apps.googleusercontent.com.json –scope https://www.googleapis.com/auth/assistant-sdk-prototype
I have noticed you don’t monetize your website,
don’t waste your traffic, you can earn additional bucks every month.
You can use the best adsense alternative for any type of website (they approve
all websites), for more info simply search in gooogle: boorfe’s tips monetize your website
Definitely believe that that you said. Your favourite justification appeared
to be at the web the easiest factor to have in mind of.
I say to you, I certainly get irked even as other folks think about issues that they plainly do not recognise about.
You managed to hit the nail upon the highest as well
as defined out the whole thing with no need side-effects ,
other people can take a signal. Will likely be back to get more.
Thank you
You forgot to add how to config the audio and sound
Hey, awesome thing to read! get some free followers