Package arrival!
On Friday I received my challenger kit (massive thanks to Element 14 and Raspberry pi foundation).
I really love the carry bag that came with it
Voice recognition
This week i got started on implementing the voice recognition portion of my project. I started this before my challenger kit arrived so i began using the pi i had previously dedicated to running emulation station. Naturally the first step was a clean install of the latest Raspbian image.
The devices i started using were an old usb webcam for a mic and a broken bluetooth speaker connected via the 3.5mm audio jack (only the bluetooth is broken).
I then started looking at what voice recognition software was available for the pi.
The following is a list of software I considered:
I did a bit of reading about each of them. The PiAUISuite uses the google voice api under the hood and the project has been stagnant on GitHub for a while now so decided not too jump into that. The Jasper software looks very promising and i think i may well come back to that as it runs offline (does take up a lot of space though).
I installed the Alexa suite and got it up and running, this required me to create an AWS developer account and do the standard OAuth config stuff. The actual installation process was incredibly simple and pretty much consisted of running the script and configuring you user details. I was quite happy with how Alexa ran but examples of interacting with the code were limited at best and everything pushed quite heavily towards custom code being ran as skills on the AWS system. Alexa runs as a node process and the sample app is written in Java. While i could conform to this and run custom code on the Pi i would have to either create a web interface on the pi and push commands from AWS or i would have to poll a message queue on the AWS servers. I didn't like the idea of either of these so i decided to move on and have a play with google assistant.
The google assistant installation process was pretty similar again requiring the creation of a developer account for google cloud. The instructions for the install process are in the HACKING.md file and the account setup instructions can be found here , the standard (non hacking) install process assumes you are using this kit and so the device setup was not correct. I made a small change to the install scripts as i wasn't using the directory structure they had listed the diff can be seen in this commit.
I had to modify the boot configuration after installing everything (/boot/config.txt)
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
#dtoverlay=i2s-mmap
#dtoverlay=googlevoicehat-soundcard
And i had to reconfigure alsa after the installation this question on super user should give you the details of doing this.
All in all it was a pretty simple process. Once you have got everything setup and running you can run the google assistant sample by running the following commands.
source env/bin/activate
googlesamples-assistant-hotword --project_id your_project_id --device_model_id "The Model Id you assigned"
Once I ran the standard sample and was satisfied it worked I moved onto running custom code. I started by modifying the assistant_grpc_demo.py I added a code block that triggers when the voice command contains "cracked pepper" (my initial changes can be found here). I then went on to add sound output when the command text doesn't contain "cracked pepper". For the audio output i used the pygame library the updated version can be found here. When i initially added the sound output it caused a lot of static to be played though the speaker i fixed this by adding the following line to the boot config
audio_pwm_mode=2
Finally here is a short video of the final python script in action (apologies for the quality I filmed it with a potato while underwater....)
Top Comments