Nowadays it is popular to use voice-directed personal assistants such as Apple's Siri, Google's Now and Microsoft's Cortana. Adding speech or sound recognition is a nice addition to your home automation system.
Speech and voice recognition libraries exist for almost all platforms. Depending on your design, you can add voice control to home automation. Let's start with Android.
An easy way to control your application with voice commands is to extend the Android sample application with the Android Speech Recognizer library.
Information about the Android Speech Recognizer library can be found at http://developer.android.com/reference/android/speech/SpeechRecognizer.html.
For our sample application, we would create a new thread to work as a speech listener by using the SpeechRecognizer
library and listening to the incoming voice.
The SpeechRecognizer
library populates text, and so you can compare if any of them matches the commands we loaded from the JSON file. If it does, we can send a command to the Smart Home application. You may also define better sentences to match the commands and send the corresponding commands to Intel Galileo. For example, you can define a phrase such as Open Lights
and this text will send the command switch on 4
, which turns on the lamp holder.
The easiest way to add a microphone to get sound from the environment with Intel Galileo is to use a USB microphone. It is also possible for you to connect an analog audio sensor to get raw audio to Intel Galileo. It will take more time to handle raw audio if you do not have much experience with audio.
After you have added a microphone or sound device, you need to add ALSA drivers to get audio from the hardware device and sound from the environment. ALSA drivers and the Linux library can be built with the Yocto Project by following the steps that were described in the previous chapters.
When we get the audio, we need to use the audio library to read sound from the ALSA driver and feed the speech recognizer. A suggested open source library for audio handling is PortAudio. For speech recognition, Sphinx is one of the most popular speech recognition libraries to use in the Linux environment. Pocketsphinx, the core of Sphinx, provides a C API to access and enable your platform for speech recognition.
More information about libraries can be found from the following links: