Voice command Recog System

Hello guys, please i'm working on voice command recognition system using Arduino Uno, i had a microphone input feeding in to 3 bandpass filters and my main purpose is to get the analog inputs values from the 3 filters through peak detectors and there is also a zero crossing detector circuit, save the values in EEPROM for atleast two different commands, then if the user speaks a new word the values will be compared with that of the EEPROM and check for a match. I have written some codes to get the values from the user and i dont know how to save the values in EEPROM then comparing them aswell..please can someone help me from here...pleaseeee

/*
 Turns on and off a light emitting diode(LED) connected to digital  
 pin 13, when the pushbutton attached to pin 2 is pressed and a time delay
 for the speaker to speak before the LED goes OFF as well as reading the 
 input from the analog pins.
 
*/ 

const int buttonPin = 2;                    // the number of the pushbutton pin
const int ledPin =  13;                     // the number of the LED pin
const int pulsePin =  8;                    // the number of the Pulse pin for the Zero Crossing
const int analogPin1 = A0;                 // Analog input from the Microphone peak detector Circuit
const int analogPin2 = A1;                 // Analog input from the First bandpass filter Circuit  
const int analogPin3 = A2;                 // Analog input from the Second bandpass filter  Circuit  
const int analogPin4 = A3;                 // Analog input from the Third bandpass filter  Circuit

int buttonState = 0;                        // variable for reading the pushbutton status
int sensorValue = 0;                        // Variable to store the Values read from the Microphone
int pulseValue  = 0;                        // Values read from the Zero Crossing Detector
int adcvalue1;
int adcvalue2;
int adcvalue3;
int adcvalue4;

void setup() {
 
  Serial.begin (9600);                      // initialize serial communications at 9600 bps
  
  pinMode(ledPin, OUTPUT);                  // initialize the LED pin as an output    
  pinMode(buttonPin, INPUT);                // initialize the pushbutton pin as an input
  pinMode(pulsePin, INPUT);                 // initialize the pulsePin as an input

}

void loop(){

  buttonState = digitalRead(buttonPin);     // read the state of the pushbutton value
  pulseValue = digitalRead(pulsePin);        // read the value of the zero crossings
  
  if (buttonState == HIGH) {                // check if the pushbutton is pressed
                                            // if it is, the buttonState is HIGH
                                             
    digitalWrite(ledPin, HIGH);             // turn on the LED 
    
    delay (1000);                           // The LED stays on (Wait!) Until 1 second 
  } 
  else {
                                               
    digitalWrite(ledPin, LOW);              // The LED goes off
    
 int adcvalue1 = analogRead(analogPin1);    // read the analog in value for Peak Detector1:
  
 int adcvalue2 = analogRead(analogPin2);    // read the analog in value for Peak Detector2:
 
 int adcvalue3 = analogRead(analogPin3);    // read the analog in value for Peak Detector3:
 
 int adcvalue4 = analogRead(analogPin4);    // read the analog in value for Peak Detector4:
 
    Serial.print ( "button = " );           // print the results to the serial monitor
    Serial.print (buttonState);
    Serial.print ("\t sensor = ");
    Serial.println (sensorValue);
    
    delay (100);                            // Wait 100 milliseconds before the next loop
    
    if (digitalRead (8) == 1) {
      {
        Serial.print (1023);                // print the results to the serial monitor
        Serial.print (' ');
      }
    }
      else {
        Serial.print (0);
        Serial.print (' ');
      }
      Serial.println ();
    }
    
      delay (100);                           // Wait 100 milliseconds before the next loop
  }

Hello guys, please i'm working on speech command recognition system using Arduino Uno, i had a microphone input feeding in to 3 bandpass filters and my main purpose is to get the analog inputs values from the 3 filters through peak detectors and there is also a zero crossing detector circuit, save the values in EEPROM for atleast two different commands, then if the user speaks a new word the values will be compared with that of the EEPROM and check for a match. I have written some codes to get the values from the user and i dont know how to save the values in EEPROM then comparing them aswell..please can someone help me from here...pleaseeee

/*
 Turns on and off a light emitting diode(LED) connected to digital  
 pin 13, when the pushbutton attached to pin 2 is pressed and a time delay
 for the speaker to speak before the LED goes OFF as well as reading the 
 input from the analog pins.
 
*/ 

const int buttonPin = 2;                    // the number of the pushbutton pin
const int ledPin =  13;                     // the number of the LED pin
const int pulsePin =  8;                    // the number of the Pulse pin for the Zero Crossing
const int analogPin1 = A0;                 // Analog input from the Microphone peak detector Circuit
const int analogPin2 = A1;                 // Analog input from the First bandpass filter Circuit  
const int analogPin3 = A2;                 // Analog input from the Second bandpass filter  Circuit  
const int analogPin4 = A3;                 // Analog input from the Third bandpass filter  Circuit

int buttonState = 0;                        // variable for reading the pushbutton status
int sensorValue = 0;                        // Variable to store the Values read from the Microphone
int pulseValue  = 0;                        // Values read from the Zero Crossing Detector
int adcvalue1;
int adcvalue2;
int adcvalue3;
int adcvalue4;

void setup() {
 
  Serial.begin (9600);                      // initialize serial communications at 9600 bps
  
  pinMode(ledPin, OUTPUT);                  // initialize the LED pin as an output    
  pinMode(buttonPin, INPUT);                // initialize the pushbutton pin as an input
  pinMode(pulsePin, INPUT);                 // initialize the pulsePin as an input

}

void loop(){

  buttonState = digitalRead(buttonPin);     // read the state of the pushbutton value
  pulseValue = digitalRead(pulsePin);        // read the value of the zero crossings
  
  if (buttonState == HIGH) {                // check if the pushbutton is pressed
                                            // if it is, the buttonState is HIGH
                                             
    digitalWrite(ledPin, HIGH);             // turn on the LED 
    
    delay (1000);                           // The LED stays on (Wait!) Until 1 second 
  } 
  else {
                                               
    digitalWrite(ledPin, LOW);              // The LED goes off
    
 int adcvalue1 = analogRead(analogPin1);    // read the analog in value for Peak Detector1:
  
 int adcvalue2 = analogRead(analogPin2);    // read the analog in value for Peak Detector2:
 
 int adcvalue3 = analogRead(analogPin3);    // read the analog in value for Peak Detector3:
 
 int adcvalue4 = analogRead(analogPin4);    // read the analog in value for Peak Detector4:
 
    Serial.print ( "button = " );           // print the results to the serial monitor
    Serial.print (buttonState);
    Serial.print ("\t sensor = ");
    Serial.println (sensorValue);
    
    delay (100);                            // Wait 100 milliseconds before the next loop
    
    if (digitalRead (8) == 1) {
      {
        Serial.print (1023);                // print the results to the serial monitor
        Serial.print (' ');
      }
    }
      else {
        Serial.print (0);
        Serial.print (' ');
      }
      Serial.println ();
    }
    
      delay (100);                           // Wait 100 milliseconds before the next loop
  }

Writing your values to EEPROM is fairly easy. There is an EEPROM library that will do so a byte at a time:

I think there is also a library somewhere that will save longer structures, but you only need to save a few integers so highByte() and lowByte() would probably be enough. You would use EEPROM.write(x) = highByte(...) etc. If you held your parameters in an array rather than separate variables then you could write a short loop to save them all to EEPROM sequentially.

When you want to compare them, you will want to drag them back from EEPROM using EEPROM.read(x) and I guess put them into a new array to work with. The difficulty will be deciding whether a new command is the same as the old one because things will never be quite equal. Hopefully if you have been displaying the data you will have an idea of how much "wobble" to include in the comparison of each parameter. You could grade the similarity of each and then have a threshold that carried out an action or not depending upon whether the overall similarity was above or below the threshold.

Have you checked the reference - www.arduino.cc/en/Reference/EEPROM -

Please don't crosspost - http://arduino.cc/forum/index.php/topic,81819.0.html - as it is difficult to follow the thread for us and for yourself...

Thank you for the reply..yes i have checked the reference site but i dont understand how i could manipulate it within my code..i'm new to this, i wish someone could help me with some codes on how to get it done please..

Writing your values to EEPROM is fairly easy.

Thank you for the reply, do i need to include the EEPROM head file on the whole sketch and write the values using something like this EEPROM.write(address)=highByte(value)? and will the reading part of the EEPROM be of another sketch? please help me with some codes to clarify me on what to do please. Thank you.

Please don't crosspost - http://arduino.cc/forum/index.php/topic,81819.0.html - as it is difficult to follow the thread for us and for yourself...

I'm sorry that i cross-posted this, because i needed an urgent reply from anyone. i'm desperately in need of help..so i'm very sorry for any inconvenience that it may have caused..your help will be greatly appreciated please..thank you :slight_smile:

I'm sorry that i cross-posted this, because i needed an urgent reply from anyone.

Cross posting is likely to get you less useful response.
Do you know if this approach will even work? It is highly unlikely that this system will allow you to differentiate many words with much accuracy.

Do you know if this approach will even work?

Thank you, Yeah i think it might work just for a few commands..but might not be that accurate though..i just wanna try it, and i need help please..

eagleman:

Do you know if this approach will even work?

Thank you, Yeah i think it might work just for a few commands..but might not be that accurate though..i just wanna try it, and i need help please..

I too am a big fan of doing as much as possible from scratch but if you are interested in a more reliable/quick solution, you might want to try using a pre-built speech recognition module:

or

On the other hand, if you want to code things from the ground up, here's a useful primer from Carnegie Mellon:
http://www.speech.cs.cmu.edu/comp.speech/Section6/Q6.3.html

And a google search for "arduino eeprom" should give you tons of tutorials on how to write/read eeprom.

you might want to try using a pre-built speech recognition module:

Thank you for the reply, this is a final year project, and i was asked not to use pre-built speech recognition module or VRBot...I was asked to try this method, and i think it could possibly work with different bandpass filters from the input with different frequency range and peak detectors..its just comparing the new values from the input with the ones been saved in the EEPROM, i have written the code to save the commands to EEPROM, now is how to get a new value then compare that with EEPROM value..can someone please help me with a code on that? this is my code to write values to EEPROM.

#include <EEPROM.h>
const int buttonPin = 2;                    // the number of the pushbutton pin
const int ledPin =  13;                     // the number of the LED pin
const int pulsePin =  8;                    // the number of the Pulse pin for the Zero Crossing
const int analogPin1 = A0;                 // Analog input from the Microphone peak detector Circuit
const int analogPin2 = A1;                 // Analog input from the First bandpass filter Circuit
const int analogPin3 = A2;                 // Analog input from the Second bandpass filter  Circuit
const int analogPin4 = A3;                 // Analog input from the Third bandpass filter  Circuit

int buttonState = 0;                        // variable for reading the pushbutton status
int sensorValue = 0;                        // Variable to store the Values read from the Microphone
int pulseValue  = 0;                        // Values read from the Zero Crossing Detector
int adcvalue1;
int adcvalue2;
int adcvalue3;
int adcvalue4;
int addr = 0;                              //EEPROM Addres setting
int i=0;
int j = 0;
int k = 0;

void setup() {
 
  Serial.begin (9600);                      // initialize serial communications at 9600 bps
 
  pinMode(ledPin, OUTPUT);                  // initialize the LED pin as an output   
  pinMode(buttonPin, INPUT);                // initialize the pushbutton pin as an input
  pinMode(pulsePin, INPUT);                 // initialize the pulsePin as an input

}

void loop(){

  buttonState = digitalRead(buttonPin);     // read the state of the pushbutton value
  pulseValue = digitalRead(pulsePin);        // read the value of the zero crossings
 
  if (buttonState == HIGH) {                // check if the pushbutton is pressed
                                            // if it is, the buttonState is HIGH
                                            
    digitalWrite(ledPin, HIGH);             // turn on the LED
    

if (digitalRead (8) == 1) {
      
 for (i=0;i<50;i++)        // We need to record/save the voice for one second during this action.
 {
 int adcvalue1 = analogRead(analogPin1)/4;    // read the analog in value for Peak Detector1:
 
 int adcvalue2 = analogRead(analogPin2)/4;    // read the analog in value for Peak Detector2:
 
 int adcvalue3 = analogRead(analogPin3)/4;    // read the analog in value for Peak Detector3:
 
 int adcvalue4 = analogRead(analogPin4)/4;    // read the analog in value for Peak Detector4:

//writing values to EEPROM
// int val = analogRead(1) / 4;
  // write the value to the appropriate byte of the EEPROM.
  // these values will remain there when the board is
  // turned off.
  if(addr<=796)
  {
  addr = j;
  k = j+200;
  EEPROM.write(addr, adcvalue1);
    addr = addr + 1;
  EEPROM.write(addr, adcvalue2);
    addr = addr + 1;
  EEPROM.write(addr, adcvalue3);
    addr = addr + 1;
  EEPROM.write(addr, adcvalue4);
    addr = addr + 1;

  if (addr == k){
    i = 50; }
 
    delay(50);   }
 }
 
 
if (addr== 800)
 {
   for (i=0;i<20;i++)
   {
digitalWrite(ledPin, LOW);
delay (50);
digitalWrite(ledPin, HIGH);
delay (50);
   }
  }
                          
  }
  }

  else {
                                              
    digitalWrite(ledPin, LOW);              // The LED goes off
   
  }

OK: A few issues here.

I don't know how many commands you are expecting to store or how many copies of the same command you will have but I think you will probably need to think how you are going to divide up your available EEPROM space in order to know what you have got and what you are doing with it - remember that on startup you will have data in EEPROM but no idea what it means. You need a structure for your EEPROM data.

Secondly, you need 8 bytes to store each copy of your four parameters because they are type "int" which take 2 bytes each. You therefore need to look into the highByte and lowByte instructions to divide these up.

I would think about starting your EEPROM space with a header block: An identifier byte to show that this is your data rather than just noise, followed by a byte holding how many different commands you have stored, then a byte holding how much space you are allocating to each etc.. At the start of each block of data holding a command you will also want a byte to hold how many copies are present. You might want a byte for the "action" number too, so that the data holds a code indicating what action is carried out when that command is matched and perhaps also a counter indicating which was the last copy of the command recorded.

When you save data, you will need to establish which command you are saving (I am assuming there will be more than one), multiply that by the block-size so that you start in the correct location, then check whether the number of copies already held fills the block. If not then you will add your recording to the end and increment the counter. If it's full then you will either discard your new data or overwrite the oldest copy (hence the need to record the position of the newest copy) and increment both counters. You might decide to store and "average" as well as the raw data to make for faster/more reliable reading. I guess that would be the first copy in the block. If so you would re-calculate the average after you write your new data and would write that too.

When you start up, you will check the EEPROM for your "header" and if it's there you will read the number of commands and the block size into variables to use in the main sketch.

To compare you will need to take new readings and then read each command (either every copy individually or the averaged copy) into variables, see whether your new reading is +- x% from the stored one for each parameter and then allocate a score to how similar they are. You will then need to read the "action" number out of EEPROM corresponding to the command you decided upon and carry that out.

It's a fair amount of coding but none of it should be too difficult once you have a clear idea of what it is you are trying to achieve.

Hope I have the right impression of the project and that gives you some ideas.

this is a final year project

now is how to get a new value then compare that with EEPROM value..can someone please help me with a code on that?

Well it depends on what your project is trying to achieve.
It is hardly worth going to the trouble of writing something into EEPROM and compare it to something else if you haven't got the strategy of how you are going to do the compare. To this end I think your best chance of good marks is to show that it is impossible (which it is).

I used to be a University Lecturer so I know what I would look for.
Therefore what I would do is to digitise what you can of a word and send it out to the serial port and capture it in a file. Use a CR at the end of each set of reading and separate each individual reading with a comma, so that you can load it into a spread sheet to do your manipulations. This makes them easy to change.
Next digitise again the exact same word said in as similar was as you can get it. Then get the two of them as two long sets of columns in the spread sheet. Then you can play about easily with different comparison strategies until you find one that tells you it is the same. Then digitise the exact word again for the third time and introduce that into the spread sheet and see what the successful strategy does to that.

Then you will have proved that no strategy can work.