I am making a simple program that has a voice command. I don't exactly know the codes in vb.net so I tried to copy the codes in C# then put it in VB and when I run it, it says "Empty rule is not allowed"
Here's my code:
Private Sub loginCommandFom_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
Dim commandChoices As New Recognition.Choices
Dim grammarBuilder As New Recognition.GrammarBuilder
Dim gr As New Recognition.Grammar(grammarBuilder)
commandChoices.Add(New String("Hey", "Wazzup"))
grammarBuilder.Append(commandChoices)
commandRecognition.LoadGrammarAsync(gr)
commandRecognition.SetInputToDefaultAudioDevice()
commandRecognition.RecognizeAsync()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Try
End Sub
Private Sub speechCompleted(sender As Object, e As System.Speech.Recognition.RecognizeCompletedEventArgs) Handles commandRecognition.RecognizeCompleted
commandRecognition.RecognizeAsync()
End Sub
Private Sub speechRecognize(sender As Object, e As System.Speech.Recognition.SpeechRecognizedEventArgs) Handles commandRecognition.SpeechRecognized
Select Case e.Result.Text
Case "Hey"
MsgBox("Yeah")
Case "Wazzup"
MsgBox("Yah")
End Select
End Sub