The toolkit provides a conversion tool that automatically converts JSGF
files to SRGS (XML or ABNF) that conform to the Speech Recognition Grammar
Specification version 1.0.
Using the conversion wizard
From the Voice
perspective:
- Save any open grammar files in the toolkit.
- Use one of the following methods to open the wizard:
- From the Run menu, select Grammar Conversion.
Note: If
the item does not appear in the
Run menu, select ,
and then open the
Run menu again.
From the Navigator,
right-click one or more files with the same file extension, only and select Grammar
Conversion from the menu. Continue with Step 4.
- When the Grammar Conversion Wizard opens, click Next on
the Welcome window.
- Select the format from the list. If you have multiple projects, the Select
Files to Convert window shows a list of projects and grammar files.
- To select all the files in a project, click the project check box, and
select Next.
- To select individual files, expand the project, make your selections,
and then select Next.
- If you selected files from the Navigator, only the selected files appear
in the list.
- Select one of the following check boxes.
- Select the Do not convert tags check box and it
copies the content of the tags with no attempt at conversion. Click Next.
- Select the Convert Reserved Action Tag Fields check
box if you want Action Tag constructs (such as "$tts," "$token," and "$utterance")
to appear in the conversion (deselected by default). When deselected, the
fields will be ignored and the constructs are commented out in the converted
file. See Conversion of IBM ECMAScript Action
Tags to SISR. Click Next.
- The Select Grammar Format window opens, select the desired grammar format:
SRGS XML or SRGS ABNF. Click Next.
The Summary screen lists the files that you have chosen to convert. After
reviewing the list, click Next.
- The conversion progress bar starts. If you are converting many files,
it could take a few minutes for the workspace to refresh.
Note: If you have
already converted one or more files (they are already included in the Converted
Files folder) and you are attempting to convert them again, you can choose
whether to overwrite your previously converted files. Select Yes or Yes
to all to overwrite the files. If you select No or No
to all, no new files will be created and the previously converted
files will be preserved.
- The Status window shows the results of the conversion for each selected
file:
- Pass
- (Green) The conversion completed successfully, and a new file was created.
(This message does not indicate validation, which must take place in
the grammar editor.)
- Fail
- (Red) The conversion did not complete properly, and the new file was not created.
Read the message for more information.
- Skipped
- (Black) The file was already converted and in that process you selected not to
overwrite this original file.
- After the conversion is completed, click Finish to close the window.
The converted files (filename.grxml or filename.gram)
are created in a new folder called Converted Files.
Remember to copy the converted file to the correct location in your project
and resolve references to the new file name.
Conversion of IBM ECMAScript Action Tags to
SISR
One function of the conversion wizard is to check for IBM ECMAScript
Action Tags in the grammar file. If found, the Action Tags are converted to
Semantic Interpretation for Speech Recognition (SISR) tags.
If the original
JSGF grammar contains IBM Action Tags, the conversion wizard creates either
simple or complex objects in the converted SRGS grammar, the content of the
Action Tags, and whether or not you selected the Convert Reserved
Action Tag Fields checkbox.
For example, if the grammar
contains both a this.$value="vanilla" Action Tag and this.$tts (or $token or $utterance), as shown in Example 1, then the results depend on the Convert
Reserved Action Tag Fields checkbox, shown in the examples below:
- If unchecked, the resulting return will be simple,
as shown in Example 2, and the $tts construct will be commented
out in the converted grammar.
- If checked, the resulting return will be complex,
as shown in Example 3.
Example 1: JSGF grammar with an IBM Action Tag
#JSGF V1.0;
= VANILLA {this.$value="vanilla"; this.$tts="vanilla"}
|PISTACHIO {this.$value="pistachio"; this.$tts="pistachio"};
Example 2: Converted SRGS ABNF grammar with simple objects
#ABNF V1.0;
root $flavor;
$flavor = VANILLA {$="vanilla"; /*this.$tts="vanilla"*/}
|PISTACHIO {$="pistachio"; /*this.$tts="pistachio"*/};
Note: The reserved $tts action tag is commented
out, and $ is a simple return type.
Example 3: Converted SRGS ABNF grammar with complex conversion
#ABNF V1.0;
root $flavor;
$flavor = VANILLA {$.$value="vanilla"; $.$tts="vanilla"}
|PISTACHIO {$.$value="pistachio"; $.$tts="pistachio"};
Note: The reserved $tts action tag field has been converted to
SISR, and $ is now a complex object.
Accessing semantic values from VoiceXML
If
the result of the conversion to SISR is a simple string object (such
as $="vanilla"), nothing additional will have to be done
for the VoiceXML application to access and handle the SRGS grammar returns.
If
the result of the conversion to SISR is a complex object, such as $.$value="vanilla",
the VoiceXML application must explicitly access all fields within the returned
object from the grammar. Using the same example $.$value="vanilla",
you would have to explicitly reference the $value field to
get what was returned from the grammar.