- Contents
Interaction Designer Help
Reco Add Preloaded Grammar
This Reco tool adds a preloaded grammar. The grammar will be preloaded on all ASR servers of the specified engine, or all engines if no engine name is specified in the 'ASR Engine' parameter. Each preloaded grammar has a name as which it can be referenced in recognition operations through the x-inin-reco:preloaded/name URI.
Preloaded grammars are not associated with an interaction but are global to all interactions and are persistent. The primary purpose of preloaded grammars is to prime the ASR servers with large grammars, such as grammars of (large) company directories whose compilation may take several seconds or even minutes. Changing a pre-loaded grammar at runtime ensures that the new grammar is compiled and distributed to each ASR server before the old preloaded grammar is replaced. For example, consider a corporation with a large number of employees for which a dial-by-name feature is to be provided. Every night, say at 2am, the company directory is harvested and a dial-by-name grammar generated for all users. Compiling such a large grammar can take a long time and the first caller entering the system after the grammar change would experience an unacceptably long delay while the grammar is being compiled. Using preloaded grammars, the timer-scheduled handler would synthesize a new grammar file and invoke this tool. The grammar is then parsed, compiled, distributed to all ASR servers and the caches are primed. After the grammar has been successfully registered, the DS entry is modified to ensure the new URI is used to represent the preloaded grammar and the internal link of the preloaded grammar name to the actual grammar object is modified. The next interaction referencing the preloaded grammar will get the new grammar and there should be no noticeable delay in activating the new grammar for recognition.
It is possible to register a preloaded grammar of the same name for different engines or register one for all engines ('ASR Engine' parameter empty) and then register a different one for a specific engine. The engine specific grammar hides the general grammar for that particular engine. The appropriate preloaded grammar will then be selected based on the ASR engine associated with a session. This is useful, for example, if the grammars are rendered by a third-party tool and/or compiled using engine specific tools (e.g., command-line compilers), and then registered as compiled grammar files (e.g., Nuance NGO or SpeechWorks binary grammars). It is strongly recommended to match the semantics of the different grammars sharing the same name to prevent confusion. Thus, a preloaded grammar of a certain name should have the same semantics and slots for all engines.
In most cases, the file of the previous preloaded grammar is not used any longer (the timer task should not overwrite the old file, as a failure would lead to a corrupt grammar). This tool thus allows automatically deleting the replaced old grammar file.
Note 1: Refer to the description of the Reco Register Grammar tool for a list of the most commonly returned errors.
Note 2: Preloading grammars should be considered an expensive operation as the grammar is distributed to every ASR server, compiled, and loaded into the cache. Frequently changing preloaded grammars could thus have detrimental implications on the system performance. If possible, automatically changing pre-loaded grammars should be scheduled to be done in off-peak hours (e.g. early in the morning).
IMPORTANT: Once a file has been registered as preloaded grammar, it must not be modified directly. The recognition framework does not monitor the file for changes. Furthermore, if the system is stopped or terminates unexpectedly while the file is being modified, the grammar will be corrupt and lead to failures. Instead, when creating a new grammar to be used as preloaded grammar, create a new file and then use this tool to replace the current file.
Inputs
Name
Name of the preloaded grammar. This name is used to identify it in DS and in the
x-inin-reco:preloaded/name URI.
If a preloaded grammar with this name already exists, it will be replaced.
The name must consist only of alphanumeric characters (a-z, A-Z, 0-9) or '_'. Names are case sensitive.
Grammar URI
URI of the grammar to add to register as pre-loaded grammar. The supported schemas and grammar formats are engine dependent. If the URI includes a fragment, it will be ignored. Filenames will automatically be converted to a file: URI. Relative URIs are converted to absolute URIs based on the ‘DefaultBaseURI’ configuration parameter.
Grammar Mode
Mode of the referenced grammar. Currently, only "voice" grammars are supported as preloaded grammars.
Grammar Type
Optional. Media type (MIME type) of the grammar referenced by the URL. It is recommended to specify the MIME type for grammars other than engine agnostic grammars. The following are the media types of the engine-agnostic grammar formats:
application/srgs SRGS ABNF
application/srgs+xml SRGS GrXML
application/x-jsgf JSpeech
ASR Engine
Name of the ASR engine for which this preloaded grammar should be registered.
Delete replaced grammar if file
If this box is checked, and the URI of the grammar being replaced represents a file, and the file name is different from the new URI, the old file will be deleted after successfully registering the preloaded grammar.
Leave this box unchecked to only replace the preloaded grammar.
Register Asynchronously
If this box is checked, the grammar will be preloaded asynchronously. The tool will return before the grammar is compiled and sent to ASR servers. The advantage of this mode is that the handler isn’t blocked for an extended period of time. The disadvantage is that compilation and other failures might not be known by the time the tool returns.
If this box is left unchecked, the tool will not exit until the grammar has been preloaded successfully.
Outputs
Registered URI
Fully qualified URI of the pre-loaded grammar.
Error Code
If the tool fails, this output parameter contains an error code in the form of a VoiceXML event. This will be an empty string if no error occurred.
Error Text
If the tool fails, this output parameter will contain a simple textual description of what went wrong.
Exit Paths
Success
A new preloaded grammar with the specified name has been added.
Failure
Some other error occurred.