Loading and Unloading a Grammar

Before you can use a grammar, you must load it into the speech port's collection of grammars, or you must load it into the collection of application-level (Global) grammars.  When you load a grammar, it is compiled for use in the LumenVox Speech Engine.

Grammars can be loaded by specifying their location as a URI, or by passing them in as a null terminated string buffer.  

Grammars must be given a label when they are loaded. Alternatively, non-global grammars can be given an index to identify them.

C++ API

Loading

int LVSpeechPort::LoadGrammar(const char* label, const char* location);

int LVSpeechPort::LoadGrammar(int index, const char* location);

static int LVSpeechPort::LoadGlobalGrammar(const char* label, const char* location);

int LVSpeechPort::LoadGrammarFromBuffer(const char* label, const char* buffer);

int LVSpeechPort::LoadGrammarFromBuffer(int index, const char* buffer);

static int LVSpeechPort::LoadGlobalGrammarFromBuffer(const char* label, const char* buffer);

Unloading

int LVSpeechPort::UnloadGrammar(const char* label);

int LVSpeechPort::UnloadGrammar(int index);

static int LVSpeechPort::UnloadGlobalGrammar(const char* label);

Querying

bool LVSpeechPort::IsGrammarLoaded(const char* label);

bool LVSpeechPort::IsGrammarLoaded(int index);

static bool LVSpeechPort::IsGlobalGrammarLoaded(const char* label);

 

C API

Loading

int LV_SRE_LoadGrammar(HPORT port, const char* label, const char* location);

int LV_SRE_LoadGrammarIdx(HPORT port, int index, const char* location);

int LV_SRE_LoadGlobalGrammar(const char* label, const char* location);

int LV_SRE_LoadGrammarFromBuffer(HPORT port, const char* label, const char* buffer);

int LV_SRE_LoadGrammarFromBufferIdx(HPORT port, int index, const char* buffer);

int LV_SRE_LoadGlobalGrammarFromBuffer(const char* label, const char* buffer);

Unloading

int LV_SRE_UnloadGrammar(HPORT port, const char* label);

int LV_SRE_UnloadGrammarIdx(HPORT port, int index);

int LV_SRE_UnloadGlobalGrammar(const char* label);

Querying

int LV_SRE_IsGrammarLoaded(HPORT port, const char* label);

int LV_SRE_IsGrammarLoadedIdx(HPORT port, int index);

int LV_SRE_IsGlobalGrammarLoaded(const char* label);

Return Values

LV_SUCCESS

No errors; this grammar is now available.

LV_GRAMMAR_WARNING

The grammar file was not fully conforming, but it was understandable and is now available

LV_GRAMMAR_ERROR

The grammar file was not understandable.  You will not be able to decode with this grammar.

Remarks

Detailed error and warning messages are added to the speech port's log at priorities 0 and 1, respectively.

The location may be a local file description, or a URL for a grammar at a remote location.

If you load from a buffer, and have external references in your grammar with relative pathnames, your grammar needs to specify a base URI, or the compiler will be unable to find the references.

 


Complete Help Topic List | Speech Engine Product Information