Click to Rate and Give Feedback
MSDN
MSDN Library
User Interface
ISpRecoGrammar
 ISpRecoGrammar::LoadDictation (SAPI...

  Switch on low bandwidth view
ISpRecoGrammar::LoadDictation (SAPI 5.3)
Microsoft Speech API 5.3

ISpRecoGrammar::LoadDictation

ISpRecoGrammar::LoadDictation loads a dictation topic into the SpRecoGrammar object and the SR engine.

See also ISpSREngine::OnCreateGrammar.

HRESULT LoadDictation(
   LPCWSTR       *pszTopicName,
   SPLOADOPTIONS  Options
);

Parameters

pszTopicName
[in, optional, string] The null-terminated string containing the topic name. If NULL, the general dictation is loaded. See Remarks section.
Options
[in] Flag of type SPLOADOPTIONS indicating whether the file should be loaded statically or dynamically. This value must be SPLO_STATIC.

Return values

ValueDescription
S_OKFunction completed successfully.
E_INVALIDARGpszTopicName is invalid or bad. Alternatively, Options is not SPLO_STATIC.
FAILED(hr)Appropriate error message.

Remarks

SAPI currently defines one specialized dictation topic: SPTOPIC_SPELLING. SR engines are not required to support specialized dictation topic (including spelling).

See the SR engine vendor for information on what specialized dictation topics if any are supported.

Example

The following code snippet illustrates the use of ISpRecoGrammar::LoadDictation to load a spelling topic and activate it.


// Declare local identifiers:
HRESULT                      hr = S_OK;
CComPtr<ISpRecoGrammar>      cpRecoGrammar;
CComPtr<ISpRecoContext>      cpRecoContext;
ULONGLONG                    ullGramId = 1;

// Create a grammar object.
hr = cpRecoContext->CreateGrammar(ullGramId, &cpRecoGrammar;);

if (SUCCEEDED(hr))
{
   // Load the general dictation topic.
   hr = cpRecoGrammar->LoadDictation(NULL, SPLO_STATIC);
}

if (SUCCEEDED(hr))
{
   // Activate the dictation topic to receive recognitions.
   hr = cpRecoGrammar->SetDictationState(SPRS_ACTIVE);
}

if (SUCCEEDED(hr))
{
   // Do stuff here.
}
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker