利用DotNetSpeech,可以实现读一些文本文件内容,但利用录音后,再读内容时没有声音,除非退出项目再登陆就可以,凡正录音后就无法再读了,如果没有录音过,就可反复读内容正常。
请教,是何原因造成的?
全局变量代码如下:
Public Voice As new DotNetSpeech.SpVoice()
Public Stream As new DotNetSpeech.SpFileStreamClass()
录音按钮代码:
Dim dlg As New SaveFileDialog '定一个新的SaveFileDialog
dlg.Filter= "Wav文件|*.wav" '设置筛选器
Dim ss As String
Dim st As String = trim(e.Form.controls("textbox1").value)
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
ss = dlg.FileName
Stream.Open(ss,DotNetSpeech.SpeechStreamFileMode.SSFMCreateForWrite, False)
Voice.AudioOutputStream = Stream
Voice.Voice = Voice.GetVoices("", "").Item(9)
voice.Volume = e.Form.controls("NumericComboBox1").value
voice.Rate = e.Form.controls("NumericComboBox2").value
Voice.Speak(st,DotNetSpeech.SpeechVoiceSpeakFlags.SVSFlagsAsync)
Voice.WaitUntilDone(System.Threading.Timeout.Infinite)
Stream.Close()
messagebox.show("录音完成!")
End If