EDN Admin
Well-known member
Hi,
I am new to speech recognition and was going through the Microsoft example provided in this link: http://msdn.microsoft.com/en-us/library/hh361683(v=office.14).aspx . Unfortunately the code example provided is in c-sharp with no vb alternative.
I managed to convert
it to vb.net code from the best of what could understand and have included the code below:
<pre class="prettyprint lang-vb Imports System
Imports System.Speech.Recognition
Public Class Form1
Create a new SpeechRecognitionEngine instance.
Dim WithEvents recognizer As New SpeechRecognizer()
Private Sub Form1_Load(sender As Object, e As EventArgs)
Create a simple grammar that recognizes "red", "green", or "blue".
Dim colors As New Choices()
colors.Add(New String() {"red", "green", "blue"})
Create a GrammarBuilder object and append the Choices object.
Dim gb As New GrammarBuilder()
gb.Append(colors)
Create the Grammar instance and load it into the speech recognition engine.
Dim g As New Grammar(gb)
recognizer.LoadGrammar(g)
End Sub
Create a simple handler for the SpeechRecognized event.
Private Sub sre_SpeechRecognized(sender As Object, e As SpeechRecognizedEventArgs) Handles recognizer.SpeechRecognized
Select Case e.Result.Text
Case "red"
MessageBox.Show("Red")
Case "green"
MessageBox.Show("Green")
Case "blue"
MessageBox.Show("Blue")
End Select
End Sub
End Class[/code]
When I run this code, I do not get any error messages in the Immediate Window. When I speak into the PC I do not get a response from the program. So to troubleshoot I ran through the speech recognition training in the Windows 7 and also boosted the microphone
to its maximum of 30db. This seems to pass fine and I can speak at normal volume.
Any ideas as to what could be going wrong?
Many thanks,
MobileIAm
View the full article
I am new to speech recognition and was going through the Microsoft example provided in this link: http://msdn.microsoft.com/en-us/library/hh361683(v=office.14).aspx . Unfortunately the code example provided is in c-sharp with no vb alternative.
I managed to convert
it to vb.net code from the best of what could understand and have included the code below:
<pre class="prettyprint lang-vb Imports System
Imports System.Speech.Recognition
Public Class Form1
Create a new SpeechRecognitionEngine instance.
Dim WithEvents recognizer As New SpeechRecognizer()
Private Sub Form1_Load(sender As Object, e As EventArgs)
Create a simple grammar that recognizes "red", "green", or "blue".
Dim colors As New Choices()
colors.Add(New String() {"red", "green", "blue"})
Create a GrammarBuilder object and append the Choices object.
Dim gb As New GrammarBuilder()
gb.Append(colors)
Create the Grammar instance and load it into the speech recognition engine.
Dim g As New Grammar(gb)
recognizer.LoadGrammar(g)
End Sub
Create a simple handler for the SpeechRecognized event.
Private Sub sre_SpeechRecognized(sender As Object, e As SpeechRecognizedEventArgs) Handles recognizer.SpeechRecognized
Select Case e.Result.Text
Case "red"
MessageBox.Show("Red")
Case "green"
MessageBox.Show("Green")
Case "blue"
MessageBox.Show("Blue")
End Select
End Sub
End Class[/code]
When I run this code, I do not get any error messages in the Immediate Window. When I speak into the PC I do not get a response from the program. So to troubleshoot I ran through the speech recognition training in the Windows 7 and also boosted the microphone
to its maximum of 30db. This seems to pass fine and I can speak at normal volume.
Any ideas as to what could be going wrong?
Many thanks,
MobileIAm
View the full article