1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| Imports SpeechLib
Public Class main
Public WithEvents tts As SpeechLib.SpVoice
Private Sub main_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
Dim x, y As Int16
x = Me.Width - 16
y = Me.Height - 180
TextBox.Size = New Size(x - 20, y)
TextBox.Location = New Point(10, 77)
B_Play.Location = New Point(20, y + 80)
Button1.Location = New Point(180, y + 80)
CheckBox1.Location = New Point(400, y + 90)
End Sub
Private Sub B_Play_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B_Play.Click
tts.Voice = tts.GetVoices().Item(CB_Voci.SelectedIndex)
tts.Volume = tb_vol.Value
tts.Rate = tb_vit.Value
tts.Speak(TextBox.Text, SpeechVoiceSpeakFlags.SVSFlagsAsync)
End Sub
Private Sub main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
tts = New SpVoice
Dim Voices As SpeechLib.ISpeechObjectTokens = tts.GetVoices
For i As Integer = 0 To Voices.Count - 1
CB_Voci.Items.Add(Voices.Item(i).GetDescription)
Next
CB_Voci.SelectedIndex = 0
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox.Clear()
End Sub
Private Sub TextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox.TextChanged
'Epeler
If CheckBox1.Checked = False Then Exit Sub
If TextBox.Text <> "" Then
Dim car As Char
Dim inc As Integer
inc = TextBox.Text.Length
car = Mid(TextBox.Text, inc, 1)
tts.Speak(car, SpeechVoiceSpeakFlags.SVSFlagsAsync)
End If
End Sub
Private Sub tb_vol_Scroll(sender As System.Object, e As System.EventArgs) Handles tb_vol.Scroll
End Sub
End Class |
Partager