Voice Recognition recommendation for Pi, MQTT, Openhab

Hello!

You can find my simple voice recognition application here:

You will need Python 3.3+ installed, with following packages:

  1. speech_recognition
  2. pyglet
  3. gtts (if you would like to use Google Text-to-speech)
  4. pyvona (if you would like use Ivona Text-to-speech)
  5. apiai (if you would like to use api.ai general knowledge and other domains queries)

VoiceHAB.ini is pretty self-explanatory, but I will make some kind of user manual as soon as I find some free time. To use VoiceHAB, just start __main__.py

After initialization, you can say wake-up phrase to have it listen for your commands. If you say a sentence that starts with ā€œtell meā€ (this could be changed in VoiceHAB.ini - GeneralKnowledgeTriggerPhrase) it will redirect query to api.ai, otherwise, it will send recognized text to OpenHAB item listed in VoiceHAB.ini. You will need to register and obtain keys for api.ai and Ivona if you intend to use them (they are free for a limited personal usage). I intend to add some other Speech-to-text engines (wit.ai, bing, api.ai), and I will try to add voice verification too, but it will take some time. I know this isnā€™t explained very well, so, if you have any questions, feel free to post it here - Iā€™ll try to answer them as soon as I can.

Best regards,
Davor

3 Likes

This was very exciting news, but they are only allowing certain services to be used

  • Audio or video calling
  • Messaging
  • Payments
  • Searching photos
  • Workouts
  • Ride booking

Maybe this is just the first baby steps to see what happens, but at the moment it is a little disappointing.

Interesting project, I will give it a go.

A suggestion would be to put what you wrote in your post here into a readme,md file in the repo as people might stumble across it without visiting this forum :slight_smile:

@davorf

Pretty cool!
Do you still maintain VoiceHAB?
I would like to use this with my openhab2 installationā€¦

Hello!

Honestly, I havenā€™t been updating it since July, because my OH server crashed and I was concentrated on restoring everything. Regardless, Iā€™m planning to get back to it, because Iā€™ll need it soon too. If I recall correctly, itā€™s in the working state, just missing some advanced functions I had planned (i.e. voice authorization). If you have any questions, or you encountered a problem, feel free to ask.

Best regards,
Davor

Thatā€™s good news!
Iā€™m planning on making an Amazon Echo style listening device using a Raspberry Pi3 and VoiceHAB.
Already cloned the repository and going through the code :smile:
Iā€™m willing to help with that even if Iā€™m not skilled at all with Python.
In the current state itā€™s not working out-of-the-box on my Pi, but Iā€™ll dig more.
Iā€™ll post my findings/issues on github.

Hello!

I havenā€™t used it for a while, so, maybe I started something and havenā€™t finished. If you find some specific errors, you can post it, either here, or on github. Iā€™m glad thereā€™s someone to test it, besides me.

Best regards,
Davor

Hi Davor,
I tried to run your application on a Raspberry Piā€¦
After struggling with PyAudio and portaudio I finally got it up and running.
Sadly Iā€™m now stuck at the point that AVbin is required to decompress audioā€¦
Since there does not seem to be AVbin for ARM architecture I wonā€™t make any progress with my Raspberry.
Would you mind changing the way to decompress the audio?

Hello!

Another user reported the same problem, so Iā€™ve implemented an option to choose between pygame and pyglet as sound processing package. Patch was implemented last night, so, youā€™ll probably need to clone git repo again.

Best regards,
Davor

Thanks for that I missed missed out on that discussion on github.

Now Iā€™m getting some ALSA lib error messages concering conf.c (evaluate error: no such file or directory), confmisc.c (unable to find definittion ā€˜cards.bcm28ā€¦ā€™) and pcm.c (unknown pcm cards) .

Any help is again highly appreciated.
Thanks in advance,
loc

I managed to plug in a speaker and am getting the following messages:
ā€œjust a moment pleaseā€
"Iā€™m listening"
whenever I use the keyword I get:
ā€œgoogle speech recognition denied request for resultā€

python3 __main__.py

gives me

ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.front.0:CARD=0' ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM front ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0' ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround21 ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0' ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround21 ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround40.0:CARD=0' ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround40 ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0' ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround41 ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0' ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround50 ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0' ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround51 ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround71.0:CARD=0' ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround71 ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2' ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM iec958 ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2' ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM spdif ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2' ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM spdif ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave

@loc
Iā€™m using @davorf 's VoiceHAB with a RPi3 and a USB soundcard.
How is your setup? The microphone is surely connected to such a USB soundcard, right? But what about the speakers? They are connected to the same USB soundcard or directly to the audio output of the pi?
I have both of them connected to the USB soundcard and the sound card set as default.
Are you able to record something though the microphone? Try to record using arecord (search Google for syntax).
I also have some warnings from Alsa regarding missing PCMs, but you can ignore them.

@Mihai_Badea
Iā€™m using a RPi3 and one of those mini USB microphones: https://www.amazon.de/sumicline-USB-2-0-Mini-Mikrofon-PCs-Skype-Anerkennung/dp/B01LOK9Z96/
lsusb says it is a ā€œC-Media Electronics, Inc. CM108 Audio Controllerā€.
The speakers are connected directly to the audio output of the RPi.

Whenever I record for testing arecord -D plughw:1,0 -r 4800 test.wav I can hear my voice very quite and I have some crackling in the recorded file.
I already changed the USB speed to 1 dwc_otg.speed=1 within the /boot/cmdline.txt

I configured the ā€œUSB PnP Sound Deviceā€ in alsamixer and changed the capture level to 94 - but the crackled records remain.

Hello!

Since I donā€™t have an RPi, or any Linux maching at home at the moment (my setup uses Windows 7), there is not much I can do regarding your problem. I would check if your default sound output device is properly installed and configured in ALSA. It doesnā€™t look like input (microphone), but rather output (speakers) problem.

Best regards,
Davor