做一个按钮
Dim dlg As new SaveFileDialog
dlg.Filter = "语音|*.wav"
If dlg.ShowDialog = DialogResult.OK Then
Dim yy As WinForm.ListBox = e.Form.Controls("ListBox1")
Dim vl As String = e.Form.Controls("txtContent").Value '获得要朗读的文本
Speaker.Rate = e.Form.Controls("boxSpeed").Value '设置语速
Speaker.Voice = Speaker.GetVoices(String.Empty,String.Empty).Item(yy.SelectedIndex) '选择语音库
Speaker.Speak("", DotNetSpeech.SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak) '停止之前的朗读
Dim Stream As new DotNetSpeech.SpFileStreamClass()
Stream.Open(dlg.FileName, DotNetSpeech.SpeechStreamFileMode.SSFMCreateForWrite, False)
Speaker.AudioOutputStream = Stream
If e.Form.Controls("rdoAsync").Checked Then
Speaker.Speak(vl, DotNetSpeech.SpeechVoiceSpeakFlags.SVSFlagsAsync) '异步朗读
Else
Speaker.Speak(vl, DotNetSpeech.SpeechVoiceSpeakFlags.SVSFDefault) '同步朗读
End If
Stream.Close()
End If