You are reading help file online using chmlib.com
|
ISpRecoContext::CreateGrammar creates an SpRecoGrammar object.
HRESULT CreateGrammar(
ULONGLONG ullGrammarId,
ISpRecoGrammar **ppGrammar
);
Value | Description |
---|---|
S_OK | Function completed successfully. |
E_POINTER | ppGrammar is invalid. |
E_OUTOFMEMORY | Not enough system memory to create a grammar object. |
SPERR_SR_ENGINE_EXCEPTION | An exception was thrown by the SR engine during OnCreateGrammar. |
FAILED(hr) | Appropriate error message. |
The following code snippet illustrates the use of ISpRecoContext::CreateGrammar.
HRESULT hr = S_OK; hr = cpRecoContext->CreateGrammar(GRAM_ID, &cpRecoGrammar); // Check hr // load a cfg from a file hr = cpRecoGrammar->LoadCmdFromFile(MY_CFG_FILENAME, SPLO_STATIC); // Check hr
// activate the top-level rules hr = cpRecoGrammar->SetRuleState(NULL, NULL, SPRS_ACTIVE); // Check hr // get a recognition // ... // get the recognized phrase from the recognition result object hr = cpRecoResult->GetPhrase(&pPhrase); // Check hr // check the grammar id of the recognition result SPDBG_ASSERT(GRAM_ID == pPhrase->ullGrammarID);
You are reading help file online using chmlib.com
|