You are reading help file online using chmlib.com
|
Object: SpVoice
The AudioOutputStream property gets and sets the current audio stream object used by the voice.
Setting the voice's AudioOutputStream property may cause its audio output format to be automatically changed to match the text-to-speech (TTS) engine's preferred audio output format. If the voice's AllowAudioOutputFormatChangesOnNextSet property is True, the format change takes place; if False, the format remains unchanged. In order to set the AudioOutputStream property of a voice to a specific format, its AllowOutputFormatChangesOnNextSet should be False.
Set: | SpVoice.AudioOutputStream = ISpeechBaseStream |
Get: | ISpeechBaseStream = SpVoice.AudioOutputStream |
Voice status and voice events are closely associated with the status of the audio output device. A voice speaking to a file stream produces no audio output, generates no events, and has no audio output status. As a result, the ISpeechVoiceStatus data returned by that voice will always indicate that it is inactive.
The following Visual Basic form code demonstrates the use of the AudioOutputStream property. To run this code, create a form with the following controls:
Paste the this code into the Declarations section of the form.
The Command1_Click procedure sets the AudioOutputStream property of the voice to a file called AudioOutputStream.wav and speaks the contents of the text box into a wave file. It then sets the voice's AudioOutputStream property to Nothing, so that subsequent voice output will be directed to the audio system rather than to a file.
The Command2_Click procedure plays back the wave file that created by the Command1_Click procedure.
Option Explicit
Dim objVOICE As SpeechLib.SpVoice
Dim objFSTRM As SpeechLib.SpFileStream
Const strFName = "C:\AudioOutputStream.wav"
Private Sub Command1_Click()
'Build a local file path and open it as a stream
Call objFSTRM.Open(strFName, SSFMCreateForWrite, False)
'Set voice AudioOutputStream to the stream and speak
Set objVOICE.AudioOutputStream = objFSTRM
objVOICE.Speak Text1.Text
'Close the stream and set voice back to speaking
Call objFSTRM.Close
Set objVOICE.AudioOutputStream = Nothing
Command2.Enabled = True
End Sub
Private Sub Command2_Click()
objVOICE.Speak Text1.Text, SVSFIsXML
End Sub
Private Sub Form_Load()
Set objVOICE = New SpVoice
Set objFSTRM = New SpFileStream
Command2.Enabled = False 'Force create file before playback
Text1.Text = "The TTS voice will speak this text into a file."
End Sub
You are reading help file online using chmlib.com
|