Velocity powered by Wavelink

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.

Watch a related video (3:19)

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 improve recognition, we recommend using fewer, distinct terms, and associating grammar files with screen and 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







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 Grammar Files

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. If you don't unload grammar files after scope, the number of grammar files increases and may impact performance and recognition. You should only load grammar files for terms you expect to hear in a particular context.

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.




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

Was this article useful?    

The topic was:



Not what I expected