ISpPhrase::GetText (Windows CE 5.0)
This method gets elements from a text phrase.
HRESULT GetText(ULONG ulStart,ULONG ulCount,BOOL fUseTextReplacements,WCHAR** ppszCoMemText,BYTE* pbDisplayAttributes);
Parameters
- ulStart
[in] First element in the text phrase to retrieve. - ulCount
[in] Number of elements to retrieve from the text phrase. - fUseTextReplacements
[in] Value indicating if replacement text should be used. Set this value to TRUE to use replacement text, and to FALSE otherwise. An example of a text replacement is saying "write new check for twenty dollars" and retrieving the replaced text as "write new check for $20". - ppszCoMemText
[out] Address of a pointer to display text information. It is the caller's responsibility to call CoTaskMemFree to free the memory. - pbDisplayAttributes
[out] Address of a pointer to text display attribute information. Possible information types are defined by the SPDISPLAYATTRIBUTES enumeration. Text display attribute information can be used by the application to display the text to the user in a reasonable manner. For example, speaking "hello comma world period" includes a trailing period, so the recognition may include SPAF_TWO_TRAILING_SPACES to inform the application without requiring extra text processing logic for the application.
Return Values
The following table shows the possible return values.
Value | Description |
---|---|
S_OK | Function completed successfully. |
S_FALSE | A phrase that does not contain text or ppszCoMemText is NULL. |
E_INVALIDARG | One or more arguments are invalid. |
E_POINTER | Invalid pointer. |
E_OUTOFMEMORY | Exceeded available memory. |
Example
The following code snippet illustrates the use this method to retrieve parts of the recognized 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 entire string, including replacements
hr = pPhrase->GetText(SP_GETWHOLEPHRASE,
SP_GETWHOLEPHRASE,
TRUE,
&pwszText,
NULL);
// Check hr
// get the phrase's first 2 words, excluding replacements
hr = pPhrase->GetText(pPhrase->Rule.ulFirstElement,
2,
FALSE,
&pwszText,
NULL);
Requirements
OS Versions: Windows CE .NET 4.1 and later.
Header: Sapi.h, Sapi.idl.
Link Library: Sapilib.lib.
See Also
Send Feedback on this topic to the authors