CHMlib Logo Leading Translation Management System for Translation Agencies, Top Translation Management Software for Freelance Translators, Time Tracking Software, Word Count, Character Count and Line Count Software, Computer Assisted Translation Tool for Easy Word Count, Clipboard Character Count Software, User-Friendly Translation Memory Software, Terminology Management Software, Terminology Management Server, Microsoft Glossary Software, Dictionary of Acronyms, Social Network for Translators and Translation Agencies, Acronyms and Abbreviations Search Engine, Russian Translation Lab, Ukrainian Translation Lab.
You are reading help file online using chmlib.com
CrisisHelper - First Aid in Tough Times of World Economic Crisis


The Microsoft.com Speech website Microsoft Speech SDK

SAPI 5.1

ISpRecoContext::CreateGrammar

ISpRecoContext::CreateGrammar creates an SpRecoGrammar object.

HRESULT CreateGrammar(
   ULONGLONG          ullGrammarId,
   ISpRecoGrammar   **ppGrammar
);

Parameters

ullGrammarId
[in] Specifies the grammar identifier. The identifier is used by the application and is not required. This identifier is associated with all result objects from the grammar (see SPPHRASE.ullGrammarID).
ppGrammar
[out] Address of a pointer which receives the ISpRecoGrammar object. The application must call IUnknown::Release on the object when finished using it.

Return values

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.

Example

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

If you want your help file to be removed or added please send e-mail to chmlibcom@gmail.com
Partner sites: Logo Design, Simple Anti-Crisis Accounting Software, Voice Search for Web