ISpRecoContext::SetVoice
This method sets the voice associated with the speech recognition context.
HRESULT SetVoice(
ISpVoice* pVoice,
BOOL fAllowFormatChanges
);
Parameters
- pVoice
[in] Pointer to an object implementing ISpVoice to associate with the speech recognition context. If this value is NULL, the currently associated voice is released. - fAllowFormatChanges
[in] Value specifying if the engine allows the voice format alteration. Set this value to TRUE if the alteration is allowed, and to FALSE otherwise. See Remarks section.
Return Values
The following table shows the possible return values.
Value | Description |
---|---|
S_OK | Function completed successfully. |
E_POINTER | pVoice is invalid or bad. |
FAILED(hr) | Appropriate error message. |
Remarks
If fAllowFormatChanges is TRUE, then the Voice's output format will be the same format as the associated SR engine's audio input format (see ISpRecognizer and ISpSREngine::GetInputAudioFormat). Using the same audio format for input and output source is useful for sound cards that do not support full-duplex audio (such as input format must match output format). If the input format quality is lower than the output format quality, the output format quality will be down-sampled to the lower quality.
After calling ISpRecoContext::SetVoice, an application that calls ISpRecoContext::GetVoice will retrieve the originally "set" ISpVoice interface pointer.
Example
The following code snippet illustrates the use of this method and "barge-in" setup.
HRESULT hr = S_OK;
// create a shared recognition context
hr = cpRecoContext.CoCreateInstance(CLSID_SpSharedRecoContext);
// Check hr
// create a voice
hr = cpVoice.CoCreateInstance(CLSID_SpVoice);
// Check hr
// associate the voice with the context (with same audio format as context)
hr = cpRecoContext->SetVoice(cpVoice, TRUE);
// Check hr
// tell the associated Voice to stop speaking when the SR Engine hears a
recognizable sound
hr = cpRecoContext->SetVoicePurgeEvent(SPFEI(SPEI_SOUND_START));
// Check hr
Requirements
OS Versions: Windows CE .NET 4.1 and later.
Header: Sapi.h, Sapi.idl.
Link Library: Sapilib.lib.
See Also
ISpRecoContext | SAPI Interfaces
Last updated on Saturday, April 10, 2004
© 1992-2003 Microsoft Corporation. All rights reserved.