'ISpeechWaveFormatEx' and 'TSpWaveFormatEx'
帮助上有VB的例子:
Option Explicit
Dim F As SpeechLib.SpAudioFormat
Dim W As SpeechLib.SpWaveFormatEx
Private Sub Command1_Click()
'Create an empty SpAudioFormat object
'Set it to the default format
'Get its format in an SpWaveFormatEx object
Set F = New SpAudioFormat
F.Type = SAFT22kHz16BitStereo
Set W = F.GetWaveFormatEx
Debug.Print
Debug.Print "Default SpAudioFormat and SpWaveFormatEx"
Debug.Print "Format: SAFT22kHz16BitStereo"
Debug.Print "Format code: "
&
F.Type
Debug.Print "AvgBytesPerSec "
&
W.AvgBytesPerSec
Debug.Print "BitsPerSample "
&
W.BitsPerSample
Debug.Print "BlockAlign "
&
W.BlockAlign
Debug.Print "Channels "
&
W.Channels
Debug.Print "ExtraData "
&
W.ExtraData
Debug.Print "FormatTag "
&
W.FormatTag
Debug.Print "SamplesPerSec "
&
W.SamplesPerSec
'Give the SpAudioFormat object an audio type
'Get its format in an SpWaveFormatEx object
F.Type = SAFT11kHz16BitMono
Set W = F.GetWaveFormatEx
Debug.Print
Debug.Print "Changing SpAudioFormat changes SpWaveFormatEx"
Debug.Print "Format: SAFT11kHz16BitMono"
Debug.Print "Format code: "
&
F.Type
Debug.Print "AvgBytesPerSec "
&
W.AvgBytesPerSec
Debug.Print "BitsPerSample "
&
W.BitsPerSample
Debug.Print "BlockAlign "
&
W.BlockAlign
Debug.Print "Channels "
&
W.Channels
Debug.Print "ExtraData "
&
W.ExtraData
Debug.Print "FormatTag "
&
W.FormatTag
Debug.Print "SamplesPerSec "
&
W.SamplesPerSec
End Sub
Private Sub Command2_Click()
'Create an empty SpAudioFormat object
'Set it to the default format
'Get its format in an SpWaveFormatEx object
Set F = New SpAudioFormat
F.Type = SAFT22kHz16BitStereo
Set W = F.GetWaveFormatEx
Debug.Print
Debug.Print "Default SpAudioFormat and SpWaveFormatEx:"
Debug.Print "Format: SAFT22kHz16BitStereo"
Debug.Print "Format code: "
&
F.Type
Debug.Print "AvgBytesPerSec "
&
W.AvgBytesPerSec
Debug.Print "BitsPerSample "
&
W.BitsPerSample
Debug.Print "BlockAlign "
&
W.BlockAlign
Debug.Print "Channels "
&
W.Channels
Debug.Print "ExtraData "
&
W.ExtraData
Debug.Print "FormatTag "
&
W.FormatTag
Debug.Print "SamplesPerSec "
&
W.SamplesPerSec
'Set SpWaveFormatEx properties as in SAFT11kHz16BitMono format;
'this will reset the SpAudioFormat Type.
Debug.Print
Debug.Print "Changing SpWaveFormatEx properties changes SpAudioFormat:"
W.AvgBytesPerSec = 22050
W.BitsPerSample = 16
W.BlockAlign = 2
W.Channels = 1
W.SamplesPerSec = 11025
Call F.SetWaveFormatEx(W)
Debug.Print "Format code: "
&
F.Type
End Sub