Imports System.Speech.Synthesis
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim spk As SpeechSynthesizer
For Each voice As InstalledVoice In spk.GetInstalledVoices
ListBox1.Items.Add(voice.VoiceInfo.Name)
Next
ListBox1.SelectedIndex = 0
TextBox1.Text = "Hello"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim spk As New SpeechSynthesizer
spk.SelectVoice(ListBox1.SelectedItems.ToString)
spk.Speak(TextBox1.Text)
End Sub
End Class
# 에러 해결 방법
* 5번째줄
Dim spk As SpeechSynthesizer -> Dim spk As New SpeechSynthesizer
* 17번째줄
spk.SelectVoice(ListBox1.SelectedItems.ToString) -> spk.SelectVoice(ListBox1.SelectedItem.ToString)
로 수정해 준다
이 댓글을