Introduction: Speech Recognition With Arduino

Picture of Speech Recognition With Arduino
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 (https://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.

Comments

HeathD4 (author)2016-09-08

I have been getting an error in the code...compilation terminated. exit status 1 Error compiling for board Arduino/Genuino Uno

both the arduino uno and correct com port are chosen

ArsamA1 (author)HeathD42017-11-17

I had same problem. I solved it by including library used in the code. Hope it works for u

Uddipta206UdDReX (author)HeathD42017-09-05

Try googling ur error or post in arduino forum.

TristanS50 (author)2017-11-09

Is there a way to edit what the arduino accepts as audio inputs?

SANTAMANYU GUJARI (author)2017-10-13

You can control home appliance with a relay module.

I have made an instructable tutorial on Home Automation, just check out if you need help .

Santamanyu

I have found a comment you made in 2013 - about a 100 years ago, or it seems that long. I need exactly what you wrote about. Schematics and software for a miniature device that can hear an audio codeword amongst daily normal noise and when it hears that closes a relay. Any contribution available from you as to how and what can do this?

Harold Tracey - dvrdigital@gmail.com

Aditya Tripathi (author)2017-06-04

Can this thing be wireless. I mean connected to the cloud and not to the computer

Surely you can. Nothing is impossible. but you will need more modules to fill the gap like wifi shield, etc as per ur requirement. But if you want to connect to the cloud also you will need to process the voice somewhere to make it detect as a command. So think about it

suryak53 (author)2017-03-31

Can i use bitvoicer software for speech recognition without connecting it to pc?

Then you would need to use raspberry pi instead of a pc. Arduino itself isnt capable of doing anykind of voice or image processing itself.

kypperb (author)2017-05-29

Hello, where can I get the arduino library

alexa356 (author)2017-05-16

hello there how you doing ? it is nice what you have posted. I was working on speech recognition elevator using arduino and speech recognition module v3, how can i interface these things ? I have only two weeks for defence so pleas help me ?

fahid bin tariq (author)2017-02-16

can i use android app like voicecontrolaurdino for the same code ?

MikeZ9 (author)2016-11-06

I know that BitVoicer does not fit compatibly with Mac, but is there any other similar software like BitVoicer which is compatible on Mac?

PandulaM (author)2016-05-24

can i use normal condenser microphone for it? and how?

HeathD4 (author)PandulaM2016-09-08

that is what I am trying...but I am having coding issues

HeathD4 (author)2016-09-08

I was wondering if you can make this with this mic:

http://www.ebay.com/itm/252401158657?_trksid=p2057...

I am going to try it but my problem I think I will run into would be the Pos and Neg/input(to board) I looked at this in person and online and there is no definitive markings to mark pos or neg or anything...Ideas?

ChengS1 (author)2016-06-21

my bitvoice couldnt sent any message to the serial port, is it about the activation?

should I buy it?

Bitvoice always come out SPeech rejected!!!!!!

plz help me

leandro4b (author)ChengS12016-06-22

If you do not have a license, BitVoicer will be unable to open the serial port. However, I do not think it would lead to a Speech Rejected response. I suggest you contact BitSophia for that.

shubaangi_95 (author)2016-06-11

Hi! Is it possible to make this instructable without the electret microphone? Can I use the laptop's microphone? If yes, how would the code be modified?

AtrayanM (author)2016-06-11

Well is it possible to take input and process audio data from digital pins without using the vr module or a pc?

SansithD (author)2016-05-06

Is it recommend to connect Arduino to Pc when I use this Vice Recognition?Plz....

leandro4b (author)SansithD2016-05-08

A PC running BitVoicer is required in order to use this speech recognition model. You can connect to the PC over WiFi though.

SansithD (author)leandro4b2016-05-16

Can I use Bluetooth for it?

leandro4b (author)SansithD2016-05-18

I believe you can. Just make sure your bluetooth module is capable of transmitting at least 64kbps.

SansithD (author)leandro4b2016-05-23

Thanx.. I made it with BT module HC-05

TylerL40 (author)2016-04-29

I want to make a small car which we can control through voice ... any suggestion how can i do this?

devshri (author)2016-04-22

Hey i make speech recognition with Arduino but when i up[load this coad in Arduino i got this error mesge please hepl me

Arduino: 1.6.9 Hourly Build 2016/04/13 03:33 (Windows 7), Board: "Arduino/Genuino Uno"

C:\Users\PintuDev\Downloads\arduino-nightly-windows (1)\arduino-nightly\libraries\BVS_Demo1\BVS_Demo1.ino:1:18: fatal error: BVSP.h: No such file or directory

#include <BVSP.h>

^

compilation terminated.

exit status 1

Error compiling for board Arduino/Genuino Uno.

This report would have more information with

"Show verbose output during compilation"

option enabled in File -> Preferences.

leandro4b (author)devshri2016-04-24

The BVSP class/library is used with BitVoicer Server. This post uses the old BitVoicer version. Anyway, this error seems to be related to an incorrect library installarion. You should read this: http://www.arduino.cc/en/Guide/Libraries#toc4

JeffD82 (author)2016-04-11

Hi leandro4b,

Thanks for the great tutorial. You mention below that 'you can add wireless connectivity....'. Can you elaborate on that? Do you think it's possible to send packets via WiFi to an Internet server with BitVoicer?

Thanks!

leandro4b (author)JeffD822016-04-24

I think BitVoicer was designed to run in a local network only.

JGUZMANO (author)2016-04-23

great instructable, thanks for sharing. At the moment I'm working on a project that "writes" on a screen what it is said to a mic. Any suggestions guys? Thanks in advance

adeelsaqib (author)2016-04-13

can you help me...?

DiegoA82 (author)2016-03-19

Hi, would you recommend to buy the BitVoicer Server or just the BitVoicer? I see the main difference is the speech synthesis that the BitVoicerServer has. In one of your other projects you used a speaker to interact better with the arduino, I imagine that for this feature I would be needing the BitVoicer Server, am I correct? Or would the BitVoicer be enough for both projects (this one and the one with the speaker)?

leandro4b (author)DiegoA822016-03-21

To add speech synthesis to your project, you will need the new BitVoicer Server. The old BitVoicer does not synthesize speech at all.

A.H.T.Erangad (author)2015-06-18

Hi,

I'm going to use your bitvoice library along with an Arduino for my university project.

- I want use four microphones for voice recognition.

- Also need to identify from which microphone the specified voice was identified.

would bitvoice be able to help me with any method to achieve this task by using an Arduino?

leandro4b (author)A.H.T.Erangad2016-03-02

You can achieve that using the new version. Take a look at my most recent post (https://www.instructables.com/id/Speech-Recognition-and-Synthesis-With-Arduino/) and also check the BitSophia's website.

A.H.T.Erangad (author)leandro4b2016-03-05

I actually need the voice recognition software to be in the embedded system other than using a PC to run the voice recognition software in it.
Is that possible?

HannahL27 (author)2016-02-05

Can I only download BitVoicer on a windows computer, I can't download it on a Mac. Plus, is there a free version, or can I only download the one to pay?

leandro4b (author)HannahL272016-03-02

I do not think there is a BitVoicer for Mac and I also do not know of a free version. However, you can try many of the software features using the non-paid version you can download from their website.

NHRobin (author)2016-02-13

Does it run without being connected to a computer?

leandro4b (author)NHRobin2016-03-02

No, it does not. You can add wireless connectivity to it though.

ThomasR35 (author)NHRobin2016-02-27

I would also like to know. Just looking at the code I suspect the answer is no.

felixa1 (author)2015-07-15

I hooked up the circuit, downloaded everything and found out i had to pay to activate a 10 minute arduino project???

ahbee87844 (author)2015-06-07

Manage to resolve, as i need to enable the sound recording on my pc.

Thank you it working now

ahbee87844 (author)2015-06-07

i using a 222ohm resistor should not be the problem as i tested with 1k ohm and same problem. Would appreciate help from anyone.

thank you

ShihanM (author)2015-05-25

Dear Sir,

What types of speech recognition method used here?

example:1.Statistical modeling and machine learning

2.Deep Speech: Accurate Speech Recognition with GPU-Accelerated Deep Learning

3.Signal processing dealing with noisy environments

4.Vocabulary size and diffluent speech

5.Speaker independent and adaptive speech recognition

6.Spoken language understanding and dialog

7.Finger print analysis method

Bcz I should take for Arduino uno for Engineering project.

WilliamV2 (author)2015-05-24

yo me metí de lleno al proyecto que hizo investigue y y el micrófono de arduino osea el micrófono de tres lineas lo que hace es que amplificar la señal eso es lo que hace a diferencia de un micrófono normal que solo tiene voltaje y tierra lo que yo hice fue sacar la señal del micrófono de dos lineas y ampliarlo para obtener la linea de señal y conectarlo al pin analógico lo hice con 5 leds pero mi problema es que no enciende... según mi tester cuando hago ruido en el micrófono lo detecta le llegan 5v pero cuando abro el programa del bitvoicer pues me detecta las sentencias y reconoce lo que digo el código tengo bueno pues me lo compilo pero el problema es que no hace nada... cuando digo por ejemplo "wakeup" el bitvoicer me lo reconoce y todo pero mi arduino no hace nada... no se en que me habré equivocado... me urge que funcione no se en que me he equivocado?

me toca apagar el microfono que tiene mi laptop porque sino ese microfono me reconoce pero cuando digo las palabras reservadas no lo detecta... como que sino lo tuviera conectado pero el microfono esta bueno..

en la parte del microfono lo hice con una fuente externa usb para q traslade 5v el bitvoicer no me reconoce el microfono del circuito usted cual cree q sea mi error?

las resistencias que uso para los leds son de 330Ohmios

HELP ME!!!

" I immersed myself in research project that made yy bone arduino microphone microphone three lines it does is amplify the signal that is what makes it unlike a normal microphone voltage and ground only has what I did was take the microphone signal and extend two lines for signal line and connect the analog pin did 5 leds but my problem is not light ... in my tester when I do noise in the microphone detects you arrive 5v but when I open the program bitvoicer because I detected judgments and recognize what I say the code got good because I do I build it but the problem is that it does nothing ... when I say for example "wakeup" the bitvoicer recognize me and everything but my Arduino does nothing ... not that I have been mistaken ... I urge you not to work when I go wrong?

I have to turn off the microphone that has my laptop because otherwise the microphone recognizes me but when I say the keywords does not detect it ... like that but it has connected but the microphone is good ..

on the part of the microphone did an external source to q transfer usb 5v bitvoicer not recognize me the microphone circuit which you believe q is my mistake? "

WilliamV2 (author)2015-05-24

yo me metí de lleno al proyecto que hizo investigue y y el micrófono de arduino osea el micrófono de tres lineas lo que hace es que amplificar la señal eso es lo que hace a diferencia de un micrófono normal que solo tiene voltaje y tierra lo que yo hice fue sacar la señal del micrófono de dos lineas y ampliarlo para obtener la linea de señal y conectarlo al pin analógico lo hice con 5 leds pero mi problema es que no enciende... según mi tester cuando hago ruido en el micrófono lo detecta le llegan 5v pero cuando abro el programa del bitvoicer pues me detecta las sentencias y reconoce lo que digo el código tengo bueno pues me lo compilo pero el problema es que no hace nada... cuando digo por ejemplo "wakeup" el bitvoicer me lo reconoce y todo pero mi arduino no hace nada... no se en que me habré equivocado... me urge que funcione no se en que me he equivocado?

me toca apagar el microfono que tiene mi laptop porque sino ese microfono me reconoce pero cuando digo las palabras reservadas no lo detecta... como que sino lo tuviera conectado pero el microfono esta bueno..

en la parte del microfono lo hice con una fuente externa usb para q traslade 5v el bitvoicer no me reconoce el microfono del circuito usted cual cree q sea mi error?

las resistencias que uso para los leds son de 330Ohmios

HELP ME!!!

" I immersed myself in research project that made yy bone arduino microphone microphone three lines it does is amplify the signal that is what makes it unlike a normal microphone voltage and ground only has what I did was take the microphone signal and extend two lines for signal line and connect the analog pin did 5 leds but my problem is not light ... in my tester when I do noise in the microphone detects you arrive 5v but when I open the program bitvoicer because I detected judgments and recognize what I say the code got good because I do I build it but the problem is that it does nothing ... when I say for example "wakeup" the bitvoicer recognize me and everything but my Arduino does nothing ... not that I have been mistaken ... I urge you not to work when I go wrong?

I have to turn off the microphone that has my laptop because otherwise the microphone recognizes me but when I say the keywords does not detect it ... like that but it has connected but the microphone is good ..

on the part of the microphone did an external source to q transfer usb 5v bitvoicer not recognize me the microphone circuit which you believe q is my mistake? "

About This Instructable

193,327views

275favorites

License:

More by leandro4b:2WD Voice Controlled Robot with Arduino and BitVoicer ServerSpeech Recognition and Synthesis with ArduinoSpeech Recognition with Arduino and BitVoicer Server
Add instructable to: