Share via


Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

Microsoft Speech Platform

ISpRecoGrammar::LoadCmdFromProprietaryGrammar

ISpRecoGrammar::LoadCmdFromProprietaryGrammar loads a proprietary grammar.

<pre IsFakePre="true" xmlns="http://www.w3.org/1999/xhtml"> <strong>HRESULT LoadCmdFromProprietaryGrammar(</strong> <strong> REFGUID</strong> <em>rguidParam</em>, <strong> LPCWSTR</strong> *<em>pszStringParam</em>, <strong> const void</strong> *<em>pvDataParam</em>, <strong> ULONG</strong> <em>cbDataSize</em>, <a runat="server" href="jj127470(v=msdn.10).md"><strong>SPLOADOPTIONS</strong></a> <em>Options</em> <strong>);</strong> </pre>

Parameters

  • rguidParam
    [in] Unique identifier of the grammar. The GUID will be used by the application and the speech recognition (SR) engine to uniquely identify the SR engine for verifying support.
  • pszStringParam
    [in, string] The null-terminated string command. The string can be used by the application and the SR engine to specify which part of a grammar to utilize.
  • pvDataParam
    [in] Additional information for the process. The Speech Platform will handle the marshaling of the data to the SR engine.
  • cbDataSize
    [in] The size, in bytes, of pvDataParam. The Speech Platform will handle the marshaling of the data to the SR engine.
  • Options
    [in] Flag of type SPLOADOPTIONS indicating whether the file should be loaded statically or dynamically. This value must be SPLO_STATIC.

Return Values

Value Description
S_OK Function completed successfully.
E_INVALIDARG pszStringParam or pvDataParam is invalid or bad. Alternatively, Options is not SPLO_STATIC.
FAILED(hr) Appropriate error message.

Remarks

We recommend against using proprietary grammars. Instead, use XML grammars that conform to the Speech Recognition Grammar Specification (SRGS) Version 1.0 for speech recognition. Applications can use ::LoadCmdFromProprietaryGrammar when using a proprietary grammar format that the SR engine supports. If the current SR engine does not support the proprietary grammar format (specified using rguidParam and pszStringParam), the SR engine may return E_NOTIMPL.

When an application calls ::LoadCmdFromProprietaryGrammar, the currently loaded CFG or proprietary will be unloaded.

Example

`

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

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

if (SUCCEEDED(hr)) { // Load a proprietary grammar. hr = cpRecoGrammar->LoadCmdFromProprietaryGrammar(rguidParam, L"Rule1", NULL, NULL, SPLO_STATIC); }

if (SUCCEEDED(hr)) { // Do stuff here. }

`