Voice recognition help

AntecUser

Member
Joined
Feb 20, 2011
Messages
5
Programming Experience
3-5
Hi im a student Computer sciences and in my spare time i like to program using .NET
no im stuck on a part with voice recognition
i want to change the colour of my form using voice recognition
my program does detect speech but doenst respond to the commands (i think the problem is with the grammar)
i use Visual Studio 2010


VB.NET:
Imports SpeechLib
Imports System.Speech
Imports System.Environment
Imports System.Speech.Recognition

Imports System.DateTime
Imports System.Speech.Recognition.SrgsGrammar

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
        Try

            Dim gram As New SrgsDocument

            Dim colorRule As New SrgsRule("color")

            Dim colorsList As New SrgsOneOf("red", "green")

            colorRule.Add(colorsList)

            gram.Rules.Add(colorRule)

            gram.Root = colorRule

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


        Catch s As Exception
            MessageBox.Show(s.Message)
        End Try

    End Sub

    Private Sub reco_SpeechDetected(ByVal sender As Object, ByVal e As System.Speech.Recognition.SpeechDetectedEventArgs) Handles reco.SpeechDetected
       
        MessageBox.Show("Speech Detected")
    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"

                SetColor(Color.Red)

            Case "green"

                SetColor(Color.Green)

        End Select
    End Sub
   

End Class
Greetings Tim
 
This may not help you much, but I tried your code and it worked without problems for me.
I'm using Vista though, and it would only recognize when Vista speech recognition was enabled and in listening mode. However I did get "Speech Detected" on several occations when Vista speech recognition was in sleep mode.
 
strange I use w7 but didnt know that there was so much changed :confused: could anyone test it with w7 if it just my pc ?
could it be that theyre is such a different between w7 and vista
 
Did you confirm you have configured and started Speech Recognition in W7 and that is working properly for you? (Control Panel > Ease of Access > Speech Recognition)
 
Then I see no reason why your app should not work also, because it is exactly the same back engine that used (SAPI), and the code has no errors.
 
yea strange will try it tomorow on another pc :s
could reinstalling visual studio help ? formating the pc is a little bit extreme i guess :p

do you also get when you say red that the Speech Recognition takes it as redoing last action
 
yea strange will try it tomorow on another pc :s
could reinstalling visual studio help ? formating the pc is a little bit extreme i guess :p

do you also get when you say red that the Speech Recognition takes it as redoing last action
Tried it on my laptop and their it works :confused:
could it be a bad microphone (but the the other command wouldnt work on the pc
 
do you also get when you say red that the Speech Recognition takes it as redoing last action
No, red/green both works fine. But I also get green when I say 'blue', perhaps my computer is slightly color blind? :)
 
Back
Top