You are reading help file online using chmlib.com
|
Object: SpVoice
Type: Hidden
By default, when an application sets a voice object's AudioOutput property to an audio device, SAPI will change the format of that device to match the engine's preferred format. In cases where a specific audio format is required, such as telephony applications, the AllowOutputFormatChangesOnNextSet property can be used to prevent this format change.
When this property is true, SAPI adjusts the format of the audio output object to the engine's preferred format. When it is false, SAPI uses the audio output object's format. If the output is set to a stream object, SAPI will convert the output to the format of the stream.
Set: | SpVoice.AllowAudioOutputFormatChangesOnNextSet = Boolean |
Get: | Boolean = SpVoice.AllowAudioOutputFormatChangesOnNextSet |
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.
The following Visual Basic form code demonstrates the use of the AllowAudioOutputFormatChangesOnNextSet property. To run this code, create a form with the following controls:
Paste this code into the Declarations section of the form.
The Form_Load procedure creates a voice object, an audio output object, and a SpeechAudioFormatType variable. Both command button procedures set the format of the audio output object to SAFT22kHz8BitMono, then set the AudioOutputStream of the voice to the audio output object, and then test if the voice's audio format has been changed.
In the Command1 procedure, the AllowAudioOutputFormatChangesOnNextSet is set to True, and the voice's format is changed. In the Command2 procedure, this property is set to False, and the voice's format is not changed.
Option Explicit
Dim V As SpeechLib.SpVoice
Dim O As SpMMAudioOut
Dim S As ISpeechBaseStream
Dim f As SpeechLib.SpeechAudioFormatType 'This is an Enum
Private Sub Command1_Click()
V.AllowAudioOutputFormatChangesOnNextSet = True
O.Format.Type = f 'AudioOut obj gets SAFT22kHz8BitMono format
Set V.AudioOutputStream = O 'The "Next Set"
V.Speak "Adjust my format" 'Speak
Set S = V.AudioOutputStream 'Stream object gets voice's format
If S.Format.Type = f Then
MsgBox "format not adjusted"
Else
MsgBox "format adjusted"
End If
End Sub
Private Sub Command2_Click()
V.AllowAudioOutputFormatChangesOnNextSet = False
O.Format.Type = f 'AudioOut obj gets SAFT22kHz8BitMono format
Set V.AudioOutputStream = O 'The "Next Set"
V.Speak "Leave my format alone" 'Speak
Set S = V.AudioOutputStream 'Stream object gets voice's format
If S.Format.Type = f Then
MsgBox "format not adjusted"
Else
MsgBox "format adjusted"
End If
End Sub
Private Sub Form_Load()
Set V = New SpVoice
Set O = New SpMMAudioOut
f = SAFT22kHz8BitMono 'The test audio output format
End Sub
You are reading help file online using chmlib.com
|