请帮我查看一下代码
我编了一个文本朗读器,想把一段文章保存为mp3格式,程序编好后我试了一下,发现如果保存为WAV格式,用系统自带的播种器可以播放,但选择保存为mp3格式,播放器提示“文件已损坏或不支持该格式”。下面是“保存按钮”的代码,请各位大侠帮我看一下,代码有没有错误。谢谢了!Private Sub Command4_Click()
CommonDialog1.CancelError = True
On Error GoTo ErrHandler '设置对话框标题
CommonDialog1.DialogTitle = "保存到声音文件"
'set filters
CommonDialog1.Filter = "所有文件(*.*)|*.*|声音文件(*.wav)|*.wav|mp3文件(*.mp3)|*.mp3"
CommonDialog1.FilterIndex = 2
CommonDialog1.ShowSave '显示保存对话框
Dim cpfilestream As New SpFileStream
'设置输出格式为所选格式
cpfilestream.Format.Type = Combo2.ItemData(Combo2.ListIndex)
cpfilestream.Open CommonDialog1.FileName, SSFMCreateForWrite, False
voice.AllowAudioOutputFormatChangesOnNextSet = False
Set voice.AudioOutputStream = cpfilestream
voice.Speak Text1.Text, SVSFlagsAsync
voice.WaitUntilDone -1
cpfilestream.Close
Set cpfilestream = Nothing
MsgBox "WAV文件保存成功", vbOKOnly, "文件存盘"
Exit Sub
ErrHandler:
If Not cpfilestream Is Nothing Then
Set cpfilestream = Nothing
End If
End Sub
以下是朗读格式
Private Sub AddItemToCombo2()
AddFmts "SAFT8kHz8BitMono", SAFT8kHz16BitMono
AddFmts "SAFT8kHz8BitStereo", SAFT8kHz8BitStereo
AddFmts "SAFT8kHz16BitMono", SAFT8kHz16BitMono
AddFmts "SAFT8kHz16BitStereo", SAFT8kHz16BitStereo
AddFmts "SAFT11kHz8BitMono", SAFT11kHz8BitMono
AddFmts "SAFT11kHz8BitStereo", SAFT11kHz8BitStereo
AddFmts "SAFT11kHz16BitMono", SAFT11kHz16BitMono
AddFmts "SAFT11kHz16BitStereo", SAFT11kHz16BitStereo
AddFmts "SAFT12kHz8BitMono", SAFT12kHz8BitMono
AddFmts "SAFT12kHz8BitStereo", SAFT12kHz8BitStereo
AddFmts "SAFT12kHz16BitMono", SAFT12kHz16BitMono
AddFmts "SAFT12kHz16BitStereo", SAFT12kHz16BitStereo
AddFmts "SAFT16kHz8BitMono", SAFT16kHz8BitMono
AddFmts "SAFT16kHz8BitStereo", SAFT16kHz8BitStereo
AddFmts "SAFT16kHz16BitMono", SAFT16kHz16BitMono
AddFmts "SAFT16kHz16BitStereo", SAFT16kHz16BitStereo
AddFmts "SAFT22kHz8BitMono", SAFT22kHz8BitMono
AddFmts "SAFT22kHz8BitStereo", SAFT22kHz8BitStereo
AddFmts "SAFT22kHz16BitMono", SAFT22kHz16BitMono
AddFmts "SAFT22kHz16BitStereo", SAFT22kHz16BitStereo
AddFmts "SAFT24kHz8BitMono", SAFT24kHz8BitMono
AddFmts "SAFT24kHz8BitStereo", SAFT24kHz8BitStereo
AddFmts "SAFT24kHz16BitMono", SAFT24kHz16BitMono
AddFmts "SAFT24kHz16BitStereo", SAFT24kHz16BitStereo
AddFmts "SAFT32kHz8BitMono", SAFT32kHz8BitMono
AddFmts "SAFT32kHz8BitStereo", SAFT32kHz8BitStereo
AddFmts "SAFT32kHz16BitMono", SAFT32kHz16BitMono
AddFmts "SAFT32kHz16BitStereo", SAFT32kHz16BitStereo
AddFmts "SAFT44kHz8BitMono", SAFT44kHz8BitMono
AddFmts "SAFT44kHz8BitStereo", SAFT44kHz8BitStereo
AddFmts "SAFT44kHz16BitMono", SAFT44kHz16BitMono
AddFmts "SAFT44kHz16BitStereo", SAFT44kHz16BitStereo
AddFmts "SAFT48kHz8BitMono", SAFT48kHz8BitMono
AddFmts "SAFT48kHz8BitStereo", SAFT48kHz8BitStereo
AddFmts "SAFT48kHz16BitMono", SAFT48kHz16BitMono
AddFmts "SAFT48kHz16BitStereo", SAFT48kHz16BitStereo
End Sub