You are reading help file online using chmlib.com
|
ISpRecoContext::SetVoice sets the associated ISpVoice to an object.
HRESULT SetVoice(
ISpVoice *pVoice,
BOOL fAllowFormatChanges
);
Value | Description |
---|---|
S_OK | Function completed successfully. |
E_POINTER | pVoice is invalid or bad. |
FAILED(hr) | Appropriate error message. |
If fAllowFormatChanges is TRUE, the Voice's output format will be changed to be the same format as the associated SR engine's audio input format (see ISpRecognizer and ISpSREngine::GetInputAudioFormat). However, if this voice object has already been bound to a stream which has specific format, the voice's format will not be changed to the SR engine's audio input format even if fAllowFormatChanges is true.
Using the same audio format for input and output source is useful for sound cards that do not support full-duplex audio (i.e., input format must match output format). If the input format quality is lower than the output format quality, the output format quality will be reduced to equal the input quality.
After calling ISpRecoContext::SetVoice, an application that calls ISpRecoContext::GetVoice will retrieve the originally "set" ISpVoice interface pointer.
The following code snippet illustrates the use of ISpRecoContext::SetVoice 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
You are reading help file online using chmlib.com
|