Speech Recognition With BitVoicer and Arduino
Intro: 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:
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
//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 sketch uses the BitVoicer Arduino Library that can be downloaded from their website: www.bitsophia.com.
The BitVoicer Voice Schema that recognizes the speech shown in the video is available at: http://www.justbuss.xpg.com.br/BitVoicerTest.zip (you need to have BitVoicer installed in order to open it).
I hope you guys have fun with it!
Here is the YouTube video with the results:
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
//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 sketch uses the BitVoicer Arduino Library that can be downloaded from their website: www.bitsophia.com.
The BitVoicer Voice Schema that recognizes the speech shown in the video is available at: http://www.justbuss.xpg.com.br/BitVoicerTest.zip (you need to have BitVoicer installed in order to open it).
I hope you guys have fun with it!
51 Comments
ShubhamK178 6 years ago
I need total information about how to use this software and how to connect it with arduino.
VintD 7 years ago
and resistor is 330 ohm?
suryak53 7 years ago
dude, i have a question. bitvoicer runs in the pc, but i want to run the project separately without connecting aurdino to the pc? now will the bitvoicer library be loaded in aurdino? ( i ll give the power to the aurdino via adapter)
sentiner 7 years ago
Should i connect the arduino to the computer???
ValentinaM22 7 years ago
Instead of using a voice, can I just use a harmony (a few keys) from my Clarinet?
paulrobert27 7 years ago
I have a question my friend. Will i have to open the sketch and the Bitvoicer when do i run the project?
leandro4b 7 years ago
You do not have to open the sketch (Arduino IDE), but BitVoicer must be open and running. If you use BitVoicer Server, you do not have to open anything.
paulrobert27 7 years ago
Thanks very much leandro4b. I asked that because I haven't made the project yet. =).
paulrobert27 7 years ago
Thanks very much leandro4b. I asked that because I haven't made the project yet. =).
ARYANB12 7 years ago
leandro4b 7 years ago
To enable communication with your Arduino, yes.
PandulaM 8 years ago
I have problem in this line
BitVoicerSerial bitVoicer = BitVoicerSerial(0);
and I try to solve it. but failed. Please help me
leandro4b 8 years ago
The code on this Instructable no longer works with the new BitVoicer library. Take a look at the example on this other Instructable and make the appropriate adjustments to the code.
PandulaM 7 years ago
thank you very much.
adeelsaqib 8 years ago
I have a problem.. when i upload this program to arduino... i got an error of
#include <BitVoicer.h>
can you help me plzzzz it's urgently...
leandro4b 8 years ago
What is the exact error message? Have you placed all the library files in the right folder? More information here: http://www.arduino.cc/en/Guide/Libraries
adeelsaqib 8 years ago
sir plzzz help me
chiragc1 8 years ago
shows error on compiling
error:'BitVoicerSerial' does not name a type????..pls help
leandro4b 8 years ago
Chiragc, this post is too old and the last BitVoicer version no longer has the BitVoicer.h library. Take a look at this post: https://www.instructables.com/id/Speech-Recognition-with-Arduino/. It is newer and uses the current version of the BitVoicer library.
MAE38415 8 years ago
I Do I need to connect arduıno to computer for this project? please answer quick . It's important to me.