DesignSpark Electrical Logolinkedin
Menu Search
Ask a Question

29 Jan 2019, 16:17

Getting to Know the Grove Speech Recognizer Kit for Arduino

A first look, trying out the different modules and building a voice-controlled MP3 Player.

In a previous blog post, I looked at the Grove Starter Kit for Arduino and was impressed by how quick and easy it was to get simple projects up and running. This gave me a taste for Seeed’s Grove system, so I thought I would see what a different kit had to offer. The audio-related applications of the Speech Recognizer appealed to me.

What is in the Box

The Speech Recognizer Kit (174-3226)  comes packed in Grove’s customary transparent green box and contains a Base Shield and one each of the Infrared Receiver, Infrared Send, MP3 Player, RTC (Real-time Clock) and Voice Recognizer Modules as well as the necessary cables. I noticed that the RTC Module needed a CR1225 Lithium cell which is not included, so I’m glad I did not open the kit on Christmas morning!

The Modules

The Grove system uses its Base Shield as an easy way to connect the various modules to an Arduino. I generally found it beneficial to go through the information and examples for each module individually, before going ahead with the examples provided for the Kit.

Infrared Emitter and Infrared Receiver

The introduction to the infrared modules on the Seeed Grove wiki uses both the send and receive modules get 2 Arduinos to talk to each other. Luckily I had another Base Shield from the Starter Kit, but it is possible to connect the modules directly to an Arduino if you are not so fortunate.

The Infrared Receiver connects to port D2 on the Base Shield.

The Emitter connects to port D3.

I downloaded the Grove Infrared Library from GitHub and installed it in Arduino IDE. The Library also includes example sketches — one for each of the modules — and so it was just a case of opening each example in turn and uploading it to the Arduino with the matching module connected. Once that is done, point the two modules at each other and then open the Serial Monitor in the Arduino IDE. Set the baud rate to 115200 if it is not already, and you should see the following:

RTC Module

Once I had got hold of the right battery and installed it I could try out the RTC module. Again it was a case of following the instructions on the Seeed Wiki, which entailed downloading and installing the libraries, and then opening and uploading the example Sketch after editing the following lines to set right time.

clock.fillByYMD(2013,1,19); //Jan 19,2013

clock.fillByHMS(15,28,30); //15:28 30"

clock.fillDayOfWeek(SAT); //Saturday

I could then see in the Serial Monitor window the correct time being output.

Speech Recognizer

The Speech Recogniser is pre-set to respond to 22 different commands.

I followed the getting started instructions and uploaded the provided sketch to the Arduino.

I always feel a bit self-conscious asking bits of electronics to do things for me, although I am quite happy to yell abuse at inanimate objects that are not co-operating in one way or the other.

Saying “Hicell” to the module should catch its attention and you can tell when it is listening as a red LED lights up. If you then give it one of the predefined commands it should, as in this example, print the command in the Serial Monitor window.

Do make sure that this time the baud rate is set to 9600.

I found that the Hicell command worked best when I was close to the microphone. It did once confuse “Go” with “Down”, but for the most part, as long as I spoke clearly it recognized what I said. I am guessing it is more suited to projects where the microphone is close to the user, such as the project in the video below where it is mounted on the handlebars of a scooter, rather than placed in a room in the style of Siri/Alexa et al.

 

 MP3 Player

The MP3 Player module stores music on a Micro SD card and will play MP3, WAV and WMV files. Audio output is via a 3.5mm stereo jack. Again there are Libraries to download and install and a clear set of instructions to follow.

As with previous examples, the Serial Monitor is used to interact with the module, via simple commands sent to the player to Play, Pause, Resume etc. I made sure the Serial Monitor was set to 9600 baud, sent the command “P” and, sure enough, music played through the headphones.

Now to try the player with voice commands.

Making a Voice Controlled MP3 Player

The instructions for the Kit include setting up voice control to turn your TV on and off and building a voice-controlled MP3 player. I had a quick go at the TV project, but interfering with viewing the final series of Fortitude proved not very popular and anyway, if you have read my previous blog posts, it will be no surprise that I was more interested in the music related project. The voice recognition module also has more music related voice commands to play with.

The part of the Wiki that explains how to set up and run the Voice Controlled MP3 Player has not been very well translated and can be a bit difficult to follow. I plugged the MP3 Player into port D2 of the Base Shield and the Speech Recognizer into D5. I copied some music files to a Micro SD card. If you want to specify a music track to play, the files need to be renamed so they begin with a number. For example the line in a sketch:

SpecifyMusicPlay(1);

Will play a music file named 001****.mp3

I renamed a couple of tracks but left the others to see what the Player would do.

This is the part of the sketch that specifies the voice commands:

void loop()
{
    int a=0;
    if(speech.available())
    {
        a = speech.read();   // Read the return value from the Speech Recognizer
        switch (a)
        {
            case 3:      //  speech command : Play music
            SpecifyMusicPlay(1);   // MP3: play the name of "001"
            break;
            case 4:   //  speech command : Pause
            PlayPause();    // MP3: pause music
            break;
            case 19:   //  speech command : Start
            PlayResume();  // MP3: continue music
            break;
            case 5:   //  speech command : Next
            PlayNext();    // MP3: play next song
            break;
            case 6:   //  speech command : Previous
            PlayPrevious();  // MP3: play previous song
            break;
            default:
            break;
        }

Once the example Sketch was uploaded I said “Hicell” followed by “Play Music” and that is just what it did. I ran through the other voice commands and it responded as expected. Saying “Next” played the next numbered track but I could not get it to play the songs that I had left with their original file names. I wondered if I used the “Loop” command I could persuade it to play those neglected tracks. I Edited the Sketch to add a couple of lines:

case 12: //speech command : Go

PlayLoop(); // MP3: loop all songs

I removed the numbered tracks from the Micro SD card, tried the “Go” voice command and sure enough, it played the tracks. Although this removes some element of choice over what you want to listen to, it also means that you do not have to rename all your music files which, especially if you are going to put a large number on your SD card, is a tremendous advantage.

Practical Application

It occurred to me that this could work well with the voice recognition microphone clipped on to the collar of a jacket and the MP3 player itself tucked away in a pocket, running on a 9V battery and making it easy to play tunes when you are out and about. The Voice recognizer module would need a long cable and it looks like the longest Seeed do is 50cm (179-3728) , but it would be easy to make a longer one using 2 of the Conversion Cables (179-3734)  or fashion a coupler to join cables from the appropriate sockets (179-3735) . Put it in a sturdy case and it could be just what you need to motivate you on your New Year’s resolution fitness regime.

I currently look after production at AB Open. I have a background in the arts, environmental conservation and IT support. In my spare time I do a bit of DJing and I like making things.

29 Jan 2019, 16:17