You are reading help file online using chmlib.com
|
Interface: ISpeechRecoResult
The Audio method creates an audio stream from the audio data in the result object.
The resulting stream can be used as input for SPVoice.SpeakStream. However, a single call to ISpeechRecoResults.SpeakAudio performs the same action of speaking the recognized result.
The audio portion of the recognition is not automatically available. By default, the recognition context does not retain audio. To retain it, call the RetainedAudio property and set it to SRAORetainAudio. While RetainedAudio can be toggled at anytime, audio for a specific phrase must be retained before recognition attempts begin. Therefore, RetainedAudio must be called before the phrase is spoken.
ISpeechRecoResult.Audio(
[StartElement As Long = 0],
[Elements As Long = -1]
) As ISpeechBaseStream
The Audio method returns an ISpeechBaseStream stream.
Even if there are no elements, that is, StartElement = 0 and Elements = 0, the audio will still be played. Unrecognized results not having elements will still have audio.
The following code snippet assumes a valid RecoResult. The stream is returned and passed to SPVoice.SpeakStream to hear. The code also shows support for RetainedAudio in the current recognizer. As a note, the voice object is created using a late binding method.
Dim WithEvents RecoResult As SpSharedRecoContext
Set RecoResult = New SpSharedRecoContext
RecoResult.RetainedAudio = SRAORetainAudio
'Demonstrates retrieving the RetainedAudio value
Dim audioOption As SpeechRetainedAudioOptions
audioOption = RecoResult.RetainedAudio
'Rest of the code to process recognition goes here
...
'Gets the stream to speak
Dim stream As ISpeechBaseStream
Set stream = RecoResult.Audio
'Creates the voice
Dim Voice As SpVoice
Set Voice = CreateObject("SAPI.SpVoice")
Voice.SpeakStream stream
You are reading help file online using chmlib.com
|