29

Arduino: Speech control with the EasyVR Shield

Geschrieben von: SES am 19.03.2012 um 20:52 pm

Introduction

Recently I’ve found an quite interesting Arduino shield on: http://www.veear.eu/Products/EasyVRShield.aspx. Using this shield you can control your Arduino using speech commands.

The shield consists of these components:
- EasyVR Arduino Shield (includes EasyVR module)
- Microphone

On the website you can also find following free software downloads (see link above):
- User manual
- EasyVR Commander
- Arduino Libraries

Following shops sell the EasyVR shield: http://www.veear.eu/WheretoBuy.aspx
It costs around 40€ or 50$.


Demo

In this demo I control a LED with my voice and the EasyVR shield.

For this demo I also use an Arduino, that has been kindly provided by Farnell.com.

Overview Arduino: http://de.farnell.com/arduino
Arduino schematic: http://arduino.cc/en/uploads/Main/arduino-uno-schematic.pdf
Link to product page: http://de.farnell.com/arduino/a000046/board-arduino-uno/dp/1848687?ICID=i-9ec8-00001000

Step 1: Software Installation

Install the “EasyVR Commander” software [Link].
Before you run the software, make sure you run the program with administrator privileges.
But don’t start the software at the moment.

Step 2: Prepare hardware

Put the shield and the Arduino together and connect the mic to the shield (J11).
Put Jumper J12 at position “PC”.
Connect the Arduino to the PC via USB.

Step 3: Train the EasyVR Shield

Now run “EasyVR Commander” and connect to the serial port of the Arduino USB connection.
Click in the group list on Index 0 – Trigger. Add a new command, name it e.g. “ARDUINO”. Then click on “Train Command”. And speak the word “Arduino” in the mic. And a second time, when the software tells you so.

Click in the group list on Index 1 – Group. Add a new command, name it e.g. “LED_ON”. Then click on “Train Command”. And speak the words “LED on” in the mic. And a second time, when the software tells you so.
And add a second command “LED_OFF” and train this command as well.

Note: LED_AN is LED_ON and LED_AUS is LED_OFF.

Now your EasyVR is configured. We finally generate some code for the microcontroller inside of the Arduino. In EasyVR Commander click on File->Generate code.

Disconnect your Arduino from USB and change jumper J12 to SW.

Step 4: Some Arduino code

Install the EasyVR Arduino libraries (see first link) to the Arduino IDE library folder.

I slightly altered the previously generated code to control a LED. The LED is connected to pin 11:

#if defined(ARDUINO) && ARDUINO >= 100
  #include "Arduino.h"
  #include "SoftwareSerial.h"
  SoftwareSerial port(12,13);
#else // Arduino 0022 - use modified NewSoftSerial
  #include "WProgram.h"
  #include "NewSoftSerial.h"
  NewSoftSerial port(12,13);
#endif

#include "EasyVR.h"
EasyVR easyvr(port);

//Groups and Commands
enum Groups
{
  GROUP_0  = 0,
  GROUP_1  = 1,
};

enum Group0 
{
  G0_ARDUINO = 0,
};

enum Group1 
{
  G1_LED_AN = 0,
  G1_LED_AUS = 1,
};


EasyVRBridge bridge;

int8_t group, idx;

void setup()
{
  // bridge mode?
  if (bridge.check())
  {
    cli();
    bridge.loop(0, 1, 12, 13);
  }
  // run normally
  Serial.begin(9600);
  port.begin(9600);

  if (!easyvr.detect())
  {
    Serial.println("EasyVR not detected!");
    for (;;);
  }

  easyvr.setPinOutput(EasyVR::IO1, LOW);
  Serial.println("EasyVR detected!");
  easyvr.setTimeout(5);
  easyvr.setLanguage(3);

  group = EasyVR::TRIGGER; //<-- start group (customize)
  
  
  pinMode(11, OUTPUT); 
  digitalWrite(11, LOW);    // set the LED off
  
}

void action();

void loop()
{
  easyvr.setPinOutput(EasyVR::IO1, HIGH); // LED on (listening)

  Serial.print("Say a command in Group ");
  Serial.println(group);
  easyvr.recognizeCommand(group);

  do
  {
    // can do some processing while waiting for a spoken command
  }
  while (!easyvr.hasFinished());
  
  easyvr.setPinOutput(EasyVR::IO1, LOW); // LED off

  idx = easyvr.getWord();
  if (idx >= 0)
  {
    // built-in trigger (ROBOT)
    // group = GROUP_X; <-- jump to another group X
    return;
  }
  idx = easyvr.getCommand();
  if (idx >= 0)
  {
    // print debug message
    uint8_t train = 0;
    char name[32];
    Serial.print("Command: ");
    Serial.print(idx);
    if (easyvr.dumpCommand(group, idx, name, train))
    {
      Serial.print(" = ");
      Serial.println(name);
    }
    else
      Serial.println();
    easyvr.playSound(0, EasyVR::VOL_FULL);
    // perform some action
    action();
  }
  else // errors or timeout
  {
    if (easyvr.isTimeout())
      Serial.println("Timed out, try again...");
    int16_t err = easyvr.getError();
    if (err >= 0)
    {
      Serial.print("Error ");
      Serial.println(err, HEX);
    }
    
    
    group = GROUP_0;
  }
}

void action()
{
    switch (group)
    {
    case GROUP_0:
      switch (idx)
      {
      case G0_ARDUINO:
        // write your action code here
          group = GROUP_1; //<-- or jump to another group X for composite commands
        break;
      }
      break;
    case GROUP_1:
      switch (idx)
      {
      case G1_LED_AN:
        // write your action code here
        group = GROUP_0; //<-- or jump to another group X for composite commands
        
        digitalWrite(11, HIGH);   // set the LED on
        
        break;
      case G1_LED_AUS:
        // write your action code here
        group = GROUP_0; //<-- or jump to another group X for composite commands
        digitalWrite(11, LOW);    // set the LED off
        
        break;
      }
      break;
    }
}

Compile and upload this code. Your Arduino should now do something like this:

29 Antworten auf “Arduino: Speech control with the EasyVR Shield”

  1. arton sagt:

    can u help with my program is simular to your i have a trigger activate sound sensor, to commands activate and decativate switch but i cant upload my program on arduino can u see where i have gone wrong . when i try your program it doesnt like NewSoftSerial port because it does have a type

    #include
    NewSoftSerial port(12,13);

    #include
    EasyVR easyvr(port);

    //Groups and Commands
    enum Groups
    {
    GROUP_0 = 0,
    GROUP_1 = 1,
    };

    enum Group0
    {
    G0_ACTIVATE_SND_SENSOR = 0,
    };

    enum Group1
    {
    G1_ACTIVATE = 0,
    G1_DEACTIVATE_SWITCH = 1,
    };

    EasyVRBridge bridge;

    int8_t group, idx;

    void setup()
    {
    // bridge mode?
    if (bridge.check())
    {
    cli();
    bridge.loop(0, 1, 12, 13);
    }
    // run normally
    Serial.begin(9600);
    port.begin(9600);

    if (!easyvr.detect())
    {
    Serial.println(“EasyVR not detected!”);
    for (;;);
    }

    easyvr.setPinOutput(EasyVR::IO1, LOW);
    Serial.println(“EasyVR detected!”);
    easyvr.setTimeout(5);
    easyvr.setLanguage(0);

    group = EasyVR::TRIGGER; //= 0)
    {
    // built-in trigger (ROBOT)
    // group = GROUP_X; = 0)
    {
    // print debug message
    uint8_t train = 0;
    char name[32];
    Serial.print(“Command: “);
    Serial.print(idx);
    if (easyvr.dumpCommand(group, idx, name, train))
    {
    Serial.print(” = “);
    Serial.println(name);
    }
    else
    Serial.println();
    easyvr.playSound(0, EasyVR::VOL_FULL);
    // perform some action
    action();
    }
    else // errors or timeout
    {
    if (easyvr.isTimeout())
    Serial.println(“Timed out, try again…”);
    int16_t err = easyvr.getError();
    if (err >= 0)
    {
    Serial.print(“Error “);
    Serial.println(err, HEX);
    }
    }
    }

    void action()
    {
    switch (group)
    {
    case GROUP_0:
    switch (idx)
    {
    case G0_ACTIVATE_SND_SENSOR:
    // write your action code here
    // group = GROUP_X; <– or jump to another group X for composite commands
    break;
    }
    break;
    case GROUP_1:
    switch (idx)
    {
    case G1_ACTIVATE:
    // write your action code here
    group = GROUP_0; //<– or jump to another group X for composite commands

    digitalWrite(11, HIGH); // set the LED on

    break;
    case G1_DEACTIVATE_SWITCH:
    // write your action code here
    group = GROUP_0; //<– or jump to another group X for composite commands
    digitalWrite(11, LOW); // set the LED off

    break;
    }
    break;
    }
    }

  2. uzma sagt:

    hello..
    i am new to this easyvr and need help for connecting arduino uno with easyvr..
    i am not using shield..

  3. SES sagt:

    @uzma:
    that’s eays, have a look at this pdf, on page 11:
    http://download.tigal.com/veear/EasyVR_User_Manual_3.3.pdf

  4. SES sagt:

    @arton: if you have the easyvr shield, you should try a different jumper setting on jumper J12

    see page 17: http://download.tigal.com/veear/EasyVR_User_Manual_3.3.pdf

  5. [...] Wrote in to tell us about this article about using the Arduino EasyVR shield to add voice control to your project. Worth a look if it your application calls for [...]

  6. [...] Wrote in to tell us about this article about using the Arduino EasyVR shield to add voice control to your project. Worth a look if it your application calls for [...]

  7. gogy sagt:

    say me “easyvr not detected” help me please

  8. SES sagt:

    @gogy: did you checked the manual? what configuration do you have – easy vr-shield + arduino or direct connection between the easy vr board and the arduino?

  9. gogy sagt:

    the second

  10. gogy sagt:

    hello, how do I configurer this in terminal? excuse my english is bad

  11. KK sagt:

    Do you used the arduino software or another program to upload the sample program to the microcontroller?

  12. I live in Brazil, I don’t speak very well English and I am using translator ” Globalink ” and I am with difficulties of doing the recording of the sound table in my easyvr shield, and in spite of following the instructions of the video in the site http://www.youtube.com/watch?v=SThR-jyoplk..
    I used the program of sound ” compress Sensory quickSynthesis 5 “, as taught in the video, jumper position ” UP “, and downloads for the program Easy VR shield, however i am not getting to do the transfer of the sound for the easyvr shield, when I change the jumper for position ” PC ” the sound table it doesn’t show up in the program Easyvr Comander left side in the end indicating that was not recorded.

    Thank you for the attention and for the help

  13. Gurmail Khela sagt:

    Hi
    I have bought the EasyVR and Arduino shield
    do not have any program experience

    like your program to control LED with voice command
    could give the program code i can use to do this with my EasyVR
    I copied your program but did hot work with voice
    everything worked up generating code in the commander

    Thank you so much

  14. Dzzy sagt:

    im getting a error Easy.h has not been declared. im lost
    #if defined(ARDUINO) && ARDUINO >= 100
    #include “Arduino.h”
    #include “SoftwareSerial.h”
    SoftwareSerial port(12,13);
    #else // Arduino 0022 – use modified NewSoftSerial
    #include “WProgram.h”
    #include “NewSoftSerial.h”
    NewSoftSerial port(12,13);
    #endif

    #include “EasyVR.h”
    EasyVR easyvr(port);

    //Groups and Commands
    enum Groups
    {
    GROUP_0 = 0,
    GROUP_1 = 1,
    };

    enum Group0
    {
    G0_ARDUINO = 0,
    };

    enum Group1
    {
    G1_LED_ON = 0,
    G1_LED_OFF = 1,
    };

    EasyVRBridge bridge;

    int8_t group, idx;

    void setup()
    {
    // bridge mode?
    if (bridge.check())
    {
    cli();
    bridge.loop(0, 1, 12, 13);
    }
    // run normally
    Serial.begin(9600);
    port.begin(9600);

    if (!easyvr.detect())
    {
    Serial.println(“EasyVR not detected!”);
    for (;;);
    }

    easyvr.setPinOutput(EasyVR::IO1, LOW);
    Serial.println(“EasyVR detected!”);
    easyvr.setTimeout(5);
    easyvr.setLanguage(0);

    group = EasyVR::TRIGGER; //= 0)
    {
    // built-in trigger (ROBOT)
    // group = GROUP_X; = 0)
    {
    // print debug message
    uint8_t train = 0;
    char name[32];
    Serial.print(“Command: “);
    Serial.print(idx);
    if (easyvr.dumpCommand(group, idx, name, train))
    {
    Serial.print(” = “);
    Serial.println(name);
    }
    else
    Serial.println();
    easyvr.playSound(0, EasyVR::VOL_FULL);
    // perform some action
    action();
    }
    else // errors or timeout
    {
    if (easyvr.isTimeout())
    Serial.println(“Timed out, try again…”);
    int16_t err = easyvr.getError();
    if (err >= 0)
    {
    Serial.print(“Error “);
    Serial.println(err, HEX);
    }
    }
    }

    void action()
    {
    switch (group)
    {
    case GROUP_0:
    switch (idx)
    {
    case G0_ARDUINO:
    // write your action code here
    // group = GROUP_X; <– or jump to another group X for composite commands
    break;
    }
    break;
    case GROUP_1:
    switch (idx)
    {
    case G1_LED_ON:
    // write your action code here
    // group = GROUP_X; <– or jump to another group X for composite commands
    break;
    case G1_LED_OFF:
    // write your action code here
    // group = GROUP_X; <– or jump to another group X for composite commands
    break;
    }
    break;
    }
    }

  15. yusuf sagt:

    hello, I do copy your code but I failed to compile it. the error ‘ ‘cli’ is not declare in this scope ‘ appear. I’ve tried to find out the problem but I still cant get it. will you help me on this problem?
    thank you. :D

  16. SES sagt:

    @yusuf: you may find this website useful: http://www.arduino.cc/playground/Main/AVR

    It explains the cli() and sei() function.

  17. Eric sagt:

    I am trying to upload your code to my arduino but it says ‘NewSoftSerial’ does not name a type’

    any ideas on how to fix this?

  18. Luca sagt:

    Hi!!! I’m in trouble with first test on arduino… on commander it’s all ok, but when i try to test with example sketch, on the serial monitor says “EasyVR not detected!” what can be wrong? Sorry… if someone can help me, can reply me by mail? nytro1981@gmail.com thanks!!!!!

  19. Ivan Haruo Kamimura sagt:

    Hi, I´m brazilian. My english isnt good, sry for that! So I´m had trouble using this code, so i tried to repair what is gone wrong… and I got it!
    &lt;– I don´t know what it means but by the way it works.

    here is the code:

    #if defined(ARDUINO)&&ARDUINO>= 100
    #include “Arduino.h”
    #include “SoftwareSerial.h”
    SoftwareSerial port(12,13);
    #else // Arduino 0022 – use modified NewSoftSerial
    #include “WProgram.h”
    #include “NewSoftSerial.h”
    NewSoftSerial port(12,13);
    #endif

    #include “EasyVR.h”
    EasyVR easyvr(port);

    //Groups and Commands
    enum Groups
    {
    GROUP_0 = 0,
    GROUP_1 = 1,
    };
    enum Group0
    {
    G0_ARDUINO = 0,
    };
    enum Group1
    {
    G1_LED_AN = 0,
    G1_LED_AUS = 1,
    };
    EasyVRBridge bridge;
    int8_t group, idx;
    void setup()
    {
    // bridge mode?
    if (bridge.check())
    {
    cli();
    bridge.loop(0, 1, 12, 13);
    }
    // run normally
    Serial.begin(9600);
    port.begin(9600);
    if (!easyvr.detect())
    {
    Serial.println(“EasyVR not detected!”);
    for (;;);
    }
    easyvr.setPinOutput(EasyVR::IO1, LOW);
    Serial.println(“EasyVR detected!”);
    easyvr.setTimeout(5);
    easyvr.setLanguage(3);
    group = EasyVR::TRIGGER; //&lt;– start group (customize)
    pinMode(11, OUTPUT);
    digitalWrite(11, LOW); // set the LED off
    }
    void action();
    void loop()
    {
    easyvr.setPinOutput(EasyVR::IO1, HIGH); // LED on (listening)
    Serial.print(“Say a command in Group”);
    Serial.println(group);
    easyvr.recognizeCommand(group);
    do
    {
    // can do some processing while waiting for a spoken command
    }
    while (!easyvr.hasFinished());
    easyvr.setPinOutput(EasyVR::IO1, LOW); // LED off
    idx = easyvr.getWord();
    if (idx>= 0)
    {
    // built-in trigger (ROBOT)
    // group = GROUP_X; &lt;– jump to another group X
    return;
    }
    idx = easyvr.getCommand();
    if (idx>= 0)
    {
    // print debug message
    uint8_t train = 0;
    char name[32];
    Serial.print(“Command:”);
    Serial.print(idx);
    if (easyvr.dumpCommand(group, idx, name, train))
    {
    Serial.print(“=”);
    Serial.println(name);
    }
    else
    Serial.println();
    easyvr.playSound(0, EasyVR::VOL_FULL);
    // perform some action
    action();
    }
    else // errors or timeout
    {
    if (easyvr.isTimeout())
    Serial.println(“Timed out, try again…”);
    int16_t err = easyvr.getError();
    if (idx>= 0)
    {
    Serial.print(“Error”);
    Serial.println(err, HEX);
    }
    group = GROUP_0;
    }
    }
    void action()
    {
    switch (group)
    {
    case GROUP_0:
    switch (idx)
    {
    case G0_ARDUINO:
    // write your action code here
    group = GROUP_1; //&lt;– or jump to another group X for composite commands
    break;
    }
    break;
    case GROUP_1:
    switch (idx)
    {
    case G1_LED_AN:
    // write your action code here
    group = GROUP_0; //&lt;– or jump to another group X for composite commands
    digitalWrite(11, HIGH); // set the LED on
    break;
    case G1_LED_AUS:
    // write your action code here
    group = GROUP_0; //&lt;– or jump to another group X for composite commands
    digitalWrite(11, LOW); // set the LED off
    break;
    }
    break;
    }
    }

  20. Ivan Haruo Kamimura sagt:

    Hi again! I tested my own code by copying from this site but I discovered a problem. The problem is using control+c control+v to arduino IDE doesnt work. this site have a problem about simbols. (“) is the problem. so if you replace all (“) of my code again, you will see the word on the IDE will turn to blue color than black.

  21. yusuf sagt:

    oh thankyou, I manage to try this code when im move the library correctly. thank you.

  22. saad sagt:

    Can someone help me how to interface easyvr with arduino uno module because i am error of bridge connection

  23. ema sagt:

    Hello, can someone help me! I will make abraille learning board with 2 braille cells each cell consists of 6 dots the user must press on the buttons(raised dots) to make aletter or number and combine them to make words…. The output must be voice only.How can I use arduino to make the voice output.

  24. miari sagt:

    i want to ask what is the software that i should use for coding, im new with arduino!!!

  25. azerty sagt:

    Hi,
    Can someone help me to compile the code with a Teensy board instead of an Arduino???
    Thank you so much.

  26. Amal sagt:

    (“) is the problem. so if you replace all (“) of my code again, you will see the word on the IDE will turn to blue color than black.
    i do this and the color become blue but in compiler there is a problem ” conflicting declaration ‘softwareserial port’ how cani resolve it ?

  27. Amal sagt:

    finally, i upload the program but the led is on all the time and doesn’t response to voice ,what’s the problem ? and after uploading i change the mode of j12 or keep it in sw mode

  28. Albert sagt:

    Hi,

    so this is funny, when I say led_off arduino turns the led ON! and when I say ON it turns the led OFF! hmmmm this is so funny. here my code:
    (the led is on from the beginning!)
    hope you can find the little devil ;-)

    #if defined(ARDUINO) && ARDUINO >= 100
    #include “Arduino.h”
    #include “SoftwareSerial.h”
    SoftwareSerial port(12,13);
    #else // Arduino 0022 – use modified NewSoftSerial
    #include “WProgram.h”
    #include “NewSoftSerial.h”
    NewSoftSerial port(12,13);
    #endif

    #include “EasyVR.h”
    EasyVR easyvr(port);

    //Groups and Commands
    enum Groups
    {
    GROUP_0 = 0,
    GROUP_1 = 1,
    };

    enum Group0
    {
    G0_DAVID = 0,
    };

    enum Group1
    {
    G1_LED_AN = 0,
    G1_LED_AUS = 1,
    };

    EasyVRBridge bridge;

    int8_t group, idx;

    void setup()
    {
    // bridge mode?
    if (bridge.check())
    {
    cli();
    bridge.loop(0, 1, 12, 13);
    }
    // run normally
    Serial.begin(9600);
    port.begin(9600);

    if (!easyvr.detect())
    {
    Serial.println(“EasyVR not detected!”);
    for (;;);
    }

    easyvr.setPinOutput(EasyVR::IO1, LOW);
    Serial.println(“EasyVR detected!”);
    easyvr.setTimeout(10);
    easyvr.setLanguage(3);

    group = EasyVR::TRIGGER; //= 0)
    {
    // built-in trigger (ROBOT)
    // group = GROUP_X; = 0)
    {
    // print debug message
    uint8_t train = 0;
    char name[32];
    Serial.print(“Command: “);
    Serial.print(idx);
    if (easyvr.dumpCommand(group, idx, name, train))
    {
    Serial.print(” = “);
    Serial.println(name);
    }
    else
    Serial.println();
    easyvr.playSound(0, EasyVR::VOL_FULL);
    // perform some action
    action();
    }
    else // errors or timeout
    {
    if (easyvr.isTimeout())
    Serial.println(“Timed out, try again…”);
    int16_t err = easyvr.getError();
    if (err >= 0)
    {
    Serial.print(“Error “);
    Serial.println(err, HEX);
    }
    }
    }

    void action()
    {
    switch (group)
    {
    case GROUP_0:
    switch (idx)
    {
    case G0_DAVID:
    // write your action code here
    group = GROUP_1;
    break;
    }
    break;
    case GROUP_1:
    switch (idx)
    {
    case G1_LED_AN:
    group = GROUP_0; //&lt;– or jump to another group X for composite commands

    digitalWrite(11, HIGH);
    break;
    case G1_LED_AUS:
    group = GROUP_0; //&lt;– or jump to another group X for composite commands
    digitalWrite(11, LOW); // set the LED off
    break;
    }
    break;
    }
    }

  29. SES sagt:

    @Albert: How did you connect the LED? K to GND and A to the digital output?

Hinterlasse einen Kommentar