ISpSREngine::SetWordSequenceData (Windows CE 5.0)
This method sets a text buffer that the engine can use for recognition. SAPI calls this method when an application makes a call to the ISpRecoGrammar::SetWordSequenceDatamethod.
The text buffer feature is optional for engines, and support for it is shown using the "TextBuffer" attribute in the engine object token. If this method is called on an engine that does not support the text buffer feature, the method returns E_NOTIMPL.
HRESULT SetWordSequenceData( void* pvEngineGrammar, const WCHAR* pText, ULONG cchText, const SPTEXTSELECTIONINFO* pInfo);
Parameters
- pvEngineGrammar
[in] Pointer to the grammar for the engine, as retrieved in a prior call to the ISpSREngine::OnCreateGrammar method. - pText
[in] Pointer to the text buffer. See Remarks section. - cchText
[in] Length, in bytes, of the text buffer. - pInfo
[in] Pointer to an SPTEXTSELECTIONINFO structure containing information about the parts of the buffer that are active and currently selected.
Return Values
The following table shows the possible return values.
Value | Description |
---|---|
S_OK | Function completed successfully. |
E_NOTIMPL | Engine does not support text buffer functionality. |
FAILED(hr) | Other appropriate error message. |
Remarks
The buffer is formatted as a sequence of one or more null-terminated strings, with a double null termination at the end. The engine can recognize any substring of words from any of the strings in the buffer. It is up to the SR engines to perform word breaking and text normalization for improved performance.
When a text buffer transition is reached in a CFG, the engine attempts to recognize a substring of words from the current text buffer. This provides a very simple way for an application to allow selection from a set of text.
It is also possible for the application to alter the areas of the buffer to use for recognition. The initial range can be set with an SPTEXTSELECTIONINFO structure, and later calls to ISpSREngine::SetTextSelection can alter this structure without changing the actual buffer.
The first two members of the SPTEXTSELECTIONINFO structure, ulStartActiveOffset and cchActiveChars, show which area of the buffer should be active for recognition when using a text buffer transition in a CFG.
The other two fields of SPTEXTSELECTIONINFO can be used with dictation. These can indicate, for example, which area of the buffer is currently selected on the screen. If the cchSelection member is set to zero, the structure can show where the insertion point currently is. The engine can use this information to get extra language model context from preceding words in the dictated text.
Requirements
OS Versions: Windows CE .NET 4.1 and later.
Header: Sapiddk.h, Sapiddk.idl.
Link Library: Sapilib.lib.
See Also
Send Feedback on this topic to the authors