Git Product home page Git Product logo

google-assistant-hotword-raspi's Introduction

google-assistant-hotword-raspi

Simple Google Assistant with hotword activation from Snowboy setup for RaspberryPi 1 and Zero W.

Setup

  • Configure a Developer Project and Account Settings
  • Configure and Test the Audio
  • Setup virtual environment
    -   (Recommended) For Python 3:
    
        sudo apt-get update
        sudo apt-get install python3-dev python3-venv
        python3 -m venv env
        env/bin/python -m pip install pip setuptools --upgrade
        source env/bin/activate
    
    -   For Python 2:
    
        sudo apt-get update
        sudo apt-get install python-dev python-virtualenv
        virtualenv env --no-site-packages
        env/bin/pip install pip setuptools --upgrade
        source env/bin/activate
    
  • Install dependencies sudo apt-get install portaudio19-dev libffi-dev libssl-dev
  • Install Google Assistant SDK + Samples python -m pip install google-assistant-sdk[samples]
  • Get credentials 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
  • Test using the sample python -m googlesamples.assistant Issue commands after pressing enter and if you did all the steps above Google Assistant should respond.

PS On Raspberry Pi Zero W this setup takes about 30-40 minutes.

  • (Optional - The required files are already in this repo) Download Snowboy compiled library for all versions of Pi + demo
  • Install dependencies sudo apt-get install python-pyaudio python3-pyaudio sox
  • Install BLAS sudo apt-get install libatlas-base-dev
  • Install PyAudio pip install pyaudio You should be able to recored audio using: rec temp.wav

PS For Python 3 rename _snowboydetect.so_py3 to _snowboydetect.so.

Train your own hotwords or download existing ones from https://snowboy.kitt.ai/

3. Run gassistant.py and you should have a working Google Assistant with hotword activation

`python gassistant.py models/ok_google.pmdl`

google-assistant-hotword-raspi's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

google-assistant-hotword-raspi's Issues

AttributeError using python3

Hello, when i use

python gassistant.py models/ok_google.pmdl
I get:
AttributeError: module 'google.assistant.embedded.v1alpha1.embedded_assistant_pb2' has no attribute 'EmbeddedAssistantStub'
PS: i had to install libpython3.4

AttributeError: module 'google.assistant.embedded.v1alpha1.embedded_assistant_pb2' has no attribute 'EmbeddedAssistantStub'

When I run the gassistant.py file I just get

Traceback (most recent call last):
  File "gassistant.py", line 33, in <module>
    assistant = Assistant()
  File "/home/pi/Hotwordy/assistant.py", line 84, in __init__
    self.assistant = embedded_assistant_pb2.EmbeddedAssistantStub(self.grpc_channel)
AttributeError: module 'google.assistant.embedded.v1alpha1.embedded_assistant_pb2' has no attribute 'EmbeddedAssistantStub'

Do you have any idea why this happens?

cannot import name assistant_helpers

After I ran gassistant.py I got the following error. Any suggestion?
I ran it on Pi Zero W, python 2.7.9

Traceback (most recent call last):
  File "gassistant.py", line 6, in <module>
    from assistant import Assistant
  File "/home/pi/google-assistant-hotword-raspi-master/assistant.py", line 9, in <module>
    from googlesamples.assistant import (
ImportError: cannot import name assistant_helpers

Sudo command not recognized ?

when i try to execute the command "sudo apt-get install portaudio19-dev libffi-dev libssl-dev"
it says Sudo command not recognized as an internal or external command,
image
any help ?

ImportError: dynamic module does not define init function (PyInit__snowboydetect)

(env) pi@raspberrypi:~/google-assistant-hotword-raspi $ python gassistant.py models/ok_google.pmdl

I run on my raspberry pi 2 , but get this error

(env) pi@raspberrypi:~/google-assistant-hotword-raspi $ python gassistant.py models/ok_google.pmdl
Traceback (most recent call last):
  File "/home/pi/google-assistant-hotword-raspi/snowboydetect.py", line 18, in swig_import_helper
    return importlib.import_module(mname)
  File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
  File "<frozen importlib._bootstrap>", line 539, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1715, in load_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
ImportError: dynamic module does not define init function (PyInit__snowboydetect)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "gassistant.py", line 1, in <module>
    import snowboydecoder
  File "/home/pi/google-assistant-hotword-raspi/snowboydecoder.py", line 5, in <module>
    import snowboydetect
  File "/home/pi/google-assistant-hotword-raspi/snowboydetect.py", line 21, in <module>
    _snowboydetect = swig_import_helper()
  File "/home/pi/google-assistant-hotword-raspi/snowboydetect.py", line 20, in swig_import_helper
    return importlib.import_module('_snowboydetect')
  File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: dynamic module does not define init function (PyInit__snowboydetect)

Where is the token

`ERROR (ReadToken():snowboy-io.cc:131) Fail to read token in ReadToken(), position -1
terminate called after throwing an instance of 'std::runtime_error'
what(): ERROR (ReadToken():snowboy-io.cc:131) Fail to read token in ReadToken(), position -1

[stack trace: ]
./_snowboydetect.so(_ZN7snowboy13GetStackTraceEv+0x34) [0xb637bb40]
./_snowboydetect.so(_ZN7snowboy13SnowboyLogMsgD1Ev+0x4b8) [0xb637c180]
./_snowboydetect.so(_ZN7snowboy9ReadTokenEbPSsPSi+0x12c) [0xb637e1d4]
./_snowboydetect.so(ZN7snowboy14PipelineDetect14ClassifyModelsERKSsPSsS3+0x20c) [0xb636fb34]
./_snowboydetect.so(_ZN7snowboy14PipelineDetect8SetModelERKSs+0x158) [0xb6370020]
./_snowboydetect.so(ZN7snowboy13SnowboyDetectC1ERKSsS2+0x88) [0xb6365ec8]
./_snowboydetect.so(+0x1ad18) [0xb6362d18]

Aborted`

gassistant.py fails on Pi Zero

python gassistant.py models/ok_google.pmdl results in error
"Illegal instruction". I suspect this is due to the update to the latest SDK wich does not support ARMv6.

Can anyone verify this?
If so, can we fix this, or at least give a hint in the readme that this will not work for the Pi Zero/W

feature request

Hey, not an issue parse but anyway you can add triggers for GPIO control.

example 1 "Google, turn on LED" and it connects to GPIO that has the LED?
example 2 "Google, open switch" and it turns the servo on given GPIO

Any updates for latest SDK?

The latest SDK has hotword function build in, so we wouldn't need Snowboy anymore.

Will there be any update for this?

Error: No module named googlesamples.assistant.__main__

When trying to run a command
python -m googlesamples.assistant

I get error
/home/pi/env/bin/python: No module named googlesamples.assistant.main; 'googlesamples.assistant' is a package and cannot be directly executed

Any advice please?

no module named googlesamples

Hello, I tried to run your project but I think that something has changed in the Google SDK system.
When I try to run a sample I receive the following error:

/usr/bin/python: No module named googlesamples.assistant.auth_helpers

Is there any solution?

Thank you for the attention

Add a license

Hello,

I was looking at your project and I found it really cool!

I was thinking about using it in the Pirate Radio from Pimoroni, but I noticed that you don't have a license in the repo? Would you mind adding one?

It's really quick and easy :)

Thanks!

Missing argument in assistant.py in call to audio_helpers.ConversationStream

It should be corrected from this:

    self.conversation_stream = audio_helpers.ConversationStream(
        source=self.audio_source,
        sink=self.audio_sink,
        iter_size=self.audio_iter_size,
    )

to this:

    self.conversation_stream = audio_helpers.ConversationStream(
        source=self.audio_source,
        sink=self.audio_sink,
        iter_size=self.audio_iter_size,
        sample_width=self.audio_sample_width
    )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.