In this blog post I will show you how to control some Neopixels using your voice, using one Flip & click, one 4×4 RGB click board and the Speakup click from MikroElektronika.
In my previous blog post I wrote a bit about using the SpeakUp click in an Arduino environment, focusing on potential problems related to logic levels. Shortly, the SpeakUp click has three pins that are 3.3V only, thus its use with Arduino Uno boards is quite difficult, and you can easily damage your SpeakUp click board.
Initially, I wanted to use a 3.3V Arduino Pro, but that board is 3.3V only, The SpeakUp click will work fine with the Arduino Pro. On the other hand, the 4×4 RGB click needs both 5V (for LED power supply) and 3.3V (for control logic). So, the Arduino Pro won’t work in this project.
I’m left with two possible choices: Arduino Due plus Arduino Mega Click Shield, or the Flip & Click. I close the latter, as it’s a cheaper option.
As usual, it’s just like playing with Lego: 4×4 RGB LED click goes into mikroBUS socket #1, while the SpeakUp click goes into mikroBus socket #2. Simple as this.
But what about software? Well, there are two issues to solve: programming the SpeakUpo click and writing the Arduino code.
Programming the SpeakUp click
The SpeakUp click is programmed using the PC software provided by MikroElektronika. So, download and install the software.
The SpeakUp Firmware uses Dynamic Time Warping (DTW) algorithm – word-based, isolated word, speaker dependent and template matching algorithm:
- In the word based speech recognition the smallest recognition unit is a word
- In the isolated word recognition, words that are uttered with short pauses are recognized,
- Speaker dependent reference patterns are constructed for a single speaker,
- Template matching algorithm is a form of pattern recognition. It represents speech data as sets of feature/parameter vectors called templates. Each word or phrase in an application is stored as a separate template. The input speech is then compared with stored templates and the stored template most closely matching the incoming speech pattern is identified as the input word or phrase.
Before going into programming, one must choose the command words. Try to choose words that are as dissimilar to each other as possible, thus increasing the chance of a good recognition. My commands are “white”, “red”, “green”, “blue”, “brighter”, “dimmer”, and “turn off”. Note that I don’t use bright as it’s just too similar with white.
Once you connect the SpeakUp click it will perform ambient noise detection. This takes about 20 seconds, during which the SpeakUp click will appear unresponsive. Just give it enough time and it will start.
Next, we create a new project and we go to Settings. My settings are: Acceptance threshold = 50; Recording timeout = 5s; Word length = 1.5; Noise Level = Auto; Notify mater = UART; Data rate = 9600 baud.
When we connect the SpeakUp click it will perform ambient noise detection. This takes about 20 seconds, during which the SpeakUp click will appear unresponsive.
Then we can create a new project, and we go to settings. I used Acceptance threshold = 50; Recording timeout = 5s; Word length = 1.5s; Noise level = Auto; Notify master = UART; Data rate = 9600.
The next step is to record the commands. Keep the SpeakUp click close to your mouth (5-6 cm works fine) and speak loudly and clear. Listen to the recorded voice and record it again if the level is too low of it’s not clear.
Note that the DTW algorithm used by the SpeakUp click is speaker-specific. If you have multiple users, you have to record the same command for each speaker. Thus, a command can have multiple numeric indices. This can be later solved in the Arduino code.
Once everything is fine, save your project, upload the code to the SpeakUp click and export the constants. This latter step creates a .c file with the numeric correspondence of each command.
This file is generated by SpeakUp Software. It containts voice commands constants.
Creation date: 5/30/2017
Creation time: 10:08:22 AM
Length: 1.5 s
const VCMD_WHITE = 0;
Length: 1.5 s
const VCMD_RED = 1;