.Net3.0實現(xiàn)文本語音朗讀的方法
The .Net Framework 3.0 has added some managed Text to Speech functions. For this example you to add a reference to System.Speech. I have placed a Listbox (to show the available voices on your machine), textbox, and button on a form. When you click on the button your computer will say the text in your textbox in the voice selected in the listbox.
Imports System.Speech.Synthesis
Public Class Form1
Private Sub btnSay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSay.Click
Dim spk As New SpeechSynthesizer
spk.SelectVoice(lstVoice.SelectedItem.ToString)
spk.Speak(txtSay.Text)
End Sub '更多.net源碼和實例,來自[樂 博 網(wǎng) www.lob.cn]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim spk As New SpeechSynthesizer
For Each voice As InstalledVoice In spk.GetInstalledVoices
lstVoice.Items.Add(voice.VoiceInfo.Name)
Next
lstVoice.SelectedIndex = 0
txtSay.Text = "Hello World!"
End Sub
End Class