Last reviewed: 3/23/2024 8:39:12 AM
SAPI 5 Grammar Special Characters
The Microsoft SAPI 5 grammar compiler supports special characters as alternatives to element tag. The special characters supported by the SAPI 5 grammar compiler include:
Question Mark (?)
A question mark before a word identifies the word as optional. Using a question
mark is the same as using the
For example, words such as, "please" are often identified as optional.
<GRAMMAR LANGID="409">
<RULE id="menu" TOPLEVEL="ACTIVE">
<PHRASE>I would like a hamburger ?please</PHRASE>
</RULE>
</GRAMMAR>
Ellipsis (...)
An ellipsis is used to allow any word or words to be spoken. It is equivalent to a href="~/support/documentation/grammarkit/reference/sapi5/elements/comment" title="Wildcard Element"><wildcard></<wildcard> element. The words spoken are not considered critical to the rule's intent.
For example, extraneous words in following transaction may be ignored:
<GRAMMAR LANGID="409">
<RULE id="menu" TOPLEVEL="ACTIVE">
<PHRASE>... hamburger ?please</PHRASE>
</RULE>
</GRAMMAR>
and is analogous with:
<GRAMMAR LANGID="409">
<RULE id="menu" TOPLEVEL="ACTIVE">
<WILDCARD/>
<PHRASE>hamburger ?please</PHRASE>
</RULE>
</GRAMMAR>
Asterisk (*)
The asterisk allows any word or words to be spoken. It is analogous with the
For example, to return accept a phrase that has one variable word, a dictation asterisk may be used as follows:
<GRAMMAR LANGID="409">
<RULE id="colorchoice" TOPLEVEL="ACTIVE">
<PHRASE>My favorite color is *</PHRASE>
</RULE>
</GRAMMAR>
and is analogous with:
<GRAMMAR LANGID="409">
<RULE id="colorchoice" TOPLEVEL="ACTIVE">
<PHRASE>My favorite color is</PHRASE>
<DICTATION/>
</RULE>
</GRAMMAR>
If more than one word is allowed, then use the plus sign (+) after the asterisk. This is analogous with using the <dictation></<dictation> element with the MAX attribute.
For example,
<GRAMMAR LANGID="409">
<RULE id="directions" TOPLEVEL="ACTIVE">
<PHRASE>What are the directions for *+</PHRASE>
</RULE>
</GRAMMAR>
is analogous with:
<GRAMMAR LANGID="409">
<RULE id="directions" TOPLEVEL="ACTIVE">
<PHRASE>What are the directions for</PHRASE>
<DICTATION MAX="INF"/>
</RULE>
</GRAMMAR>
Plus Sign (+)
Placing a plus sign in front of a word indicates that the speech recognition engine should increase the required confidence when matching this word.
For example, when prompting with a message box, you want to ensure the yes and no responses are distinguishable.
<GRAMMAR LANGID="409">
<RULE id="messagebox" TOPLEVEL="ACTIVE">
<LIST>
<PHRASE>+YES</PHRASE>
<PHRASE>+NO</PHRASE>
</LIST>
</RULE>
</GRAMMAR>
There is no XML Grammar tag equivalent for the confidence increase plus sign character.
Minus Sign (-)
Placing a minus sign in front of a word indicates that the speech recognition engine should decrease the required confidence when matching this word.
For example, some words included in commands to aid in uniqueness are not critical to the command.
<GRAMMAR LANGID="409">
<RULE id="commands" TOPLEVEL="ACTIVE">
<LIST>
<PHRASE>-show +email</PHRASE>
<PHRASE>-turn +off +microphone</PHRASE>
</LIST>
</RULE>
</GRAMMAR>
There is no XML Grammar tag equivalent for the confidence decrease minus sign character.
How a speech recognition engine asserts confidence is unique to the engine. There is no standard or threshold defined by SAPI 5.