Loading and 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.

Watch a related video (3:19)

Loading too many or too big grammar files can impact Speakeasy's responsiveness and term recognition. The engine compares each speech sample with the terms in all the grammar files that are loaded to identify the closest match. A lot of terms means that it takes more processing power to determine a match, and there is a higher chance that Speakeasy will return the wrong term.

To improve recognition, we recommend using fewer, distinct terms, and associating grammar files with screen and field scopes.

Loading and unloading grammar files

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');

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.

Clearing Grammar Files

If you want to ensure that all grammar files in previous scopes are unloaded, 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.