Re: Голосовое управление по ключевому слову на базе Апельсинки Зеро
Добавлено: Вт май 08, 2018 1:37 pm
Да там еще один вопрос открытый остался с микрофонами.
Как в оригинале с гитхаба в скрипте работает со встроенным микрофоном.
Если втыкать usb микрофон и хочется чтобы он работал надо для начала alsa миксер настроить для того чтобы она записывала образец ключевого слова с внешнего микрофона взято отсюда
И в обоих питоновских скриптах snowboy.py и sayreplay.py
заменить на
Как в оригинале с гитхаба в скрипте работает со встроенным микрофоном.
Если втыкать usb микрофон и хочется чтобы он работал надо для начала alsa миксер настроить для того чтобы она записывала образец ключевого слова с внешнего микрофона взято отсюда
SPOILERSPOILER_SHOW
The first command recorded my voice, and then I pressed Ctrl+C to stop, and play it back with the second command. I worked fine for me. If you wish you can adjust the playback and recording volume with:
We’ll also need to create .asoundrc file for Google Assistant to work with ALSA. For we need to note the microphone card and device number (0,0):
as well as speaker card and device number (0,0):
If you want to use your TV as speaker, you’d use Card 1, device: 0.
If you have not created a pi or other user yet, you’ll want to add one belonging to sudoers and audio groups, and go the home directory:
Now create a ~/.asoundrc with the following match the card and device for our mic and speaker:
[Update: As we’ll see below this won’t work with the built-in microphone, but as indicated in the comments below, this can be fixed by changing
I have not changed the rest of the post, but the built-in microphone on Orange Pi Zero does work now]
Код: Выделить всё
alsamixerКод: Выделить всё
root@orangepizero:~# arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: audiocodec [audiocodec], device 0: SUNXI-CODEC sndcodec-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: sndhdmi [sndhdmi], device 0: SUNXI-HDMIAUDIO sndhdmi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
Код: Выделить всё
aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: audiocodec [audiocodec], device 0: SUNXI-CODEC sndcodec-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: sndhdmi [sndhdmi], device 0: SUNXI-HDMIAUDIO sndhdmi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
If you have not created a pi or other user yet, you’ll want to add one belonging to sudoers and audio groups, and go the home directory:
Код: Выделить всё
adduser pi
adduser pi sudo
adduser pi audio
su pi
cd ~Код: Выделить всё
pcm.!default {
type asym
capture.pcm "mic"
playback.pcm "speaker"
}
pcm.mic {
type plug
slave {
pcm "hw:0,0"
}
}
pcm.speaker {
type plug
slave {
pcm "hw:0,0"
}
}Код: Выделить всё
pcm.mic {
type plug
slave {
pcm "hw:0,0"
format S16_LE
}
}И в обоих питоновских скриптах snowboy.py и sayreplay.py
Код: Выделить всё
with sr.Microphone(index) as source:Код: Выделить всё
with sr.Microphone(device_index=0) as source: