Build Google Assistant on Raspberry Pi With ReSpeaker Mic Array

About: Howdy, we are application engineers in Seeed. Sharing projects with maker community is awesome. Hope you like it XD Seeed is the IoT hardware enabler providing services that empower IoT developers to swiftl...

Introduction

With ReSpeaker Mic Array, now we can build Google Assistant on Raspberry Pi !!!

Hotword detection(means that you can directly talk to it from 2 meters away), cool LEDs(diy) and easy installation(no jump wire need and more portable), it is worthy for you to make one for yourself. Own your own Artificial intelligence assistant from now on:)

Step 1: What We Need

Raspberry Pi(with network connected) *1
Respeaker Mic Array with audio jack *1

sd card with raspberry pi image *1

earphone or speaker with 3.5mm audio cable *1

usb cable *2

PC or Mac

Step 2: Install Google Assistant Library on Your Raspberry Pi

The first step we need to do is installing the Google Assistant Library and environment on our Raspberry Pi. Of course Google has an official guide, please click here to see it: https://github.com/googlesamples/assistant-sdk-py...

This step is a bit tough, so please be patient. If you have any questions, please search or post an issue here: https://github.com/googlesamples/assistant-sdk-py...

After the first step, you should be able to use “OK Google” by running the demo.

Step 3: Download Our GitHub

At this step, you need to download our GitHub:

git clone https://github.com/respeaker/mic_array.git

cd mic_array

Step 4: Test

1. Run pixel_ring.py to control the pixel ring of the Mic Array through USB HID. After running this, ReSpeaker Mic Array will start to blink.

sudo pip install pyusb
sudo python pixel_ring.py

If you don't want to access USB device with sudo, add a udev .rules file to /etc/udev/rules.d:

echo 'SUBSYSTEM=="usb", MODE="0666"' | sudo tee -a /etc/udev/rules.d/60-usb.rules
sudo udevadm control -R # then re-plug the usb device

2. Read 8 channels audio from the Mic Array and estimate sound's DOA. Then the LEDs on Mic Array will show the direction of the sounds.

sudo apt-get install python-numpy    # or pip install numpy
python mic_array.py

3. Do VAD and then estimate DOA. Then the LEDs on Mic Array will show the direction of the sounds, too.

sudo pip install webrtcvad
python vad_doa.py

4. Do KWS and then estimate DOA.

Get snowboy work and run python kws_doa.py. Then you should say “alexa” to Mic Array to wake it up, if you sound is detected, the LEDs will show the direction of the sounds.

git submodule init
git submodule update
cd snowboy/swig/Python
sudo apt-get install python-dev libatlas-base-dev swig # requiremetns to compile snowboy
echo 'from snowboydetect import *' > __init__.py # create __init__.py for a python module
cd ../../.. # chang to the root directory of the repository
ln -s snowboy/swig/Python snowboydetectpython kws_doa.py

Step 5: Run Google Assistant

After step3, it is time to run Google Assistant now. Don’t forget to activate the Python virtual environment you configured just now. And please make sure your raspberry pi is able to visit google.com

then run:

python google_assistant_for_raspberry_pi.py 

Say “OK Google” or “Hey Google” to wake it up and ask it anything you want, just as the video. Enjoy it!!

Share

    Recommendations

    • Plastics Contest

      Plastics Contest
    • Optics Contest

      Optics Contest
    • Make it Glow Contest 2018

      Make it Glow Contest 2018

    Discussions

    0
    None
    奕陞李

    1 year ago

    Sorry for bothering

    I recently have project about building Google Assistant on Raspberry Pi 3 with Respeaker Mic Array and Hamburger Mini Speaker.

    But when I ran the command: sudo python mic_array.py

    I got the error message down below:

    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.front.0:CARD=0'

    ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory

    ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory

    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM front

    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear

    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe

    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side

    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'

    ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory

    ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory

    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround21

    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'

    ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory

    ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory

    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround21

    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround40.0:CARD=0'

    ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory

    ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory

    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround40

    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'

    ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory

    ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory

    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround41

    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'

    ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory

    ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory

    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround50

    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'

    ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory

    ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory

    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround51

    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround71.0:CARD=0'

    ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory

    ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory

    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround71

    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'

    ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory

    ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory

    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM iec958

    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'

    ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory

    ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory

    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM spdif

    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'

    ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory

    ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory

    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM spdif

    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi

    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi

    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem

    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem

    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline

    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline

    ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

    ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

    connect(2) call to /tmp/jack-0/default/jack_0 failed (err=No such file or directory)

    attempt to connect to server failed

    (0, 'bcm2835 ALSA: - (hw:0,0)', 0L, 2L)

    (1, 'bcm2835 ALSA: IEC958/HDMI (hw:0,1)', 0L, 2L)

    (2, 'ReSpeaker Microphone Array: USB Audio (hw:1,0)', 8L, 2L)

    (3, 'sysdefault', 0L, 128L)

    (4, 'default', 0L, 128L)

    (5, 'dmix', 0L, 2L)

    Traceback (most recent call last):

    File "mic_array.py", line 187, in <module>

    test_8mic()

    File "mic_array.py", line 173, in test_8mic

    with MicArray(16000, 4, 16000 / 4) as mic:

    File "mic_array.py", line 42, in __init__

    raise Exception('can not find input device with {} channel(s)'.format(self.channels))

    Exception: can not find input device with 4 channel(s)

    I'm quite not understand this error message.

    What should I do to solve the problem?