参考:
http://www.foxtable.com/webhelp/topics/2240.htm
上面的代码会在窗口的ListBox1中列出已经安装的语音库的名称,并默认选择第一个语音库。
开始朗读按钮的代码为:
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) '停止之前的朗读
If e.Form.Controls("rdoAsync").Checked Then
Speaker.Speak(vl, DotNetSpeech.SpeechVoiceSpeakFlags.SVSFlagsAsync) '异步朗读
Else
Speaker.Speak(vl, DotNetSpeech.SpeechVoiceSpeakFlags.SVSFDefault) '同步朗读
End If