Instructables

Speech Recognition with Arduino

Picture of Speech Recognition with Arduino
BitVoicerTest2_2_800x600.jpg
BitVoicerTest2_1_800x600.jpg
In this project I use BitVoicer’s speech recognition features (http://www.bitsophia.com/BitVoicer.aspx), one Arduino board and one electret microphone (https://www.sparkfun.com/products/9964) to control a few LEDs.

This project is similar to the one in my first post (http://www.instructables.com/id/Speech-Recognition-with-BitVoicer-and-Arduino/), but now I use audio streaming to send audio to BitVoicer.

The fritzing schematic I added to this instructable shows how I wired my Arduino board.

I’m also adding a few pictures and a YouTube video of the project running.


Unfortunately, the sketch I wrote for my first post is no longer supported by the new version of BitVoicer. Here is the new sketch:

#include <BitVoicer11.h>

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

//Stores true if the Audio Streaming Calibration tool
//is running
boolean sampleTest = false;
//Stores the data type retrieved by getData()
byte dataType = 0;
//Sets up the pins and default variables
int pinR = 3;
int pinY = 5;
int pinG = 6;
int lightLevel = 0;

void setup()
{
  //Sets the analog reference to external (AREF pin)
  //WARNING!!! If anything is conected to the AREF pin,
  //this function MUST be called first. Otherwise, it will
  //damage the board.
  bvSerial.setAnalogReference(BV_EXTERNAL);
  //Sets up the microcontroller to perform faster analog reads
  //on the specified pin
  bvSerial.setAudioInput(0);
  //Starts serial communication at 115200 bps
  Serial.begin(115200);
  //Sets up the pinModes
  pinMode(pinR, OUTPUT);
  pinMode(pinY, OUTPUT);
  pinMode(pinG, OUTPUT);
}

void loop()
{
  //Captures audio and sends it to BitVoicer if the Audio
  //Streaming Calibration Tool is running
  if (sampleTest == true)
  {
    //The value passed to the function is the time
    //(in microseconds) that the function has to wait before
    //performing the reading. It is used to achieve about
    //8000 readings per second.
    bvSerial.processAudio(46);
  }
 
  //Captures audio and sends it to BitVoicer if the Speech
  //Recognition Engine is running
  if (bvSerial.engineRunning)
  {
    //The value passed to the function is the time
    //(in microseconds) that the function has to wait before
    //performing the reading. It is used to achieve about
    //8000 readings per second.
    bvSerial.processAudio(46);
  }
}

//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();
 
  //Changes the value of sampleTest if the received data was
  //the start/stop sampling command
  if (dataType == BV_COMMAND)
      sampleTest = bvSerial.cmdData;
 
  //Signals BitVoicer's Speech Recognition Engine to start
  //listening to audio streams after the engineRunning status
  //was received
  if (dataType == BV_STATUS && bvSerial.engineRunning == true)
    bvSerial.startStopListening();
 
  //Checks if the data type is the same as the one in the
  //Voice Schema
  if (dataType == BV_STR)
    setLEDs();
}

//Performs the LED changes according to the value in
//bvSerial.strData
void setLEDs()
{
  if (bvSerial.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);
    lightLevel = 0;
  }
  else if (bvSerial.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);
    lightLevel = 0;
  }
  else if (bvSerial.strData == "RH")
  {
    digitalWrite(pinR, HIGH);
    lightLevel = 255;
  }
  else if (bvSerial.strData == "RL")
  {
    digitalWrite(pinR, LOW);
    lightLevel = 0;
  }
  else if (bvSerial.strData == "YH")
  {
    digitalWrite(pinY, HIGH);
    lightLevel = 255;
  }
  else if (bvSerial.strData == "YL")
  {
    digitalWrite(pinY, LOW);
    lightLevel = 0;
  }
  else if (bvSerial.strData == "GH")
  {
    digitalWrite(pinG, HIGH);
    lightLevel = 255;
  }
  else if (bvSerial.strData == "GL")
  {
    digitalWrite(pinG, LOW);
    lightLevel = 0;
  }
  else if (bvSerial.strData == "ALLON")
  {
    digitalWrite(pinR, HIGH);
    digitalWrite(pinY, HIGH);
    digitalWrite(pinG, HIGH);
    lightLevel = 255;
  }
  else if (bvSerial.strData == "ALLOFF")
  {
    digitalWrite(pinR, LOW);
    digitalWrite(pinY, LOW);
    digitalWrite(pinG, LOW);
    lightLevel = 0;
  }
  else if (bvSerial.strData == "brighter")
  {
    if (lightLevel < 255)
    {
      lightLevel += 85;
      analogWrite(pinR, lightLevel);
      analogWrite(pinY, lightLevel);
      analogWrite(pinG, lightLevel);
    }
  }
  else if (bvSerial.strData == "darker")
  {
    if (lightLevel > 0)
    {
      lightLevel -= 85;
      analogWrite(pinR, lightLevel);
      analogWrite(pinY, lightLevel);
      analogWrite(pinG, lightLevel);
    }
  }
  else
  {
    bvSerial.startStopListening();
    bvSerial.sendToBV("ERROR:" + bvSerial.strData);
    bvSerial.startStopListening();
  }
}


The BitVoicer Voice Schema I used can be downloaded from: http://www.justbuss.xpg.com.br/BitVoicerTest2.zip (you need to have BitVoicer installed to be able open it).

Now I want to control a few things (lights and celling fan) at home. Suggestions are very welcome.
soniiasosa7 days ago

Hi!!! We are trying to use the speech recognition feature for a project, we bought the program, the microphone, and we connect everything but it seems not to work... What resistors are you using?? We are also using a sensor shield.. but we are connecting it to A0, just like yours.. If you can help us it will be awesome!!! PS: we are using your BitVoicer program and your arduino code

leandro4b (author)  soniiasosa3 days ago

I used 330 ohm resistors for the LEDs. Is the calibration tool showing any readings?

mina samy16 days ago

hey , I have a problem with BitVoicer that i cant find the activation key in any place to activate the program and start my work .. please tell me where can I find it .. thanks in advance :)

leandro4b (author)  mina samy3 days ago

You have to buy the product key from their website.

donromeo22 days ago

Great work Leandro.

Got BitVoicer, bought myself a license, activated it, ran it as administrator, installed Spanish library, but then ...

... when I click the link for the Voice Schema nothing happens. (Same for the old version and same for the wireless version)

I'm Arduino proficient, so as soon as I learn how to use your Voice Schema I'll be able to make it work. Please give me a hint on how to download your schema.

Thanks for the help.

Romeo

leandro4b (author)  donromeo20 days ago

Do your mean the Voice Schema link in the end of the post? It is working here?!

Yes, the link does not work, it produces a blank page. I tried both Chrome and IE. I tried even wget and what I get is a zero sized file.

leandro4b (author)  donromeo19 days ago

Well, I just checked again and it is working here. The files are available and the downloaded ZIP has a functional voice schema. Is anybody else unable to download the file?

Never mind, I learned from the BitVoicer examples how to write my own.

Thanks anyways.

mcaro229 days ago

Hey, I am trying to replicate this project but I don't know these programs. Do you have a list of steps I can follow in order to not get lost? You dont have steps but if you do can you please share? Its awesome btw!

asd2u20043 months ago

hello , i'm trying to compile the code but I have this issue

Arduino: 1.5.5-r2 (Windows 8), Board: "Arduino Duemilanove or Diecimila, ATmega328"

C:\Program Files (x86)\Arduino\libraries\BitVoicer11\BitVoicer11.cpp: In constructor 'BitVoicerSerial::BitVoicerSerial()':

C:\Program Files (x86)\Arduino\libraries\BitVoicer11\BitVoicer11.cpp:20: error: ambiguous overload for 'operator=' in '((BitVoicerSerial*)this)->BitVoicerSerial::strData = 0'

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:86: note: candidates are: String& String::operator=(const String&)

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:87: note: String& String::operator=(const char*)

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:88: note: String& String::operator=(const __FlashStringHelper*)

C:\Program Files (x86)\Arduino\libraries\BitVoicer11\BitVoicer11.cpp: In member function 'void BitVoicerSerial::setData(byte, int)':

C:\Program Files (x86)\Arduino\libraries\BitVoicer11\BitVoicer11.cpp:108: error: ambiguous overload for 'operator=' in '((BitVoicerSerial*)this)->BitVoicerSerial::strData = 0'

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:86: note: candidates are: String& String::operator=(const String&)

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:87: note: String& String::operator=(const char*)

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:88: note: String& String::operator=(const __FlashStringHelper*)

C:\Program Files (x86)\Arduino\libraries\BitVoicer11\BitVoicer11.cpp:125: error: ambiguous overload for 'operator=' in '((BitVoicerSerial*)this)->BitVoicerSerial::strData = 0'

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:86: note: candidates are: String& String::operator=(const String&)

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:87: note: String& String::operator=(const char*)

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:88: note: String& String::operator=(const __FlashStringHelper*)

C:\Program Files (x86)\Arduino\libraries\BitVoicer11\BitVoicer11.cpp:135: error: ambiguous overload for 'operator=' in '((BitVoicerSerial*)this)->BitVoicerSerial::strData = 0'

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:86: note: candidates are: String& String::operator=(const String&)

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:87: note: String& String::operator=(const char*)

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:88: note: String& String::operator=(const __FlashStringHelper*)

C:\Program Files (x86)\Arduino\libraries\BitVoicer11\BitVoicer11.cpp:145: error: ambiguous overload for 'operator=' in '((BitVoicerSerial*)this)->BitVoicerSerial::strData = 0'

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:86: note: candidates are: String& String::operator=(const String&)

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:87: note: String& String::operator=(const char*)

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:88: note: String& String::operator=(const __FlashStringHelper*)

C:\Program Files (x86)\Arduino\libraries\BitVoicer11\BitVoicer11.cpp:167: error: ambiguous overload for 'operator=' in '((BitVoicerSerial*)this)->BitVoicerSerial::strData = 0'

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:86: note: candidates are: String& String::operator=(const String&)

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:87: note: String& String::operator=(const char*)

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:88: note: String& String::operator=(const __FlashStringHelper*)

This report would have more information with

"Show verbose output during compilation"

enabled in File > Preferences.

Found the solution just put "" instead of NULL for strData in BitVoicer11.cpp

leandro4b (author) 1 year ago
I added a wireless module to this project. Here is the Instructable link: http://www.instructables.com/id/Wireless-Audio-Streaming-and-Speech-Recognition/
hello
am called ibrahim and i live in Rwanda
very interested by you technology but am stacked by two things:
- product key for bitvoicer
- sketch_nov15g:4: error: 'BitVoicerSerial' does not name a type
what can i do? the library of bitvoicer i think is missing so that the codes can work to arduino
waiting for your replay
leandro4b (author)  ibrazzis4 months ago
Well, you will have to buy the product key. The library is in the BitVoicer installation folder.
dhruvin21986 months ago
hey what material is required of this project
arduino uno rev3.0 & bit voicer do the job

leandro4b (author)  dhruvin21984 months ago
You will also need the microphone (https://www.sparkfun.com/products/9964), the LEDs and the resistors.
npyasith9 months ago
hey is there any way to do this without a computer? thanks...
leandro4b (author)  npyasith9 months ago
with this quality and flexibility, I don't think so.
do we have to buy the product key? is there any other way?
3tuxedo1 year ago
wow this is great, thanks!
WWC1 year ago
Hi
Is there going to be an XP comparability version/patch?
leandro4b (author)  WWC1 year ago
O don't know WWC. You can try to contact BitSophia at www.bitsophia.com.
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!