Raspberry Pi 4 ReSpeaker Intelligent Speech Recognition 2 Microphone
Product Link
Introduction
The ReSpeaker 2-Mics Pi HAT is a Raspberry Pi dual microphone expansion board designed for AI and voice applications. This means you can build a more powerful and flexible voice product with integrated Amazona voice services and more.
The board is based on a low-power stereo codec developed on the WM8960. There are two microphones on either side of the board to capture sound, and it also provides three APA102 RGB LEDs, a user button, and two on-board Grove interfaces for expanding applications. In addition, either a 3.5mm audio jack or a JST 2.0 speaker output is available for audio output.
Features
Raspberry Pi compatible (supports Raspberry Pi Zero and Zero W, Raspberry Pi B +, Raspberry Pi 2 B and Raspberry Pi 3 B, Raspberry Pi 4 B, Raspberry Pi 3 B +)
2 Microphones
2 Grove interfaces
1 customizable button
3.5mm audio interface
JST2.0 audio output connector
Specifications
Pinout
Buttons: User-defined buttons connected to GPIO17
MIC_L & MIC_R: one microphone on the left and one on the right
RGB LEDs: 3 APA102 RGB LEDs connected to the Raspberry Pi's SPI interface
WM8960: Low-power stereo codec
Raspberry Pi 40-pin header: supports Raspberry Pi Zero, Raspberry Pi 1 B +, Raspberry Pi 2 B and Raspberry Pi 3 B
POWER: Micro USB port for powering the ReSpeaker 2-Mics Pi HAT, please power the board to provide enough current when using the speakers.
I2C: Grove I2C port, connects to I2C-1 GPIO12: Grove digital port, connects to GPIO12 and GPIO13
JST 2.0 SPEAKER OUT: For connecting to speakers, JST 2.0 connector
3.5mm AUDIO JACK: for connecting headphones or speakers with a 3.5mm audio plug
How to Use
System configuration and driver installation
Step 1 Insert ReSpeaker 2-Mics Pi HAT into Raspberry Pi
Insert the ReSpeaker 2-Mics Pi HAT into the Raspberry Pi, making sure the pins are aligned when inserting the Raspberry Pi.
!!!Note
Do not hot-swap the ReSpeaker 2-Mics Pi HAT while it is powered up.
step 2. burn system, log in, change source
Since the current Pi kernel does not currently support the wm8960 codec, we need to build it manually.
Make sure you are running the latest Raspbian operating system (debian 9) on your Pi, you can use etcher for system burn-in!
You can use VNC or PUTTY to connect to the Raspberry Pi, but please configure the wifi beforehand!
Before installing the driver, please switch the source to Tsinghua according to the following procedure.
sudo nano /etc/apt/sources.list
If you are commenting out the contents of the original file with #, replace it with the following:
deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib
!!!Note
If it is before 2019-06-20 you need to change `buster` to `Stretch` you can check when it was released by `cat /etc/rpi-issue`.
Step 3. Download and install the driver Run the following command
Step 1. Recording Test You can record with arecord and play it back with aplay: (don't forget to plug in headphones or speakers).
arecord -f cd -Dhw:1 | aplay -Dhw:1
It can also be tested by audacity software. After opening Audacity, select AC108 and 2 channels as inputs and bcm2835 alsa: - (hw: 0, 0) as outputs to test:
$ sudo apt update
$ sudo apt install audacity
$ audacity // be in motion audacity
Step 2. Adjust the volume (can be skipped)
alsamixer is a graphical mixer program for configuring sound settings and adjusting volume, Advanced Linux Sound Architecture (ALSA).
alsamixer
!!!Note
First of all, please use F6 to select seeed-2mic's sound card device.
The left and right arrow keys are used to select a channel or device, and the "up and down arrows" control the volume of the currently selected device. To exit the programme use ALT + Q or press Esc. More information
Each on-board APA102 LED has an additional driver chip which sets the colour of the LED and then maintains that colour until a new command is received.
There is a user-defined button on the top of the board that connects to GPIO17. We can call python and RPi.GPIO to read the state。
sudo pip install rpi.gpio // install RPi.GPIO library
nano button.py // copy the following code in button.py
import RPi.GPIO as GPIO
import time
BUTTON = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(BUTTON, GPIO.IN)
while True:
state = GPIO.input(BUTTON)
if state:
print("off")
else:
print("on")
time.sleep(1)
Save the code as button.py, then run it. It should display "on" when you press the button:
python button.py
off
off
on
on
off
FAQ
What should I do if the driver still fails to install even if I follow this wiki strictly?
If the installation of the driver fails according to the above methods, please click to download the following image (not applicable to 4 belts)
First, if you want to use the interactive functions, please enter alexa-auth or dueros-auth to request authorisation, after successful authorisation, it will generate a .avs.json file in the /home/pi directory, then you can use the interactive functions.
Secondly, there will be a folder of routines for respeaker in /home/pi directory, so you can use the routines according to the mic you are using. But please update the routines in the respeaker directory after burning the system, you can run git pull origin master command in the respeaker directory to update the routines.
#include "portaudio.h" Error when run "sudo pip install pyaudio".
At the command line, enter the following command
sudo apt-get install portaudio19-dev
Warning about installing snowboy with a warning that it is not suitable for the platform
Currently snowboy is only compatible with python2, so make sure it's python2 by installing a python virtual environment.
Sometimes there are dependency issues when sudo python file.py is used
When testing, I found that sudo executes from the system environment by default, and the dependencies used in the wiki are installed under ~/env, which can be solved with sudo ~/env/bin/python file.py.
Sound can be heard through the 3.5mm audio jack playback, but not when running ns_kws_doa_alexa_with_light.py
We have 3 players (mpv, mpg123 and gstreamer) available. mpg123 is more suitable for speech recognition and wakeup more, it is more responsive; while AudioPlayer is more suitable for gstreamer> mpv> mpg123. Gstreamer supports more audio formats and works well on raspberry pi. We can also specify the player for AudioPlayer using the environment variable PLAYER. So try the following command to enable voice *** Translated with www.DeepL.com/Translator (free version) ***。