Close

April 19, 2019

Voice recognition Party Lights

With a great amount of personal assistance devices, inexpensive systems (rasberry pi) and a fantastic programming framework of Phillips Smart Hue, we sought to recreate a hockey fan’s demonstration of party lights going off when his team scored.
These are some of the notes and systems we used, as well as examples of code.

Here is our Forked version here of the PiAUISuite.
https://github.com/jtsSTECH/PiAUISuite

1.) Setup Rasberry pi stretch OS (https://www.raspberrypi.org/downloads/raspbian/).
I used the follwing:
Raspbian Stretch with desktop and recommended software
Image with desktop and recommended software based on Debian Stretch
Version:April 2019
Release date:2019-04-08
Kernel version:4.14

2.) We used Steven Hickens awesome Voicecontrol system to perform our initial round of voice recognition
Code and setup instructions: https://stevenhickson.blogspot.com/2013/04/voice-control-on-raspberry-pi.html

Please note, we forked his version (Fork here) so any of the modifications to the code are not really necessary anymore (steps 3-6)

3.) You will need to recompile the voicecommand. (PiAUISuite/VoiceCommand/)
Edit the voicecommand.cpp and remove the “–sample-rate 16000”
Recompile the code:

g++ -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -D’BUILDTS=”160506 05:20:31 -0700″‘ -O3 -lcurl -lboost_regex -o voicecommand voicecommand.cpp
Then copy it:
sudo cp voicecommand /usr/bin/voicecommand

Edit speech-recog.sh and do the same thing (remove: “–sample-rate 16000”)

4.) You may get the following error:
“voicecommand: error while loading shared libraries: libboost_regex.so.1.49.0: cannot open shared object file: No such file or directory”
https://www.raspberrypi.org/forums/viewtopic.php?p=1275083#p1275083

Solved via the above article:
sudo ln -s /usr/lib/arm-linux-gnueabihf/libboost_regex.so.1.62.0 /usr/lib/arm-linux-gnueabihf/libboost_regex.so.1.49.0

5.) Need to fix the default TTS script (/usr/bin/tts)
Fix is in the comments. Copy/paste this code overriding /usr/bin/tts
https://github.com/StevenHickson/PiAUISuite/issues/56#issuecomment-205715002

Test it in a command line:
tts “testing 123”
You should here that repeated back to you if its all good.

6.) Test your voice commands. Go into the PiAUISuite/VoiceCommand/ folder
./speech-recog.sh

Then speak a word. It should print it out below if speech to text is working properly.

7.) Go to your user directory (cd ~) and test it all out. Commands will be in the “.commands.conf” file.
Run the following to put it into loop/listen mode.
voicecommand -c

From that point on, we just wrote scripts that execute when our command is spoken (ie: “Go Flyers”). The python scripts execute specifically for whatever team event you want to celebrate.

We use an MP3 sound clip for the actual horn/music clip and then ensure that our “party light” actions are synchronized to the lenght of the clip.

We had initially wanted to go cheap and use “Sengled” smart bulbs. We could find no real documentation on anyone controlling them from an API (that was still being maintained). We took one look at Phillip’s Hue environment and were blown away by the sheer number of API wrappers in Python as well as the documentation at Phillips. With that documentation and QHUE’s wrapper, we were able to get the lights working in a matter of minutes.

Our project notes:

1.) We noticed that if we hit the lights really hard by changing them without any sorts of pauses, they would “stop”. It would take them a few minutes to reset. We were not sure if that was because of the distance to the hub, wifi issues or maybe a limitation of the actual hub itself. When we added smaller “sleeps” it seemed to fix the issue.

Please note, we are die-hard Flyers fans. A member of our families is a diehard Phillies fan, so we had to make a script for the Phillies. (They insist that the Phillies version came out better.)

The test script are in our Git Hub: https://github.com/jtsSTECH/SportsPartyScripts

The new script (see below: voicestech.py) has greatly improved the processing of commands and we don’t need to shout into the microphone anymore as I was doing in the video.

Part II:

The voicecommand module was entirely too slow for our responses. We really didn’t need the answering system (similar to Alexa), but really just wanted it to sample sound every few seconds and see if our keywords were detected.
We changed up the included “speech-recog.sh” script from the voicecommand.

The code is in the “voicestech.py” found on our Git Hub account (https://github.com/jtsSTECH/SportsPartyScripts)

Part III:

As an alternative, we triedy using PocketSphinx so we would have a more local connection and not be dependent on Google.
After a considerable amount of effort, sadly it did not pan out.

1.) Followed the directions from the official website.
https://cmusphinx.github.io/wiki/raspberrypi/

2.) https://www.codesofinterest.com/2017/03/python-speech-recognition-pocketsphinx.html

pip install SpeechRecognition

3.) We built some test script and put it into a loop.  The performance just was not there.  Our Pi just could not keep up with the trans-coding rate.