actually, i figured that out. I was missing the new on creating the recognizer. I thought it had to do with the grammer. feel like an idiot now. Regardless, I still couldn't get it to work. I also added a list to grammar of user ids, and it does not put the correct one in the text box no matter what I say. It always puts Todd in there, or doesn't do it at all.
Imports System.Speech
Imports System.Speech.Recognition
Imports System.Speech.Recognition.SrgsGrammar
Public Class Form1
WithEvents reco As New Recognition.SpeechRecognitionEngine()
Dim synth As New Synthesis.SpeechSynthesizer
Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
If txtUserID.Enabled = True Then
txtUserID.Focus()
End If
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
synth.Speak("I quit!")
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
synth.SpeakAsync("Enter your user I.D. now.")
txtUserID.Focus()
Dim gram As New Recognition.SrgsGrammar.SrgsDocument
Dim userRule As New Recognition.SrgsGrammar.SrgsRule("user")
Dim usersList As New Recognition.SrgsGrammar.SrgsOneOf("Mike", "Vince", "Todd", "Gregg", "Ben")
userRule.Add(usersList)
gram.Rules.Add(userRule)
gram.Root = userRule
Dim rgram As New Grammar(gram)
reco.LoadGrammar(rgram)
Dim t As New Threading.Thread(AddressOf recoasync)
t.Start()
End Sub
Private Sub reco_AudioSignalProblemOccurred(ByVal sender As Object, ByVal e As System.Speech.Recognition.AudioSignalProblemOccurredEventArgs) Handles reco.AudioSignalProblemOccurred
Me.BackColor = Color.Red
End Sub
Private Sub reco_RecognizeCompleted(ByVal sender As Object, ByVal e As System.Speech.Recognition.RecognizeCompletedEventArgs) Handles reco.RecognizeCompleted
reco.RecognizeAsync()
End Sub
Private Sub reco_SpeechDetected(ByVal sender As Object, ByVal e As System.Speech.Recognition.SpeechDetectedEventArgs) Handles reco.SpeechDetected
Me.BackColor = Color.Aqua
End Sub
Private Sub reco_SpeechRecognitionRejected(ByVal sender As Object, ByVal e As System.Speech.Recognition.SpeechRecognitionRejectedEventArgs) Handles reco.SpeechRecognitionRejected
synth.SpeakAsync("I don't understand.")
End Sub
Private Sub reco_SpeechRecognized(ByVal sender As Object, ByVal e As System.Speech.Recognition.SpeechRecognizedEventArgs) Handles reco.SpeechRecognized
txtUserID.Text = txtUserID.Text & e.Result.Text
'synth.SpeakAsync("You said " & e.Result.Text)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If txtUserID.Enabled = True Then
If txtUserID.Text = "" Then
synth.SpeakAsync("You need to enter a user I.D., morron.")
txtUserID.Focus()
End If
End If
End Sub
Private Function recoasync()
reco.SetInputToDefaultAudioDevice()
reco.RecognizeAsync()
End Function
End Class