Velocity powered by Wavelink

> Managing Projects > Using Speakeasy > Grammar Files > Loading & Unloading Files

This page refers to an older version of the product.
View the current version of the User Guide.

Loading & Unloading Grammar Files

Grammar files must be loaded to a scope in order for Speakeasy to perform speech-to-text recognition. If no file is loaded, then Speakeasy cannot recognize voice responses. When loading grammar files, you can use session, screen, or field scopes.

Loading large or multiple grammar files to a session can severely impact Speakeasy's responsiveness and phrase recognition. Each time you speak to enter a value in a text field, the engine is forced to go through every grammar file loaded and try to identify the closest match. This can prove especially problematic if you have terms similar in sound or the user's utterance is hard to understand.

To prevent such issues, we recommend creating loading scripts that use only select few grammar files restricted to a screen or field scope. This narrows down the number of files the Speakeasy engine must reference to identify a matching term. While grammar files can be loaded and unloaded with all scope types, we recommend these activities to the screen or field scopes.

One Grammar File

If a field or screen draws upon a limited number of phrases, you can attach a single grammar file to that scope.

/* Removing one grammar file

*/

Voice.loadGrammars('connected_digits');

.

.

.

Voice.unloadGrammars('connected_digits');

The example above demonstrates how to load a specific grammar file, which can then be applied to a screen or field scope.

Multiple Grammar Files

You can also load multiple grammar files by separating the file names with a comma.

/* Removing two grammar files

*/

Voice.loadGrammars('connected_digits', 'yes_no');

.

.

.

Voice.unloadGrammars('connected_digits', 'yes_no');

While you can have multiple grammar files with multiple sub-lists within, we recommend having no more than five grammar files loaded at a time. This ensures the best performance as it reduces the number of recognized phrases the Speakeasy engine must search through to find a match.

Unloading

The most important part of loading grammar files is that you also remember to include the API call to unload the file once the scope is exited. This removes the grammar file from use when the next scope is called. If you don't unload grammar files after scope, the number of grammar files would increase exponentially and greatly slow Speakeasy's performance.

Clearing Grammar Files

If you want to ensure that all grammar files in previous scopes are unloaded, you should also insert a parameter to clear all grammar files from Speakeasy's current list. After this, you can add new grammar files.

/* Remove active grammar files and then make one grammar file active.

*/

Voice.clearGrammars();

Voice.loadGrammars('connected_digits');

This API is most effective when scripted to launch when a new screen is loaded.


This page refers to an older version of the product.
View the current version of the User Guide.

The topic was:

Inaccurate

Incomplete

Not what I expected

Other