Platform SDK: Web Telephony Engine

Using the GRAMMAR Attribute

You can use the GRAMMAR attribute on HTML elements that create menu items (such as A, BUTTON, and OPTION) and on elements that create entry fields for taking dictation (such as TEXTAREA and INPUT TYPE=text). On a menu item, the GRAMMAR attribute specifies a set of words and phrases, allowing the caller to select the menu item by speaking any word or phrase in the set. In the following example, the GRAMMAR attributes give the caller several ways to say the name of the person for whom to leave a message:

<P VOICEFILE="speakname.wav">For whom do you wish to leave a message?
<SELECT NAME="recipients" SIZE=10 onchange="SaveName();">
    <OPTION GRAMMAR="'Mister Smith' 'Robert' 'Bob' 'Bob Smith' 'Smitty'"
        VALUE="Robert Smith" VOICEFILE="smith.wav">Robert Smith
    <OPTION GRAMMAR="'Misses Doe' 'Jane' 'Janie'" VALUE="Jane Doe"
        VOICEFILE="doe.wav">Jane Doe
    .
    .
    .
</SELECT>

On TEXTAREA and INPUT TYPE=text controls, the GRAMMAR attribute can point to a SAPI 4.0a-compliant grammar file (.cfg) in Unicode format. The grammar file provides a hint to the engine about what the caller is expected to say. It replaces the default grammar file that the SR engine uses in dictation. The default grammar file does not provide any hint to the engine. For the complete syntax of grammar files, see the SAPI 4.0a documentation.

The following example shows how to specify the GRAMMAR attribute on an INPUT element:

<INPUT TYPE=text GRAMMAR=url(time.cfg)>

The .cfg file, Time.cfg, might contain the following information:

[Grammar]
Type=cf
LangID=1033
 
[(Commands)]
1=the time is "Time=" <time>

In this case, if the caller says "the time is ten fifteen", the text entered to the text control will be "Time=10:15".

For more information, see Taking Dictation.