วันจันทร์ที่ 18 ธันวาคม พ.ศ. 2560

Google Assistant with Raspberry Pi





Google Assistant with Raspberry Pi

What is Google Assistant?

Google Assistant is Google’s voice assistant, which grew out of Google Now, and is available on a range of recent Android devices and now the iPhone

You can use Google Assistant to trigger apps and devices, ask all kinds of questions, make plans, and carry out a variety of useful tasks. If you’re new to the voice assistant, it may be difficult to figure out just how it works. Lucky for you, we can help! If you’re currently wondering, “what is Google Assistant anyway?” or “how can I use all this stuff with OK Google?” then read on to get started.

So,we 'll use Google Assistant on Raspberry Pi.

Hardware

1. Raspberry Pi Board model 3B and accessories
2. Speaker and Amplifier with Speaker
3. USB Microphone



Set Google Assistant API

Open Browser in Pi and go to: https://console.cloud.google.com/cloud-resource-manager

Create Project



New Project
Add your Project name. then Create.



Dashboard
Your Project detail.



Enable API
Go to API  ( APIs & services ) then Dashboard




Then ENABLE APIs and Services




Search "google assistant"




Click ENABLE



Create credentials



Go to OAuth consent screen




Then Download your credential id. ( JSON File )
We will use this file on Raspberry pi.
Then copy this file to raspberry pi.




How to Setup on Raspberry Pi

Install python virtual environment


$  sudo apt-get install python3-dev python3-venv


Download Dependencies

$  sudo apt-get install portaudio19-dev libffi-dev libssl-dev


Setup Python3

$  python3 -m venv env
$  env/bin/pip install setuptools --upgrade


set the virtual environment

$  source env/bin/activate 


Install Google Assistant SDK

$  python -m pip install google-assistant-sdk[samples]


Updated SDK for newest version

$  pip install --upgrade google-auth-oauthlib[tool]


Setup Google Assistant SDK with Credentials

$  google-oauthlib-tool --client-secrets /home/pi/Downloads/client_secret_XXXXX.json --scope https://www.googleapis.com/auth/assistant-sdk-prototype --save --headless

Need your credential file form Credential Setup page.
Then you have link to Google Permission Page



Run Google Assistant

$  googlesamples-assistant-pushtotalk



Enjoy your Google Assistant on Raspberry Pi.

see on Youtube

Reference

https://www.novaspirit.com/17SSm

https://www.raspberrypi.org/forums/viewtopic.php?t=188958

https://www.hackster.io/Salmanfarisvp/googlepi-google-assistant-on-raspberry-pi-9f3677



My Website
email : info@softpowergroup.net  ,amphancm@gmail.com  Tel .+6681-6452400

Android and Arduino IoT



LINE : adunfong
FaceBook : https://www.facebook.com/adun.nantakaew
email: amphancm@gmail.com

2 ความคิดเห็น:

  1. This issue. Please help....

    $ googlesamples-assistant-pushtotalk
    INFO:root:Connecting to embeddedassistant.googleapis.com
    Traceback (most recent call last):
    File "/home/pi/env/bin/googlesamples-assistant-pushtotalk", line 11, in
    sys.exit(main())
    File "/home/pi/env/lib/python3.5/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
    File "/home/pi/env/lib/python3.5/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
    File "/home/pi/env/lib/python3.5/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    File "/home/pi/env/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
    File "/home/pi/env/lib/python3.5/site-packages/googlesamples/assistant/grpc/pushtotalk.py", line 332, in main
    flush_size=audio_flush_size
    File "/home/pi/env/lib/python3.5/site-packages/googlesamples/assistant/grpc/audio_helpers.py", line 187, in __init__
    blocksize=int(block_size/2), # blocksize is in number of frames.
    File "/home/pi/env/lib/python3.5/site-packages/sounddevice.py", line 1256, in __init__
    **_remove_self(locals()))
    File "/home/pi/env/lib/python3.5/site-packages/sounddevice.py", line 673, in __init__
    samplerate)
    File "/home/pi/env/lib/python3.5/site-packages/sounddevice.py", line 2481, in _get_stream_parameters
    info = query_devices(device)
    File "/home/pi/env/lib/python3.5/site-packages/sounddevice.py", line 480, in query_devices
    raise PortAudioError('Error querying device {0}'.format(device))
    sounddevice.PortAudioError: Error querying device -1

    ตอบลบ