4、官方参考教程

您当前位置: 首页 > 语音模块ReSpeaker 4 > 语音识别教程

ReSpeaker 4-Mics Pi HAT

基于Raspberry Pi的ReSpeaker 4-Mic阵列是一款适用于AI和语音应用的Raspberry Pi的四通道麦克风扩展板。 这意味着您可以借助它构建一个集成Amazon Alexa语音服务,Google助手等,功能更强大,更灵活的语音产品。

区别于 ReSpeaker 2-Mics Pi HAT, 该板是基于AC108开发的,这是一款高度集成四通道ADC,具有用于高清晰度语音捕获,I2S / TDM输出,拾取3米半径的声音的语音设备。 此外,这款4-Mics版本提供了超酷LED环,其中包含12个APA102可编程LED。 就像Amazon Echo或 Google assist一样, 使用4个麦克风和LED环,Raspberry Pi具有VAD(语音活动检测),DOA(到达方向),KWS(关键字搜索),并通过LED环显示方向灯功能。

产品特征

Note

ReSpeaker 4-Mic Array没有任何音频输出接口, 它只用于语音捕获。 您可以使用Raspberry Pi上的耳机插孔进行音频输出。


创意应用

硬件概述

Note

如果要使用APA102 RGB LED,请先将高电平写入“GPIO5”,给LED的VCC供电。


入门指导

1. 系统配置与驱动安装

step 1. 把ReSpeaker 2-Mics Pi HAT插入到Raspberry Pi

把 ReSpeaker 4-Mics Pi HAT 插入到 Raspberry Pi, 确保插入Raspberry Pi的时候针脚对齐。

Note

不要在上电的时候,热插拔ReSpeaker 4-Mics Pi HAT.


connection pic1 connection pic2

step 2. 烧录系统,登陆,换源

因为当前的Pi内核目前不支持wm8960编解码器,所以我们需要手动构建。

  1. 确保您正在您的Pi上运行最新的Raspbian操作系统(debian 9),您可以用etcher进行系统烧录

  2. 您可以用 VNC或者PUTTY连接树莓派,但之前请配置好wifi

  3. 在安装驱动之前,请根据以下流程切换源到清华。

sudo nano /etc/apt/sources.list

如果是用#注释掉原文件内容,用以下内容取代:

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

如果是2019-06-20之前版本 需要将buster修改为Stretch可以通过cat /etc/rpi-issue查看是什么时候发布的版本

step 3. 驱动下载并安装 运行下面命令

sudo apt-get update
git clone https://github.com/respeaker/seeed-voicecard.git
cd seeed-voicecard #下载声卡驱动
sudo ./install.sh  --compat-kernel #安装声卡驱动
reboot  #重启


Note

若驱动安装失败您可以跳转到FAQ的Q1以解决驱动安装失败问题。

step 4. 检查声卡名称是否与源代码seeed-voicecard相匹配.

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

如果要更改alsa设置,可以使用sudo alsactl --file=ac108_asound.state store保存。 当你需要再次使用这些设置时,将它复制到:sudo cp ~/seeed-voicecard/ac108_asound.state /var/lib/alsa/asound.state

2. 录音播放测试

step 1. 录播测试 可以用arecord录制,然后用aplay播放:(不要忘记插耳机或者喇叭):

arecord  |  aplay

也可以通过audacity软件测试。打开Audacity后,选择 AC108和2通道 作为输入,bcm2835 alsa: - (hw:0,0) 作为输出来测试:

$ sudo apt update
$ sudo apt install audacity
$ audacity                      // 运行 audacity

step 2. 调节音量(可跳过)

alsamixer 是用于配置声音设置和调整音量,高级Linux声音体系结构(ALSA)的图形混音器程序。

alsamixer

Note

首先请用F6选择seeed-4mic的声卡设备。

左和右箭头键用于选择通道或设备,“向上和向下箭头”控制当前所选设备的音量。 退出程序使用ALT + Q或按Esc键。 More information

3. 控制APA102 LED的示例

每个板载APA102 LED都有一个额外的驱动芯片,驱动芯片设置LED的颜色,然后保持该颜色,直到接收到新的命令。

pip install spidev gpiozero           # 安装 spidev 和 gpiozero
git clone --depth 1 https://github.com/respeaker/pixel_ring.git   #安装pixel_ring
cd pixel_ring
pip install -U -e .
cd examples/