Grammar File Structure

The following example is a basic grammar file (the grammar file VoiceSpeed.bnf) viewed in Notepad:

Each grammar file must begin with a statement such as #BNF+EM V1.1; that identifies how Speakeasy should handle the grammar file. You do not need to modify this line.

To create comments — information ignored by the engine — you can begin a line with // or enclose text in /* and */ markers. You can edit the Description and the What Can I Say? sections to describe changes you make to the grammar file.

If you change the name of the grammar file, the command !grammar must use the new file name. For example, if the name of the file was changed to VoicePick.bnf, the command would read: !grammar VoicePick;

The !start command specifies which terms in the grammar will be available when the grammar is in use. In the above example, the engine will listen for all of the terms in the <Speech> rule. The words and phrases listed between <Speech>: and the last ; are the terms the grammar will accept. Each word or phrase must be separated by | (an OR symbol). Terms may be listed all on the same line or aligned vertically for easier editing.

In some grammar files, the main rule <Speech> is divided into subsections to make it easier to manage the terms. In the example fragment below, the terms are divided so that the !slot command will only apply to some of the terms:

!start <Speech>;
!slot <YesNo>;

<Speech>: <YesNo> | <Maybe>;
<YesNo>: yes | no;
<Maybe>: maybe;

In this example, the <Speech> rule includes the <YesNo> and the <Maybe> rules, so the engine will listen for all the terms in both the <YesNo> rule and the <Maybe> rule. However, only the terms in the <YesNo> rule are included in the !slot command and used for voice training. (For more information about using the !slot command, see Enabling Voice Training for New Terms.) 

 


Was this article useful?    

The topic was:

Inaccurate

Incomplete

Not what I expected

Other

Privacy and Legal