Imports System.Speech.Synthesis
Imports SpeechLib
Public Class  Form1
,,,Public Sub 新()
,,,,,,,”,此调用是,Windows 窗体设计器所必需的。
,,,,,,,InitializeComponent ()
,,,,,,,”,在InitializeComponent(),调用之后添加任何初始化。
,才能最终获得子
,,,的分别用两种方法实现
,,,Dim ss As SpeechSynthesizer ,“定义一个语音引擎访问全局变量
,,,Dim voice As SpVoice =, New SpVoice 调用第三方工具库SpeechLib
,,,Private Sub Form1_Load (sender As 对象,,e As EventArgs), Handles MyBase.Load
,,,,,,,ss =, New SpeechSynthesizer(),“实例化
,,,,,,,Dim voicestring As String =,”,“定义一个字符串
,,,,,,,For Each iv As InstalledVoice 拷贝ss.GetInstalledVoices(),“遍历已安装的语音引擎
,,,,,,,,,,,ComboxVoice.Items.Add (iv.VoiceInfo.Name),“将其名字添加到组合框
,,,,,,,下一个
,,,,,,,ComboxVoice.SelectedIndex =, 0,”默认显示第一个
,才能最终获得子
,,,Private Sub ButtonRead_Click (sender As 对象,,e As EventArgs), Handles ButtonRead.Click
,,,,,,,voice.Voice =, voice.GetVoices (String.Empty, String.Empty) .Item(0),“设置中文语音
,,,,,,,的时间=voice.Voice voice.GetVoices (String.Empty, String.Empty) .Item(1),“设置英文语音,只读英文
,,,,,,,”,voice.Rate =, trackBarSpeed.Value “设置语速
,,,,,,,的时间=voice.Volume ; trackBarVolumn.Value 设置音量
,,,,,,,ss.SelectVoice (ComboxVoice.SelectedItem),“选择语音引擎
,,,,,,,ss.Rate =, trackBarSpeed.Value ,“设置语速
,,,,,,,ss.Volume =, trackBarVolumn.Value ,“设置音量
,,,,,,,”voice.Speak (txtMsg.Text, SpeechVoiceSpeakFlags.SVSFDefault),“同步朗读
,,,,,,,”,voice.Speak (txtMsg.Text, SpeechVoiceSpeakFlags.SVSFlagsAsync),“异步朗读
,,,,,,,ss.SpeakAsync (txtMsg.Text),“异步发出语音
,才能最终获得子
,,,Private Sub ButtonPause_Click (sender As 对象,,e As EventArgs), Handles ButtonPause.Click
,,,,,,,ss.Pause(),“暂停播放
,,,,,,,”voice.Pause ()
,才能最终获得子
,,,Private Sub ButtonContinue_Click (sender As 对象,,e As EventArgs), Handles ButtonContinue.Click
,,,,,,,ss.Resume(),“继续播放
,,,,,,,”voice.Resume ()
,才能最终获得子
,,,Private Sub ButtonRecord_Click (sender As 对象,,e As EventArgs), Handles ButtonRecord.Click
,,,,,,,Dim ss As SpeechSynthesizer =, New SpeechSynthesizer(),“定义一个局部变量
,,,,,,,ss.Rate =trackBarSpeed.Value
,,,,,,,ss.Volume =trackBarVolumn.Value
,,,,,,,Dim sfd As SaveFileDialog =, New SaveFileDialog(),“定义一个文件保存提示框,并且实例化
,,,,,,,sfd.Filter =,“Wave 文件| * . wav”,“设置文件类型为语音文件(wav)
,,,,,,,If sfd.ShowDialog =, DialogResult.OK Then ,“如果选择了文件名
,,,,,,,,,,,ss.SetOutputToWaveFile (sfd.FileName),“输出音频文件
,,,,,,,,,,,ss.Speak (txtMsg.Text)
,,,,,,,,,,,ss.SetOutputToDefaultAudioDevice ()
,,,,,,,,,,,MessageBox.Show(“完成录音~ ~”,,“提示”)
,,,,,,最终获得;如果
,才能最终获得子
null
null
null
null