====== 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;
= run forward;
= run backward;
= stop;
= ( | ) with maximum speed;
public - = | | | ;
===== Exercises =====
- Update your project. To see how, go to: [[did:roboclub:github_tutorials:updating|Pulling/updating]]
- Play with **speakBack** method :)
- Define new command(s) that will allow to specify speed of robot, for instance: //run forward with speed 50//
- Do the same with a rotation angle, for instance //rotate motor A 4 times forward with speed 50//.
- Think of how to allow different versions of this command, such as:
- //rotate motor A and B 4 times forward with speed //
- //rotate motor A and B and C 4 times forward with speed //
- Read JSGF manual to see how to do this (section [[https://www.w3.org/TR/jsgf/#14660|Unary Operators]])
- How to keep some information about the context? How to implement a short-term memory of a robot?Add following voice commands:
- //Increase/Decrease speed by // or //Slow down/speed up//