Tropo is part of CiscoLearn More

Simple Grammar Basics

Highly accurate speech recognition for very short command phrases requires that the speech recognition system know what words or phrases are expected. This dictionary of expected input is called a grammar in the speech world. Without a grammar, the speech system wouldn't be able to distinguish between similar sounds, words, or phrases. For example, if a caller said "wood" the system wouldn't know if it should tell the application the user said would, wood, or even hood.

The speech interface world has complex systems for creating incredibly powerful grammars that allow very accurate, intricate input -- and require advanced degrees in speech science to create and understand. To make creating a grammar easier, Tropo has created a format called Simple Grammar that uses simple comma-separated lists to define your expected input.

var result = ask("What's your favorite color?  Choose from red, blue or green.", {
   choices:"red, blue, green"
});
say("You said " + result.value);
log("They said " + result.value);
result = ask "What's your favorite color?  Choose from red, blue or green.", {
   :choices => "red, blue, green"}
say "You said " + result.value
log "They said " + result.value
<?php

$result = ask("What's your favorite color?  Choose from red, blue or green.", array(
   "choices" => "red, blue, green"
));
say("You said" . $result->value);
_log("They said " . $result->value);

?>
result = ask("What's your favorite color? Choose from red, blue or green.", {
   "choices":"red, blue, green"})
say("You said " + result.value)
log("They said " + result.value)
result = ask("What's your favorite color? Choose from red, blue or green.", [
   choices: "red, blue, green"])
say("You said $result.value")
log("They said $result.value")

In this example, the grammar is red, blue, green. Tropo will expect the caller to say one of those three words, and uses a statistical probability to determine if one of those words was said. This means that if someone says something very close, Tropo will try and match it. A caller saying "Fred" would likely be detected as saying "red" in this example. You can tell Tropo how confident you'd like it to be when looking for a match by setting the minConfidence parameter of your ask function.

The Simple Grammar accepts letters and numbers only. Each word is separated by a comma, and you can group like concepts into a single phrase using parentheses (more on that later). Any other character will cause Tropo to return an error. If you want your application to recognize "pork & beans" you'll want to write it as "pork and beans" in your Simple Grammar.