Speech Recognition With Arduino

218,183

287

119

Intro: 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.

Share

    Recommendations

    • Tiny Home Contest

      Tiny Home Contest
    • Furniture Contest 2018

      Furniture Contest 2018
    • Fix It! Contest

      Fix It! Contest

    119 Discussions

    0
    None
    sushmitah4

    Question 3 months ago on Introduction

    Can Bitvoicer be used with an ATTiny85 to program the commands and remove the dependency of having it work with the laptop?

    1 more answer
    0
    None
    alannap2sushmitah4

    Answer 4 weeks ago

    I agree that's where the real fun starts everyone is doing the same stuff

    0
    None
    alannap2

    4 weeks ago on Introduction

    Let's see a voice water gun keep seeing all the same stuff

    0
    None
    HeathD4

    2 years ago

    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

    3 replies
    0
    None
    ArsamA1HeathD4

    Reply 10 months ago

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

    0
    None
    TommieP1ArsamA1

    Reply 9 months ago

    Go to your installation folder of BitVoice, copy the contents of 'library', paste them into 'libraries' in the arduino installation folder

    0
    None
    choboi

    10 months ago

    I need help with the communication settings for my microphone. I am using the max4466 electret microphone but from the bitvoicerserver manual it says the serial number must be 20 characters. How did you guys find the serial number for your microphone?

    0
    None
    TristanS50

    10 months ago

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

    0
    None
    SANTAMANYU GUJARI

    11 months ago

    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 .

    1 reply
    0
    None
    Harold TraceySANTAMANYU GUJARI

    Reply 10 months ago

    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

    0
    None
    Aditya Tripathi

    1 year ago

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

    1 reply

    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

    0
    None
    suryak53

    1 year ago

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

    1 reply
    0
    None
    Uddipta206UdDReXsuryak53

    Reply 1 year ago

    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.

    0
    None
    kypperb

    1 year ago

    Hello, where can I get the arduino library

    0
    None
    alexa356

    1 year ago

    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 ?

    0
    None
    fahid bin tariq

    1 year ago

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

    0
    None
    MikeZ9

    1 year ago

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

    0
    None
    PandulaM

    2 years ago

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

    condenser mic.jpg