ISpPhrase::GetPhrase

Microsoft Speech SDK

The Microsoft.com Speech website Microsoft Speech SDK SAPI 5.1

ISpPhrase::GetPhrase

ISpPhrase::GetPhrase retrieves data elements associated with a phrase.


HRESULT GetPhrase(
   SPPHRASE   **ppCoMemPhrase
);

Parameters

ppCoMemPhrase
[out] Address of a pointer to an SPPHRASE data structure receiving the phrase information. May be NULL if no phrase is recognized. If NULL, no memory is allocated for the structure. It is the caller's responsibility to call CoTaskMemFree to free the object; however, the caller does not need to call CoTaskMemFree on each of the elements in SPPHRASE.

Return values

Value Description
S_OK Function completed successfully.
E_POINTER Invalid pointer.
E_OUTOFMEMORY Exceeded available memory.

Returned data includes all elements associated with this phrase.

Example

The following code snippet illustrates the use of ISpRecoResult::GetPhrase as inherited from ISpPhrase to retrieve the recognized text, and display the rule recognized and the phrase.

    HRESULT hr = S_OK;

    // ... obtain a recognition result object from the recognizer...

    // get the recognized phrase object
    hr = cpRecoResult->GetPhrase(&pPhrase);
    // Check hr

    // get the phrase's text
    hr = pPhrase->GetText(SP_GETWHOLEPHRASE, SP_GETWHOLEPHRASE, TRUE, &pwszText, NULL);
    // Check hr

    // display the recognized text and the rule name in a message box
    MessageBoxW(MY_HWND, pwszText, pPhrase->Rule.pszName, MB_OK);