Pages: [1] 2 3   Go Down
Author Topic: Speech Recognition with BitVoicer and Arduino  (Read 25395 times)
0 Members and 2 Guests are viewing this topic.
Offline Offline
Newbie
*
Karma: 2
Posts: 43
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

This is the YouTube video with the result:



This is the code I created to control the leds and retrieve data from BitVoicer:

Code:
//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 = "";
    }
}

It uses the BitVoicer Arduino library that can be downloaded from BitSophia's website (http://www.bitsophia.com).

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







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).
Logged

USA, FL
Offline Offline
God Member
*****
Karma: 14
Posts: 689
A life? Where can I download one of those?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How is the Arduino wired to hear your voice?  I do not see a MIC in your Arduino schematics.  I am assuming that the Arduino has to be hooked to a computer to get the info from BitVoicer.
Logged

//LiNK

Global Moderator
0
Offline Offline
Newbie
*****
Karma: 0
Posts: 40
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have sent your question to the company behind BitVoicer, but from the description on the web and the contents of their Arduino library it appears to be as you say:

BitVoicer is a Windows executable which can recognize speech and send  results to a serial port. In this since there is nothing very Arduino specific about it; however, the website provides an Arduino library, very prominently included in the main download section, and someone (perhaps the same person) has also written this nice tutorial.

Good documentation and a well written tutorial are certainly to be appreciated. This might be useful to newcomers to Arduino who need to get voice recognition integrated into an Arduino project with very little time to spend, and have access to a Windows PC.

Mind you, I have not tested this software (nor can I, I'm exclusively Linux), so I'm just responding to what I see in this thread and on the BitVoicer website.
Logged

USA, FL
Offline Offline
God Member
*****
Karma: 14
Posts: 689
A life? Where can I download one of those?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yea I didn't thoroughly read the website.  I am in need of a voice recognition system that is Arduino compatible.  I currently designing around the EasyVR.  The only downfall is that it's Speaker dependent.  If I program my voice then it only responds to my voice..  I want it to recognize anyone. 

I am trying to keep this project independent from a PC, but it may will not be able since there will be face recognition also.  So it may not matter that it's PC dependent.

PS: I am designing a humanoid robot.  So far there are 3 Arduinos (actually custom PCB with Atmel MCUs) connected through Serial for the control.
Logged

//LiNK

Offline Offline
Newbie
*
Karma: 2
Posts: 43
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just looked at BitSophia's website and they released a new version of BitVoicer. Now it can recognize speech captured by a microphone hooked to the Arduino. I'm going to try this new version and order a wireless module (https://www.sparkfun.com/products/10822) from Sparkfun.

I want to voice control some things at home. Any suggestions on how to connect them to Arduino?
Logged

Offline Offline
Newbie
*
Karma: 2
Posts: 43
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I added an electret microphone and wireless communication to this project so that the Arduino does not have to be physically connected to the computer. Here is the link to the new project: http://arduino.cc/forum/index.php/topic,140765.0.html
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey, so I tried to upload your sketch, and I got the error "bitvoicerserial does not name a type"? any ideas?
Logged

Offline Offline
Newbie
*
Karma: 2
Posts: 43
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you downloaded the 1.1 version of BitVoicer, you have to use the BitVoicer11.h library. Also, The code in this sketch is no longer supported by the new version. Use the code in this post instead: http://arduino.cc/forum/index.php/topic,140766.msg1072337.html#msg1072337, but if you are not using an electret microphone, you will have to make some changes to the code.
« Last Edit: January 30, 2013, 10:58:54 am by msb4180 » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

where is the library? also, is it not possible to use a mic connected to my computer? id like to not have to buy anything new, as I just want to test this software out.
Logged

Offline Offline
Newbie
*
Karma: 2
Posts: 43
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The "BitVoicer11.h" library can be found in the "Library" folder located inside the BitVoicer's installation folder.
Yes, you can use your computer's mic. Just set it as the audio input in the preferences.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the code written is giving error and #include<BitVoicer.h> is not poping up in a different colour in arduino editor
i have interfaced the library of bitvoicer to arduino and will this problem be solved if i buy the product key for bit voicer?

please respond as fast as possible smiley
Logged

Offline Offline
Newbie
*
Karma: 2
Posts: 43
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have already answerd this question, but ...

If you downloaded the 1.1 version of BitVoicer, you have to use the BitVoicer11.h library. Also, The code in this sketch is no longer supported by the new version. Use the code in this post instead: http://arduino.cc/forum/index.php/topic,140766.msg1072337.html#msg1072337; but if you are not using an electret microphone, you will have to make some changes to the code.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Dear BitVoicer Guru,

I downloaded your product last night and have been working with it a little bit. I noticed from the other posts that you have upgraded to the mic attached to the board and gone wireless. I eventually want to get to that point but I'm going to have to wait on parts to arrive in the mail. I did however want to try to get this to work as you had in your first example (mic on the computer with usb connection etc...) The problem is (as mentioned before) that the code has changed. Im new to arduino and I wouldn't mind trying to tear apart the code, and compare to the old code so that I can use the mic on the computer and the newer BitVoicer 1.1 download. I'll probably start on tearing it apart tomorrow, just wondering if you had any suggestions as to where to start and as to what changes to make to the newer code, so that I can use the mic on the computer. Also do you think it would work if instead of the mic (newer version) I could replace it with an audio jack and plug in a headset with a mic?

Thanks for anyone who wants to comment on this.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

After going through a bunch of the code I think I found something. Let me know if you think this is the right way to go about it.

In the wireless version:
BitVoicerSerial bvSerial = BitVoicerSerial(); // Instantiates the BitVoicerSerial class

And in the older version:
BitVoicerSerial bvSerial = BitVoicerSerial(0); // Instantiates the BitVoicerSerial class and sets serial to port 0

Could I make the change (adding in the 0) to the wireless version and have it read in the mic data that my computer sends it from BitVoicer?

nvm, ran it on the arduino checker and there is no BitVoicerSerial(int) function. Was there one in the older version?
« Last Edit: February 07, 2013, 01:02:26 am by rsmall » Logged

Offline Offline
Newbie
*
Karma: 2
Posts: 43
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The new version of the BitVoicerSerial class does not take any parameters, so you can not add 0 to the wireless version of the code. Only the old version would take an int value.

I found the code bellow in the BitVoicer's user manual. It uses the computer's mic to capture audio and does not use a wireless connection (the simplest setup possible). They have another sample code in the manual. I think you should take a look at it (section 5.5).

Code:
//Imports the BitVoicer library to the sketch
#include <BitVoicer11.h>

//Instantiates the BitVoicerSerial class
BitVoicerSerial bvSerial = BitVoicerSerial();

//Stores the data type retrieved by getData()
byte dataType = 0;
//Stores the state of pin 4
byte pinVal = 0;

void setup()
{
  //Starts serial communication at 9600 bps
  Serial.begin(9600);
  //Sets digital pin 4 as OUTPUT
  pinMode(4, OUTPUT);
  //Turns off pin 4
  digitalWrite(4, pinVal);
}

void loop()
{
  //Updates the state of pin 4 on every loop
  digitalWrite(4, pinVal);
}

//This function runs every time serial data is available
//in the serial buffer after a loop
void serialEvent()
{
  //Reads the serial buffer and stores the received data type
  dataType = bvSerial.getData();

  //Checks if the data type is the same as the one in the
  //Voice Schema
  if (dataType == BV_BYTE)
  {
    //Checks the stored value in byteData by getData() and
    //changes the value of the pin
    if (bvSerial.byteData == 0)
      pinVal = LOW;
    else
      pinVal = HIGH;
  }
}
Logged

Pages: [1] 2 3   Go Up
Jump to: