Go Down

Topic: EasyVR (Read 900 times) previous topic - next topic

nevar91

Hello,
have somebody any experince with EasyVR voice recognition module?
I am trying to control LED 13 on my Arduino board, but I am not too successfully with it.
I have uploaded new commands into EasyVR through EasyVRCommander and I simplify the TestEasyVR example program to this:

#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);

int8_t set = 0;
int8_t group = 0;
uint32_t mask = 0; 
uint8_t train = 0;
char name[32];
bool useCommands = true;

char i = "ROBOTE";

EasyVRBridge bridge;

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);
  easyvr.setTimeout(5);
  easyvr.setLanguage(EasyVR::ENGLISH);
 
  int16_t count = 0;
 
  if (easyvr.getGroupMask(mask))
  {
    uint32_t msk = mask; 
    for (group = 0; group <= EasyVR::PASSWORD; ++group, msk >>= 1)
    {
      if (!(msk & 1)) continue; 
     
    }
  }
  group = 0;
  mask |= 1; // force to use trigger
  useCommands = (mask != 1);
}

bool checkMonitorInput()
{
}

void loop()
{
  checkMonitorInput();
 
  easyvr.setPinOutput(EasyVR::IO1, HIGH); // LED on (listening)
  if (useCommands)
  {
    Serial.print("Say a command in Group ");
    Serial.println(group);
    easyvr.recognizeCommand(group);
  }

  do
  {
    if (checkMonitorInput())
      return;
  }
  while (!easyvr.hasFinished());
 
  easyvr.setPinOutput(EasyVR::IO1, LOW); // LED off

    int16_t idx = easyvr.getCommand();
   
    if (idx >= 0)
    {
      Serial.print("Command: ");
      Serial.print(easyvr.getCommand());
      if (easyvr.dumpCommand(group, idx, name, train))
      {
        Serial.print(" = ");
        Serial.println(name);
      }
      else
        Serial.println();
      // ok, let's try another group
      do
      {
        group++;
        if (group > EasyVR::PASSWORD)
          group = 0;
      } while (!((mask >> group) & 1));
      easyvr.playSound(0, EasyVR::VOL_FULL);
    }
    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);
      }
    }
  }


I think I need to write something like "if (name == char on = "ON") digitalWrite(13, HIGH);" under "if (easyvr.dumpCommand(group, idx, name, train))" command.
Can samobody hepl me wit it, please or show me how should look a basic led control program?
Thanks.

nevar91

OK, I have solved that a bit.
I have simplify TestEasyVR example program and speech commands I indetify by indexes instead by name, so it works.
But I doubt I am working on a "good written" code, so any help will

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy