How can I use Speech Recognition in VB.net with voice only triggering commands in the VB.net program I made? RRS feed

  • Question

  • Hello,

    I am using system.speech currently.

    I want to use speech recognition to make a program. However, while the program is running, I noticed that some of the commands for windows (like saying "run") would trigger other program functions. Thus, while the VB.net program is running I do not want this to happen. Also, when the computer starts up, I speech to start listening right away rather than me having to say "start listening". How can I do this? Can someone help me do this? I am pretty sure that it is simple. THANKS!

    This is my code so far:

    Imports System.Speech

    Public Class Form1

        Dim WithEvents reco As New Recognition.SpeechRecognizer


        Private Sub SetColor(ByVal color As System.Drawing.Color)

            Dim synth As New Synthesis.SpeechSynthesizer

            synth.SpeakAsync("setting the back color to " + color.ToString)

            Me.BackColor = color

        End Sub


        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

            Dim gram As New Recognition.SrgsGrammar.SrgsDocument

            Dim colorRule As New Recognition.SrgsGrammar.SrgsRule("color")

            Dim colorsList As New Recognition.SrgsGrammar.SrgsOneOf("red", "green")



            gram.Root = colorRule

            reco.LoadGrammar(New Recognition.Grammar(gram))

        End Sub


    Private Sub reco_SpeechRecognized(ByVal sender As Object, ByVal e As System.Speech.Recognition.RecognitionEventArgs) Handles reco.SpeechRecognized

            Select Case e.Result.Text

                Case "red"


                Case "green"


            End Select

        End Sub

    End Class


    Wednesday, August 11, 2010 9:23 PM


All replies