Let's Make Robots!

Speech Recognition with BitVoicer and Arduino

The main goal of this project was to test the speech recognition performance of BitVoicer (http://www.bitsophia.com/BitVoicer.aspx). For this purpose, I designed a simple led control sketch which I integrated with BitVoicer. Of course you can do anything you want once you have received the commands from Bitvoicer, but to keep things simple, I thought a led test would do just fine.

Here is the YouTube video with the results: http://www.youtube.com/watch?v=gs-3fJCa5P0

The Voice Schema used in this project can be downloaded from http://www.justbuss.xpg.com.br/BitVoicerTest.zip (you need to have BitVoicer installed in order to open it)

This is the Arduino sketch that controls the leds and retrieves data sent from BitVoicer:

//Includes the BitVoicer library to the sketch

#include <BitVoicer.h>

//Sets up the pins and default variables
int pinR = 3;
int pinY = 5;
int pinG = 6;
int blinkDelay = 250;
int sequenceDir = 0;
int lightLevel = 0;

//Creates a new instance of the BitVoicerSerial class and
//sets up serial port to 0
BitVoicerSerial bitVoicer = BitVoicerSerial(0);

void setup()
{
    //Starts serial communication and sets up the pinModes
    Serial.begin(9600);
    pinMode(pinR, OUTPUT);
    pinMode(pinY, OUTPUT);
    pinMode(pinG, OUTPUT);
}

void loop()
{
    //Retrieves data from serial buffer
    bitVoicer.getData();

    //Quits the loop if no string data was returned from getData
    if (bitVoicer.strData == "")
    {
        return;
    }

    //Each of the next 'if' statements performs a different
    //task based on the data received from BitVoicer
    if (bitVoicer.strData == "wake")
    {
        digitalWrite(pinR, LOW);
        digitalWrite(pinY, LOW);
        digitalWrite(pinG, LOW);
        digitalWrite(pinR, HIGH);
        digitalWrite(pinY, HIGH);
        digitalWrite(pinG, HIGH);
        delay(200);
        digitalWrite(pinR, LOW);
        digitalWrite(pinY, LOW);
        digitalWrite(pinG, LOW);
        delay(200);
        digitalWrite(pinR, HIGH);
        digitalWrite(pinY, HIGH);
        digitalWrite(pinG, HIGH);
        delay(200);
        digitalWrite(pinR, LOW);
        digitalWrite(pinY, LOW);
        digitalWrite(pinG, LOW);
        delay(200);
        digitalWrite(pinR, HIGH);
        digitalWrite(pinY, HIGH);
        digitalWrite(pinG, HIGH);
        delay(200);
        digitalWrite(pinR, LOW);
        digitalWrite(pinY, LOW);
        digitalWrite(pinG, LOW);
        bitVoicer.strData = "";
        lightLevel = 0;
    }
    else if (bitVoicer.strData == "sleep")
    {
        digitalWrite(pinR, LOW);
        digitalWrite(pinY, LOW);
        digitalWrite(pinG, LOW);
        digitalWrite(pinR, HIGH);
        digitalWrite(pinY, HIGH);
        digitalWrite(pinG, HIGH);
        delay(200);
        digitalWrite(pinR, LOW);
        digitalWrite(pinY, LOW);
        digitalWrite(pinG, LOW);
        delay(200);
        digitalWrite(pinR, HIGH);
        digitalWrite(pinY, HIGH);
        digitalWrite(pinG, HIGH);
        delay(200);
        digitalWrite(pinR, LOW);
        digitalWrite(pinY, LOW);
        digitalWrite(pinG, LOW);
        bitVoicer.strData = "";
        lightLevel = 0;
    }
    else if (bitVoicer.strData == "RH")
    {
        digitalWrite(pinR, HIGH);
        bitVoicer.strData = "";
        lightLevel = 255;
    }
    else if (bitVoicer.strData == "RL")
    {
        digitalWrite(pinR, LOW);
        bitVoicer.strData = "";
        lightLevel = 0;
    }
    else if (bitVoicer.strData == "YH")
    {
        digitalWrite(pinY, HIGH);
        bitVoicer.strData = "";
        lightLevel = 255;
    }
    else if (bitVoicer.strData == "YL")
    {
        digitalWrite(pinY, LOW);
        bitVoicer.strData = "";
        lightLevel = 0;
    }
    else if (bitVoicer.strData == "GH")
    {
        digitalWrite(pinG, HIGH);
        bitVoicer.strData = "";
        lightLevel = 255;
    }
    else if (bitVoicer.strData == "GL")
    {
        digitalWrite(pinG, LOW);
        bitVoicer.strData = "";
        lightLevel = 0;
    }
    else if (bitVoicer.strData == "blink")
    {
        digitalWrite(pinR, HIGH);
        digitalWrite(pinY, HIGH);
        digitalWrite(pinG, HIGH);
        delay(blinkDelay);
        digitalWrite(pinR, LOW);
        digitalWrite(pinY, LOW);
        digitalWrite(pinG, LOW);
        delay(blinkDelay);
        lightLevel = 255;
    }
    else if (bitVoicer.strData == "BF")
    {
        blinkDelay = 100;
        bitVoicer.strData = "blink";
        lightLevel = 255;
    }
    else if (bitVoicer.strData == "BFF")
    {
        switch (blinkDelay)
        {
            case 500:
                blinkDelay = 250;
                break;
            case 250:
                blinkDelay = 100;
                break;
            default:
                break;
        }
        bitVoicer.strData = "blink";
        lightLevel = 255;
    }
    else if (bitVoicer.strData == "BS")
    {
        blinkDelay = 500;
        bitVoicer.strData = "blink";
        lightLevel = 255;
    }
    else if (bitVoicer.strData == "BSS")
    {
        switch (blinkDelay)
        {
            case 100:
                blinkDelay = 250;
                break;
            case 250:
                blinkDelay = 500;
                break;
            default:
                break;
        }
        bitVoicer.strData = "blink";
        lightLevel = 255;
    }
    else if (bitVoicer.strData == "sequence")
    {
        if (sequenceDir == 0)
        {
            digitalWrite(pinR, HIGH);
            delay(250);
            digitalWrite(pinR, LOW);
            digitalWrite(pinY, HIGH);
            delay(250);
            digitalWrite(pinY, LOW);
            digitalWrite(pinG, HIGH);
            delay(250);
            digitalWrite(pinG, LOW);
        }
        else
        {
            digitalWrite(pinG, HIGH);
            delay(250);
            digitalWrite(pinG, LOW);
            digitalWrite(pinY, HIGH);
            delay(250);
            digitalWrite(pinY, LOW);
            digitalWrite(pinR, HIGH);
            delay(250);
            digitalWrite(pinR, LOW);
        }
        lightLevel = 255;
    }
    else if (bitVoicer.strData == "revert")
    {
        if (sequenceDir == 0)
        {
            sequenceDir = 1;
        }
        else
        {
            sequenceDir = 0;
        }
        bitVoicer.strData = "sequence";
        lightLevel = 255;
    }
    else if (bitVoicer.strData == "ALLON")
    {
        digitalWrite(pinR, HIGH);
        digitalWrite(pinY, HIGH);
        digitalWrite(pinG, HIGH);
        bitVoicer.strData = "";
        lightLevel = 255;
    }
    else if (bitVoicer.strData == "ALLOFF")
    {
        digitalWrite(pinR, LOW);
        digitalWrite(pinY, LOW);
        digitalWrite(pinG, LOW);
        bitVoicer.strData = "";
        lightLevel = 0;
    }
    else if (bitVoicer.strData == "brighter")
    {
        if (lightLevel < 255)
        {
            lightLevel += 85;
            analogWrite(pinR, lightLevel);
            analogWrite(pinY, lightLevel);
            analogWrite(pinG, lightLevel);
        }
        bitVoicer.strData = "";
    }
    else if (bitVoicer.strData == "darker")
    {
        if (lightLevel > 0)
        {
            lightLevel -= 85;
            analogWrite(pinR, lightLevel);
            analogWrite(pinY, lightLevel);
            analogWrite(pinG, lightLevel);
        }
        bitVoicer.strData = "";
    }
    else
    {
        Serial.println("ERROR:" + bitVoicer.strData);
        bitVoicer.strData = "";
    }
}

This is the basic layout of this project. I also added a couple of pictures of the connected wires bellow the layout.

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

On this post: http://letsmakerobots.com/node/35671; I used a wireless WiFly module from Rovio, so I do not need to be physically connected to the PC anymore. I simply use my home wireless network. BitVoicer also supports TPC/IP communication.

Duane Degn's picture

Thanks leandro4b. Being able to access the a PC wirelessly does increase BitVoicer usefulness.

I still keep hoping to find an alternative to EasyVR which can run independent of a PC.

Duane Degn's picture

Thanks Maxihez. I was afraid that was the case.

So while BitVoicer can be useful in some applications, it's not a replacement for an EasyVR module.

Maxhirez's picture
The PC is doing he heavy lifting here. The bitsophia website is pretty clear on that-the Arduino has to be attached to the PC serially for the voice recognition to work. You can run the microphone through the Arduino or use one directly through the PC though.
Duane Degn's picture

Thanks for posting this leandro4b.

Your recent reply in this thread got me wondering about the BitVoicer.

I don't think I understand fully the way this works. BitVoicer is software only correct?

I'm confused about what how much the PC does in the voice recognition vs how much the PC does. Does the Arduino have to be connected to the PC in order to recognize your speech?

Yes, BitVoicer is software only and all the speech processing is performed by it. The Arduino board only captures the audio, sends it to the computer and waits for an answer.