X
    Categories: Projects

Google Assistant on Raspberry Pi

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

Voice Activated Google Assistant for Raspberry Pi

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

https://developers.google.com/assistant/sdk/prototype/getting-started-pi-python/config-dev-project-and-account

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

Voice Activated Google Assistant for Raspberry Pi

novaspirit: Avid Thinker, Computer Programmer, Web evangelist, Hacking / Breaking expert, Problem Solver, Technology Obsessed, Gamer, 3D printing, Coffee lover!

View Comments (47)

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

  • 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

        • 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?

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

Related Post