偶然发现seeedstudio更新了他们的英文版说明书,然而中文版还没更新[捂脸]。关于DOA的部分,除了原来的使用ODAS Studio的方法以外,又多加了一些使用Python代码直接进行DOA的章节。
0 安装驱动
别忘了用source activate doa切到专门的环境里,或者conda create -n doa python=3.6现造一个环境。
安装驱动:
proxychains4 git clone https://github.com/respeaker/seeed-voicecard.gitcd seeed-voicecardsudo proxychains4 ./install.shsudo reboot -h now检查驱动:
arecord -L # 输入驱动,即录制null Discard all samples (playback) or generate zero samples (capture)defaultac108dmixerac101sysdefault:CARD=seeed8micvoicec seeed-8mic-voicecard, Default Audio Devicedmix:CARD=seeed8micvoicec,DEV=0 seeed-8mic-voicecard, Direct sample mixing devicedsnoop:CARD=seeed8micvoicec,DEV=0 seeed-8mic-voicecard, Direct sample snooping devicehw:CARD=seeed8micvoicec,DEV=0 seeed-8mic-voicecard, Direct hardware device without any conversionsplughw:CARD=seeed8micvoicec,DEV=0 seeed-8mic-voicecard, Hardware device with all software conversions
aplay -L # 输出驱动,即播放null Discard all samples (playback) or generate zero samples (capture)defaultac108dmixerac101sysdefault:CARD=ALSA bcm2835 ALSA, bcm2835 ALSA Default Audio Devicedmix:CARD=ALSA,DEV=0 bcm2835 ALSA, bcm2835 ALSA Direct sample mixing devicedmix:CARD=ALSA,DEV=1 bcm2835 ALSA, bcm2835 IEC958/HDMI Direct sample mixing devicedsnoop:CARD=ALSA,DEV=0 bcm2835 ALSA, bcm2835 ALSA Direct sample snooping devicedsnoop:CARD=ALSA,DEV=1 bcm2835 ALSA, bcm2835 IEC958/HDMI Direct sample snooping devicehw:CARD=ALSA,DEV=0 bcm2835 ALSA, bcm2835 ALSA Direct hardware device without any conversionshw:CARD=ALSA,DEV=1 bcm2835 ALSA, bcm2835 IEC958/HDMI Direct hardware device without any conversionsplughw:CARD=ALSA,DEV=0 bcm2835 ALSA, bcm2835 ALSA Hardware device with all software conversionsplughw:CARD=ALSA,DEV=1 bcm2835 ALSA, bcm2835 IEC958/HDMI Hardware device with all software conversionssysdefault:CARD=seeed8micvoicec seeed-8mic-voicecard, Default Audio Devicedmix:CARD=seeed8micvoicec,DEV=0 seeed-8mic-voicecard, Direct sample mixing devicedsnoop:CARD=seeed8micvoicec,DEV=0 seeed-8mic-voicecard, Direct sample snooping devicehw:CARD=seeed8micvoicec,DEV=0 seeed-8mic-voicecard, Direct hardware device without any conversionsplughw:CARD=seeed8micvoicec,DEV=0 seeed-8mic-voicecard, Hardware device with all software conversions1 测试LED
说实话,自打买了这个麦阵列,我还从来没试过这12个LED灯[捂脸],试试吧要不感觉对不起这个板子,另外,运行demo需要gpiozero、spidev、pyusb。
proxychains4 git clone --depth 1 https://github.com/respeaker/pixel_ring.gitcd pixel_ringproxychains4 pip install -U -e .proxychains4 pip install gpiozero RPi.GPIOpython examples/respeaker_4mic_array.py控制LED的主要代码其实就在函数show(),直接在Python交互环境中输入下面的代码,就可以打开12点方向的灯,并渲染为白色,也就是ARGB(0, 64, 64, 64)。
from pixel_ring import pixel_ringfrom gpiozero import LED
power = LED(5)power.on()
pixel_ring.set_brightness(10) # 0-100,其实会被转换为`APA102.dev.global_brightness`的0-31pixel_ring.pattern.show([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 64])用于控制的数组是一个48位的list,从1点钟方向开始,到12点钟方向结束,每四位控制一个LED灯,非常好操作。
2 装DOA相关库
添加seeed提供的apt源。(靠谱的公司啊)
echo "deb https://seeed-studio.github.io/pi_repo/ stretch main" | sudo tee /etc/apt/sources.list.d/seeed.listproxychains4 curl https://seeed-studio.github.io/pi_repo/public.key | sudo apt-key add -proxychains4 sudo apt update安装numpy和pyaudio:
proxychains4 conda install -y numpyproxychains4 sudo apt-get install -y portaudio19-devproxychains4 pip install pyaudio安装编译工具:
sudo proxychains4 apt-get install -y swig python-dev libatlas-base-dev build-essential make安装snowboy(热词检测DOA):
proxychains4 git clone --depth 1 https://github.com/Kitt-AI/snowboy.gitcd snowboypython setup.py buildpython setup.py bdist_wheelpip install dist/snowboy*.whl安装seeed的voice-engin:
proxychains4 git clone https://github.com/voice-engine/voice-engine.gitcd voice-enginepython setup.py bdist_wheelpip install dist/*.whl测试ok~:
python ~/doa/voice-engine/examples/respeaker_6mic_array_for_pi/kws_doa.py如果只是想用DOA功能,可以试试seeed的老项目mic_array:
proxychains4 git clone https://github.com/respeaker/mic_array.gitpython ./mic_array/mic_array.py对比了一下,跟人家introlab/odas项目差的还是比较远的。直观上看就是我们简单的靠fft实现的DOA仅仅能做到平面范围内的方位判断,仅输出一个角度(平面offset),速度慢且不支持声源跟踪等功能。而odas的声源定位项目输出两个值,一个平面offset一个法向offset,还能进行声源分辨,多声源跟踪跟踪。odas项目的理论收录在Lightweight and Optimized Sound Source Localization and Tracking Methods for Opened and Closed Microphone Array Configurations中,值得一读。