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