Go Down

Topic: Wireless Audio Streaming and Speech Recognition (PART 2) (Read 3883 times) previous topic - next topic

msb4180

Jan 04, 2013, 09:51 pm Last Edit: Jan 05, 2013, 03:24 pm by msb4180 Reason: 1
LINK TO PART 1: http://arduino.cc/forum/index.php/topic,140765.0.html

Here are a couple of pictures of my project:





And this is the sketch I used to control the LEDs, capture audio and interact with BitVoicer:

Code: [Select]

#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 BitVocier Voice Schema I used can be downloaded here: http://www.justbuss.xpg.com.br/BitVoicerTest3.zip

If you have any question about this project, please post it here, so anyone else can read the answer.

excuse me but in the code u r using it is not specified which pin the mic is connected to then how does the program work?
:smiley-eek:

msb4180

#2
Jan 06, 2013, 02:35 pm Last Edit: Jan 06, 2013, 02:39 pm by msb4180 Reason: 1
I call setAudioInput(0) in the setup() passing ZERO (analog pin 0) to the function so that processAudio() uses analog pin 0 to capture audio.

do we have to buy the product key? is there any other way?

msb4180

Yes, I bought the product key and I don't know of another way. It's only $ 4.50.

do u no any other program that does smethin like this program or is thr any other way?

msb4180

I don't know any other program that does something like this.

rsmall

I finally managed to round up some parts that you outlined in the first section of the walkthrough. Everything seems to be working fine except that I can't get the LED's to turn on haha. I imagine that you have one XBEE plugged into an USB explorer and plugged into the computer and another XBEE receiving/transmitting data from the Arduino that is not connected to the computer. If this is the case, what settings did you use in the preferences in BitVoicer? Do I just program the Arduino with your code, then disconnect it and place it somewhere and speak into the mic? I know that the wireless is working and that I am picking up sound from the onboard mic, because BitVoicer is recognizing it.

So what preferences did you use for communication and what modules do you have attached to the computer to transmit to the Arduino or are you just sending out a WiFi signal from the computer?

msb4180

I'm using the computer's WiFi interface and my home wireless network to send data to the Roving WiFly module attached to the Arduino. The communication preferences are just the IP address of the WiFly module and TCP port 2000. If you are using a pair of XBEEs, I believe that the one connected to the PC would appear as a virtual COM port, so you would have to use the settings of this port in the BitVoicer preferences. Which wireless module are you using with the Arduino?

sbright33

Great minds think alike!  But we achieve our goals in a totally different way.

You can do this without leaving your PC on.  You can have it call you and do voice recognition over the phone. 
Only 30 lines of code and 10 minutes to put it together.  No cost like Bitvoice has.
Now if only I could make this work with Arduino...

http://arduino.cc/forum/index.php/topic,158357.0.html
If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Go Up