@borrigan
AlexaPi service, when running, is “Always On”? It is always listening? How to test it directly without having integrated with MMM-AlexaPi Yet?
you should hear “hello” when it start and then if you say Alexa you should hear “yes” then you can ask a question. It is always listening.
A little tips for you, before using the service, try to run AlexaPi yourself. It provide you more debugging info that way.
To do it, first desactivate the service with the terminal by writing sudo systemctl stop AlexaPi.service; sudo systemctl disable AlexaPi.service
(you can reactivate later by doing sudo systemctl enable AlexaPi.service
).
Then you can run AlexaPi yourself by writing in the terminal /opt/AlexaPi/src/main.py -d
(If you you putted it on that location anyway).
Where can the activation word be configured? If I just say “Alexa”, should it work?
in the yaml file in /etc/opt/AlexaPi/config.yaml
there is a section pocketsphinx:
(this is what is use to detect words I believe). in that section you have a key phrase:
with "alexa"
as a value. you can simply change the word to another word. Do not choose an over complicated one though, I think pocketsphinx try to guess what it supposed to sound like based on the spelling so if you choose a word not in English it might not guess correctly. You shoudl let alexa untill you get it to work though, because we know that one work for sure. You can test other word later.
Finally, I spent hours troubleshooting the microphone. It is a very standard Logitech Microphone. I just could not get it working.
I am no expert in sound but I going to try to help you.
First, I rather have the output from arecord -l
rather than arecord -L
. the later give to much information to my understanding.
The output of my arecord -l
look like this:
pi@raspberrypi:~ $ arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: Device [USB Audio Device], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
I can see it’s “card 1” and “device 0” . that’s what I am interesting about.
then, my aplay -l
give me
pi@raspberrypi:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Device [USB Audio Device], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
I using the default speaker output, which is the bcm2835 Alsa device which is “card 0” and “device 0”
Knowing that you can test if your device working by doing the following:
meaning you should be able to do a aplay -D hw:0,0 /usr/share/sounds/alsa/Front_Center.wav
to test your speaker where “hw:0,0” (you could also put “plughw:0,0”) is your output device. Not sur what does “hw” and “plughw” mean, but the numbers are the card number and the device number. 0,0 in my example (remember the aplay -l above)
this will use the vlc handler i beleive. You can test it the same way with play
instead of aplay
for the sox handler.
you can test your michrophone in the same way by doing arecord -r 48000 -f S16_LE -D hw:1,0 -d 5 test.wav
this will tell to record with the device hw:1,0 (in my example the card 1, device 0) for 5 second at a rate of 48000Hz and as S16_Le type (not sure what that is) and the result will be put in a file name test.wav. You can then play
or aplay
that file to see if the recording whent well.
If you manage to make those command work. In the /etc/opt/AlexaPi/config.yaml
there is a section sound:
with a key “input_device:” and a key “output_device:” . Both of those key have for value “default” . for the output it’s easy, the default is the system defautl output which is hw:0,0 in my example. so you can let default or put “hw:0,0” instead if you want to use that output like me.
The tricky part is the input. The input is your michrophone, but there is no “default” michrophone in the pi right ? so the chance AlexaPi understand what you are talking about are prett slim in my opinion.
But when I wrote “hw:1,0” or “plugwh:1,0” instead of default , I had an error. For some reason it didn’t wanted to take that value. That’s when trickery was needed for me. I’m sure some people hadn’t to do that but I did.
I creat a alsa configuration file name “asound.conf” with the following in it :
pcm.myTest {
type dsnoop
ipc_key 816357492
ipc_key_add_uid 0
ipc_perm 0666
slave {
pcm "hw:1,0"
channels 1
}
}
pcm.!default {
type asym
playback.pcm {
type plug
slave.pcm "hw:0,0"
}
capture.pcm {
type plug
slave.pcm "myTest"
}
}
This overrite what is the “default” configuration.
type asym
mean my playback and default arn’t on the same sound device.
the playback.pcm
describe what is my output device. In my example you can see i putted “hw:0,0” because I use the default output.
the capture.pcm
describe the input device (microphone). I put “MyTest” as a name which is describe above in the file (the name isn’t very explicit but I was testing and never changed it >.> )
I am not going to enter in the detail for the myTest thing, but basically, it’s tell that the michrophone can be use in multiple application at the time and that it is the “hw:1,0” (remember the arecord -l thing above in the post)
This asound.conf file should be put in the /etc/
folder.
Well. That’s it. That’s what I had to do to make my microphone work for AlexaPi. Adapt this to your own devices and it might work like me.
Remember to test it whitout the service first and when that’s work you activate the service and see if it still work or not. and if not we’ll try to understand why.