Speech recognition doesn't work under electron
With a fresh checkout running under electron (npm start), annyang is not longer working. I am using a USB logitech webcam microphone for the input.
If I run the exact same set of files under chromium, the microphone and speech recognition work fine. Was there any configuration necessary under electron, alsa or asound to get electron to work?
After playing around with it a bit more, it seems that if I run 'sudo npm start' instead of just 'npm start', the microphone will work.
Thank you for that hint. I had the same problem with a Creative USB webcam, annyang reported unknown input once per second. Starting with sudo makes it work as intended.
I don't think this is an issue with the mirror, it's more likely an issue with Electron. Having to run with sudo is kind of a bummer. I'm using a Logitech Webcam and it's working fine for me... I'll take a look at this and let you know if I figure something out.
I am unable to get it to speech to work. How do I set this up? I am not getting any prompts to choose a device on launch. When I record with my usb mic via command line, I get sound back.
I found getting the mic to work with electron quite finicky. As mentioned above, I never got it to work without running with sudo. I also had issues starting electron in rc.local - it would start (running as root), but the mic still didn't work.
In the end, I start it as the 'pi' user from a '@reboot' in the 'pi' user's crontab file:
@reboot sudo /home/pi/smart-mirror/start &
with the start script being:
#!/bin/bash
export DISPLAY=:0
export XAUTHORITY=/home/pi/.Xauthority
cd /home/pi/smart-mirror && npm start
I also played around with my ~/.asoundrc file. I am not sure if it was necessary at all. Here is what is in my file:
pcm.!default {
type hw
card 0
}
ctl.!default {
type hw
card 0
}
pcm.default.card 1
I did post questions to both stackoverflow and atom.io hoping for some info on this, but I have not heard anything back.
I wasn't able to come to any conclusions when I looked at it over the weekend - although I have a sneaking suspicion that for some reason electron isn't picking up your microphone is the default (despite your configuration). It's possible to select which media device to use inside Electron, could you try using http://cl.ly/code/303S1R1o332n and seeing if your device gets picked up properly?
Thanks - I will try it when I get home. If this can work, we could add a config to config.js that allows a hard-coded selection of the microphone.
If I can't get it to work on the default browser. How do you npm start it with chromium/ chrome? I have Chromium installed but, have not seen a way to get npm to start with that instead of default browser.
I did what efunneko did with:
pcm.!default {
type hw
card 0
}
ctl.!default {
type hw
card 0
}
pcm.default.card 1
But, I also had to go to /usr/share/alsa/alsa.conf and edit that file. I changed the defaults of the following to 1.
defaults.ctl.card 1
defaults.pcm.card 1
Only issue I saw so far (about 10 minutes of testing before bed), I was unable to do an image search. I was able to do maps.
Seems like that's the solution then :)
If you still wanted to test device selection for getUserMedia use https://github.com/atom/electron-quick-start as a starting point and then drop in the contents of http://cl.ly/code/303S1R1o332n in index.html, that should work.
Some help hear would be appreciated. Linux is definitely not my strongest attribute. I have everything up and running, finally! With 1 exception my mic. I'm using an hp KQ245aa Tested working using sudo arecord -D plughw:1,0 test.wav ran the file with aplay test.wav and confirmed audio.
I can't seem to get smart-mirror to listen for commands.
Since I am Linux stupid.
can some one give me a step by step as to what BrianDawson did or anything I can follow to get this up and running proper
Much appreciated and thank you in advance.
I got the voice recognition to work without sudo finally.
I had already made the changes to alsa.conf and the .asoundrc discussed above, but in addition I also had swapped the ordering of the USB webcam and ALSA, so for me 0->1 and 1->0 compared to the solution above.
The problem was that I did not have "pcm.default.card 0" in my .asoundrc file. With that added, it works like charm!
Nice job figuring this out folks! I've added a link to this issue in the readme for anyone else who has the same issue.
Please follow the instructions above to sort this out. There are some variations to this solution (as it depends on which mic you are using) so read through the thread and see what works for you.
@Keopss for new questions please file a new issue or ask on gitter, I want to keep this thread uncluttered so people who have this problem don't have to sift through a bunch of information to get what they need :)
anyone else have a problem with losing sound out of the audio jack when mic is working. and when I edit the files the to get the sound to work I lose the mic again?
For those that are having audio issues. I'm not sure if this is a universal fix but this is what worked for me.
I ended up editing the /usr/share/alsa/alsa.conf file. Basically run arecord --list-devices and find the card #/device #. For me I simply needed the card#.
In the /usr/share/alsa/alsa.conf file I then changed these lines defaults.ctl.card # defaults.cm.card # to my corresponding card number of my input device. I also deleted the # from this line (load card-specific configuration files (on request)).
My .asounrc file is now blank.
I was trying to also add Airplay functionality to my mirror and was unable to use the onboard or secondary usb output after following the steps in #20 and this resolved that issue for me.
I found most of this info online and on these forums: http://superuser.com/questions/989385/alsa-base-conf-missing-in-new-raspberry-pi-raspbian-jesse http://askubuntu.com/questions/429945/what-is-the-hardware-address-of-my-webcam-mic
Awesome information @nojkepop thanks a ton!
Does your mic still work?
Yes I have a USB microphone and USB speakers connected, these are two separate devices. I can Airplay audio to my Raspberry Pi using shairport-sync and still use voice commands on the Mirror.