Speech recognition and voice commands II – grammar based recognition

In grammar-based recognition, to make the robot recognize your voice commands we need to specify the set of possible commands. Most of the commands will share some parts, like for instance: run forward with maximum speed and run backward with maximum speed. It sounds inefficient to enumerate each command separately, as there will be a lot of redundant stuff in such configuration file.

That is why, instead of explicitly write every possible commands, we define a grammar file, which allows us to do the same in a more compact way:

#JSGF V1.0;

grammar robot;

<forward>  = run forward;
<backward>  = run backward;
<stop> = stop;
<max>  = (<forward> | <backward> ) with maximum speed;

public <item> = <forward> | <stop> | <backward> | <max> ;

Exercises

  1. Update your project. To see how, go to: Pulling/updating
  2. Play with speakBack method :)
  3. Define new command(s) that will allow to specify speed of robot, for instance: run forward with speed 50
  4. Do the same with a rotation angle, for instance rotate motor A 4 times forward with speed 50.
    1. Think of how to allow different versions of this command, such as:
      1. rotate motor A and B 4 times forward with speed <some value>
      2. rotate motor A and B and C 4 times forward with speed <some value>
      3. Read JSGF manual to see how to do this (section Unary Operators)
    2. How to keep some information about the context? How to implement a short-term memory of a robot?Add following voice commands:
      1. Increase/Decrease speed by <some value> or Slow down/speed up