Skip to main content

ReSpeaker 6-Mic Circular Array Kit for Raspberry Pi

enter image description here

Seeed’s ReSpeaker 6-Mic Circular Array Kit is an extension board, aka HAT designed for Raspberry Pi. It's a circular microphone array kit, comes with six microphones and designed for AI and voice applications. That means you can build a more powerful and flexible voice product with Raspberry Pi which can integrate Amazon Alexa Voice Service, Google Assistant, and so on.

ReSpeaker 6-Mic Circular Array Kit for Raspberry Pi consists of two boards, one is voice accessory HAT, another is six microphones circular array.

ReSpeaker 6-Mic Circular Array Kit for Raspberry Pi support 8 input & 8 output channels in Raspbian system. The first 6 input channel for microphone recording, rest of 2 input channel are echo channel of playback. The first 2 output channel for playing, rest of 6 output channel are dummy.

Features

  • 2 ADC chips and 1 DAC chip
  • 8 input and 8 output channels
  • Six microphones array
  • Grove support
  • Raspberry Pi compatible(Support Raspberry Pi Zero and Zero W, Raspberry Pi B+, Raspberry Pi 2 B, Raspberry Pi 3 B, Raspberry Pi 3 B+, Raspberry Pi 3 A+ and Raspberry Pi 4)
  • Headset and speaker voice output

Specification

  • 2 x X-Power AC108 ADC
  • 6 x high performance microphones
  • 1 x X-Power AC101 DAC
  • Voice output:
    • 3.5mm headset audio jack
    • Speaker jack
  • Compatible with Raspberry Pi 40-pin headers
  • Microphones: MSM321A3729H9CP
  • Sensitivity: -22 dBFS (Omnidirectional)
  • SNR: 59 dB
  • Max Sample Rate: 48Khz

Applications

  • Smart speaker
  • Intelligent voice assistant systems
  • Voice recorders
  • Voice conferencing system
  • Meeting communicating equipment
  • Voice interacting robot
  • Car voice assistant
  • Other scenarios need voice command

Hardware Overview

System Diagram

Interface

note

After connecting, be sure to use a multimeter to determine if the conduction of the circuit is as indicated in the figure above.

Assembly Drawing

Getting Started

Hardware

Prerequisites

ReSpeaker 6-Mic Circular Array x1

Raspberry Pi 3B or 3B+ x1

Micro-USB Cable x1

PC x1

Earphone or Speaker x1

tip

Actually the ReSpeaker 6-Mic Circular Array support Raspberry Pi Zero, Raspberry Pi 1 B+, Raspberry Pi 2 B, Raspberry Pi 3 B, Raspberry Pi 3 model B+ , Raspberry Pi 3 A+ and Raspberry Pi 4 in this wiki we are using Raspberry Pi 3.

Connection

Step 1. Connect the ReSpeaker Voice Accessory HAT with ReSpeaker 6-Mic circular Array via the Ribbon Cable

Step 2. Plug the ReSpeaker Voice Accessory HAT into the Raspberry Pi via the 40 Pin GPIO

Step 3. Plug the earphone into the 3.5mm headset audio jack or plug the speaker into the JST 2.0 speaker jack

Step 4. Connect the Raspberry Pi with the PC via the micro-USB cable

Pics here

Software

Prerequisites

Plan A

PUTTY

You need to use Putty or other ssh tools to connect with your raspberry pi. Before started, please make sure:

1- Open ssh fuction of your pi to let the putty in. If you do not know how to open ssh, please google how to setup ssh raspberry pi

2- Your raspberry pi and your PC are working on the same WiFi net. If you do not know how to config WiFi, please google how to setup wifi raspberry pi

3- Get the ip address of your raspberry pi, if you do not know how to get the ip address please refer to raspberry offical documentation

4- Use the ip address to connect the raspberry pi with your PC via putty ssh serve.

pic

Then please tap the host name and the password. the default ID is pi and the password is raspberry.

login as: pi
[email protected]'s password:raspberry

Now you are in, and you can tap the command in putty and play with your raspberry.

VNC Viewer

To make this kit work with alexa or dueros, you need to open a web site to get the authorization. So you need to use VNC Viewer to log in your amazon or baidu account. So please make sure you have open the VNC service of your raspberry.

Or you can just consider plan B.

Plan B

If you are tired of all above, you can just use a HDMI Monitor and plug the USB Keyboard and USB mouse in to your raspberry, it works too, simple and easy.

Step 1. Install seeed-voicecard

Get the seeed voice card source code. and install all linux kernel drivers.

sudo apt-get update
sudo apt-get upgrade
git clone https://github.com/respeaker/seeed-voicecard.git
cd seeed-voicecard
sudo ./install.sh
sudo reboot

Step 2. Check the Sound Card

Tap the command below to check the record device.

pi@raspberrypi:~ $ arecord -L

It should be like:

pi@raspberrypi:~ $ arecord -L
null
Discard all samples (playback) or generate zero samples (capture)
default
ac108
dmixer
ac101
sysdefault:CARD=seeed8micvoicec
seeed-8mic-voicecard,
Default Audio Device
dmix:CARD=seeed8micvoicec,DEV=0
seeed-8mic-voicecard,
Direct sample mixing device
dsnoop:CARD=seeed8micvoicec,DEV=0
seeed-8mic-voicecard,
Direct sample snooping device
hw:CARD=seeed8micvoicec,DEV=0
seeed-8mic-voicecard,
Direct hardware device without any conversions
plughw:CARD=seeed8micvoicec,DEV=0
seeed-8mic-voicecard,
Hardware device with all software conversions

Use the following command to check the play device.

pi@raspberrypi:~ $ aplay -L

It should be like:

pi@raspberrypi:~ $ aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
default
ac108
dmixer
ac101
sysdefault:CARD=ALSA
bcm2835 ALSA, bcm2835 ALSA
Default Audio Device
dmix:CARD=ALSA,DEV=0
bcm2835 ALSA, bcm2835 ALSA
Direct sample mixing device
dmix:CARD=ALSA,DEV=1
bcm2835 ALSA, bcm2835 IEC958/HDMI
Direct sample mixing device
dsnoop:CARD=ALSA,DEV=0
bcm2835 ALSA, bcm2835 ALSA
Direct sample snooping device
dsnoop:CARD=ALSA,DEV=1
bcm2835 ALSA, bcm2835 IEC958/HDMI
Direct sample snooping device
hw:CARD=ALSA,DEV=0
bcm2835 ALSA, bcm2835 ALSA
Direct hardware device without any conversions
hw:CARD=ALSA,DEV=1
bcm2835 ALSA, bcm2835 IEC958/HDMI
Direct hardware device without any conversions
plughw:CARD=ALSA,DEV=0
bcm2835 ALSA, bcm2835 ALSA
Hardware device with all software conversions
plughw:CARD=ALSA,DEV=1
bcm2835 ALSA, bcm2835 IEC958/HDMI
Hardware device with all software conversions
sysdefault:CARD=seeed8micvoicec
seeed-8mic-voicecard,
Default Audio Device
dmix:CARD=seeed8micvoicec,DEV=0
seeed-8mic-voicecard,
Direct sample mixing device
dsnoop:CARD=seeed8micvoicec,DEV=0
seeed-8mic-voicecard,
Direct sample snooping device
hw:CARD=seeed8micvoicec,DEV=0
seeed-8mic-voicecard,
Direct hardware device without any conversions
plughw:CARD=seeed8micvoicec,DEV=0
seeed-8mic-voicecard,
Hardware device with all software conversions

Step 3. Record and Play

You can record then play, or you can record and play at the same time.

#It will capture sound on AC108 and save as a.wav
arecord -Dac108 -f S32_LE -r 16000 -c 8 a.wav
#Take care of that the captured mic audio is on the first 6 channels

#It will play sound file a.wav on AC101
aplay -D ac101 a.wav
#Do not use -D plughw:1,0 directly except your wave file is single channel only.

#Doing capture && playback the same time
arecord -D hw:1,0 -f S32_LE -r 16000 -c 8 to_be_record.wav &
#mono_to_play.wav is a mono channel wave file to play
aplay -D plughw:1,0 -r 16000 mono_to_play.wav

note

Limit for developer using 6-Mic Circular Array Kit(or 4-Mics Linear Array Kit) doing capture & playback the same time:

-1. capture must be start first, or else the capture channels will possibly be disorder.

-2. playback output channels must fill with 8 same channels data or 4 same stereo channels data, or else the speaker or headphone will output nothing possibly.

-3. If you want to play and record at the same time, the aplay music file must be mono, or you can not use this command to play.

Also you can play and record with Audacity.

tip

You should open Audacity via VNC or you can just use a monitor to open it

sudo apt update
sudo apt install audacity
audacity // run audacity

Play with LEDs

There are 12 GRB LEDs in the 6-mic circular array, you can configure the LEDs yourself, now let's see how to light them up.

git clone --depth 1 https://github.com/respeaker/pixel_ring.git
cd pixel_ring
pip install -U -e .
python examples/respeaker_4mic_array.py

You will see LEDs light and run. And you can refer to the python examples/respeaker_4mic_array.py file to make your own effects.

Realtime Sound Source Localization and Tracking

ODAS stands for Open embeddeD Audition System. This is a library dedicated to perform sound source localization, tracking, separation and post-filtering. Let's have a fun with it.

  • Step 1. Get ODAS and build it.
sudo apt-get install libfftw3-dev libconfig-dev libasound2-dev libgconf-2-4
sudo apt-get install cmake
git clone https://github.com/introlab/odas.git
mkdir odas/build
cd odas/build
cmake ..
make
  • Step 2. Get ODAS Studio and open it.

  • Step 3. The odascore will be at odas/bin/odaslive, the config file is at here.

Extract Voice

We use PyAudio python library to extract voice.

  • Step 1, We need to run the following script to get the device index number of 6 Mic pi hat:
sudo pip install pyaudio
cd ~
nano get_index.py
  • Step 2, copy below code and paste on get_index.py.
import pyaudio

p = pyaudio.PyAudio()
info = p.get_host_api_info_by_index(0)
numdevices = info.get('deviceCount')

for i in range(0, numdevices):
if (p.get_device_info_by_host_api_device_index(0, i).get('maxInputChannels')) > 0:
print "Input Device id ", i, " - ", p.get_device_info_by_host_api_device_index(0, i).get('name')
  • Step 3, press Ctrl + X to exit and press Y to save.

  • Step 4, run 'sudo python get_index.py' and we will see the device ID as below.

Input Device id  2  -  seeed-8mic-voicecard: - (hw:1,0)
  • Step 5, change RESPEAKER_INDEX = 2 to index number. Run python script record.py to record a speech.
import pyaudio
import wave

RESPEAKER_RATE = 16000
RESPEAKER_CHANNELS = 8
RESPEAKER_WIDTH = 2
# run getDeviceInfo.py to get index
RESPEAKER_INDEX = 2 # refer to input device id
CHUNK = 1024
RECORD_SECONDS = 5
WAVE_OUTPUT_FILENAME = "output.wav"

p = pyaudio.PyAudio()

stream = p.open(
rate=RESPEAKER_RATE,
format=p.get_format_from_width(RESPEAKER_WIDTH),
channels=RESPEAKER_CHANNELS,
input=True,
input_device_index=RESPEAKER_INDEX,)

print("* recording")

frames = []

for i in range(0, int(RESPEAKER_RATE / CHUNK * RECORD_SECONDS)):
data = stream.read(CHUNK)
frames.append(data)

print("* done recording")

stream.stop_stream()
stream.close()
p.terminate()

wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
wf.setnchannels(RESPEAKER_CHANNELS)
wf.setsampwidth(p.get_sample_size(p.get_format_from_width(RESPEAKER_WIDTH)))
wf.setframerate(RESPEAKER_RATE)
wf.writeframes(b''.join(frames))
wf.close()
  • Step 6. If you want to extract channel 0 data from 8 channels, please follow below code. For other channel X, please change [0::8] to [X::8].
import pyaudio
import wave
import numpy as np

RESPEAKER_RATE = 16000
RESPEAKER_CHANNELS = 8
RESPEAKER_WIDTH = 2
# run getDeviceInfo.py to get index
RESPEAKER_INDEX = 2 # refer to input device id
CHUNK = 1024
RECORD_SECONDS = 3
WAVE_OUTPUT_FILENAME = "output.wav"

p = pyaudio.PyAudio()

stream = p.open(
rate=RESPEAKER_RATE,
format=p.get_format_from_width(RESPEAKER_WIDTH),
channels=RESPEAKER_CHANNELS,
input=True,
input_device_index=RESPEAKER_INDEX,)

print("* recording")

frames = []

for i in range(0, int(RESPEAKER_RATE / CHUNK * RECORD_SECONDS)):
data = stream.read(CHUNK)
# extract channel 0 data from 8 channels, if you want to extract channel 1, please change to [1::8]
a = np.fromstring(data,dtype=np.int16)[0::8]
frames.append(a.tostring())

print("* done recording")

stream.stop_stream()
stream.close()
p.terminate()

wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
wf.setnchannels(1)
wf.setsampwidth(p.get_sample_size(p.get_format_from_width(RESPEAKER_WIDTH)))
wf.setframerate(RESPEAKER_RATE)
wf.writeframes(b''.join(frames))
wf.close()

DOA

DOA with Keywords

Requirements

  • pyaudio
  • numpy
  • snowboy

Installation

Install pyaudio, numpy and snowboy, use virtualenv a virtual python environment.

sudo apt install python-pyaudio python-numpy python-virtualenv
sudo apt-get install swig python-dev libatlas-base-dev build-essential make
git clone --depth 1 https://github.com/Kitt-AI/snowboy.git
cd snowboy
virtualenv --system-site-packages env
source env/bin/activate
python setup.py build
python setup.py bdist_wheel
pip install dist/snowboy*.whl
git clone https://github.com/voice-engine/voice-engine.git
cd voice-engine
python setup.py bdist_wheel
pip install dist/*.whl

Let's say snowboy

  • Step 1. Run the kws_doa.py
cd ~/voice-engine/examples/respeaker_6mic_array_for_pi/
python kws_doa.py

Here is the code of the kws_doa.py

"""
Search the keyword "snowboy".
After finding the keyword, Direction Of Arrival (DOA) is estimated.

Hardware: ReSpeaker 6 Mic Array for Raspberry Pi
"""

import sys
import time
from voice_engine.source import Source
from voice_engine.channel_picker import ChannelPicker
from voice_engine.kws import KWS
from voice_engine.doa_respeaker_6mic_array import DOA


def main():
src = Source(rate=16000, channels=8)
ch0 = ChannelPicker(channels=src.channels, pick=0)
kws = KWS(model='snowboy', sensitivity=0.6, verbose=True)
doa = DOA(rate=16000)

src.link(ch0)
ch0.link(kws)
src.link(doa)

def on_detected(keyword):
print('detected {} at direction {}'.format(keyword, doa.get_direction()))

kws.set_callback(on_detected)

src.recursive_start()
while True:
try:
time.sleep(1)
except KeyboardInterrupt:
break

src.recursive_stop()

# wait a second to allow other threads to exit
time.sleep(1)


if __name__ == '__main__':
main()
  • Step 2. Let's say snowboy and here is output of DOA.
(env) pi@raspberrypi:~/voice-engine/examples/respeaker_6mic_array_for_pi $ python kws_doa.py 
['arecord', '-t', 'raw', '-f', 'S16_LE', '-c', '8', '-r', '16000', '-D', 'default', '-q']
0000000000000000000000000000000000000000000000000000000000000000000000000000000002222222222222222222222222222222222222222222222/usr/local/lib/python2.7/dist-packages/voice_engine-0.1.3-py2.7.egg/voice_engine/gcc_phat.py:22: RuntimeWarning: invalid value encountered in divide
cc = np.fft.irfft(R / np.abs(R), n=(interp * n))
detected 1 at direction 283.32811392
3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002222222222222222222222222222222222222222222222detected 1 at direction 210.0
30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002222222222222222222222222222222222222222222222detected 1 at direction 62.5448292531
30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002222222222222222222222222222222222222222222222222detected 1 at direction 62.5448292531
300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002222222222222222222222222222222222222222222detected 1 at direction 223.32811392
300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022222222222222222222222222222222222222222222222222detected 1 at direction 223.32811392
30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000222222222222222222222222222222222222222detected 1 at direction 283.32811392
300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002222222222222222222222222222222222222222222detected 1 at direction 237.455170747

Buton

if you want to check that your respeaker_6-Mic is installed correctly on raspberry . The Buton is a good idea. we can use the below code to check.


import RPi.GPIO as GPIO
import time

BUTTON = 26

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)

FAQ

Q1: There are only 6 Mic in the Mic Array, how could it be 8 channels?

A1: There are 2 AC108 in this array, and each AC108 chip has 4 channel output. So it comes a total of 8 channels here, 6 of which are for the microphone, and the the rest 2 are the playback channels.

Q2: If Raspberry can detect ReSpeaker 2-mics hat, but can't detect ReSpeaker 6-mics Circular array?

A2: Please click raspberry -> Preferences -> Raspberry Pi Configuration, then select the Interfaces tab, make sure the 1-Wire is Disabled.

Resources

Tech Support & Product Discussion

Thank you for choosing our products! We are here to provide you with different support to ensure that your experience with our products is as smooth as possible. We offer several communication channels to cater to different preferences and needs.

Loading Comments...