Note
Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.
Microsoft Speech Platform
ISpPhrase::GetPhrase
ISpPhrase::GetPhrase retrieves data elements associated with a phrase.
<pre IsFakePre="true" xmlns="http://www.w3.org/1999/xhtml"> <strong>HRESULT GetPhrase(</strong><a runat="server" href="jj127872(v=msdn.10).md"><strong>SPPHRASE</strong></a> **<em>ppCoMemPhrase</em><strong> );</strong> </pre>
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. |
Example
The following code snippet illustrates the use of ISpRecoResult::GetPhrase as inherited from ISpPhrase to retrieve the recognized phrase and its text, and to display the recognized text and the name of the recognizing rule.
`
// Declare local identifiers: HRESULT hr = S_OK; CComPtr<ISpRecoResult> cpRecoResult; SPPHRASE *pPhrase; WCHAR *pwszText; HWND hwndParent;`// ... Obtain a recognition result object from the recognizer ...
// Get the recognized phrase object. hr = cpRecoResult->GetPhrase(&pPhrase;);
if (SUCCEEDED (hr)) { // Get the phrase's text. hr = cpRecoResult->GetText(SP_GETWHOLEPHRASE, SP_GETWHOLEPHRASE, TRUE, &pwszText;, NULL); }
if (SUCCEEDED(hr)) { // Display the recognized text and the rule name in a message box. MessageBoxW(hwndParent, pwszText, pPhrase->Rule.pszName, MB_OK); }