Results 1 to 13 of 13
  1. #1
    unknownartist0's Avatar
    Join Date
    May 2013
    Gender
    male
    Location
    Murica
    Posts
    667
    Reputation
    378
    Thanks
    834

    Voice Command Example (Voice Command Webbrowser)

    First you need to add a system.speech reference

    Now declare your Reference
    Code:
    Imports System.Speech
    Now we are going to declare this into memory outside of sub.
    Code:
    Dim gram As New System.Speech.Recognition.DictationGrammar()
    Dim WithEvents reco As New Recognition.SpeechRecognitionEngine
    Now we are going to our Voice Commands
    Code:
     reco.SetInputToDefaultAudioDevice()
            Dim gram As New Recognition.SrgsGrammar.SrgsDocument
            Dim Rule As New Recognition.SrgsGrammar.SrgsRule("Rule")
            Dim List As New Recognition.SrgsGrammar.SrgsOneOf("Back", "Forward", "refresh", "Set as Homepage", "Google", "Go to Homepage")
            Dim Items As New Recognition.SrgsGrammar.SrgsText
            Rule.Add(List)
            gram.Rules.Add(Rule)
            gram(dot)root = Rule
    'MPGH wont let me type Gram   (.)   root  
            reco.LoadGrammar(New Recognition.Grammar(gram))
            reco.RecognizeAsync()
    Now to program the Voice Commands (For our homepage I did it by going to settings, Type: String, Scope: User, Name: HomePageURL)
    Code:
    Private Sub reco_SpeechRecognized(ByVal sender As Object, ByVal e As System.Speech.Recognition.RecognitionEventArgs) Handles reco.SpeechRecognized
            Dim homepage As String = My.Settings.HomePageUrl
            Select Case e.Result.Text
                Case "refresh"
                    WebBrowser1.Refresh()
                Case "Back"
                    WebBrowser1.GoBack()
                Case "Forward"
                    WebBrowser1.GoForward()
                Case "Set as Homepage"
                    My.Settings.HomePageUrl = WebBrowser1.Url.ToString
                    My.Settings.Save()
                    MsgBox("New HomePage:" & homepage)
                Case "Google"
                    WebBrowser1.Navigate("https://google.com")
                Case "Go to Homepage"
                    WebBrowser1.Navigate(homepage)
            End Select
    (take note this is not proper handling, I am simply doing this improperly for the sake of not giving a fuck)

    And now we finish handling our Speech recognizer.
    Code:
     Private Sub reco_RecognizeCompleted(ByVal sender As Object, ByVal e As System.Speech.Recognition.RecognizeCompletedEventArgs) Handles reco.RecognizeCompleted
            reco.RecognizeAsync()
        End Sub

    Now you have a Voice Command Webbrowser without the need of any buttons (assuming you have a mic or a headset).
    Last edited by unknownartist0; 07-20-2013 at 07:02 PM.

  2. The Following 2 Users Say Thank You to unknownartist0 For This Useful Post:

    Cryptonic (07-20-2013),wut12345 (07-23-2013)

  3. #2
    Cryptonic's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    United Provinces of Canada
    Posts
    1,315
    Reputation
    44
    Thanks
    190
    My Mood
    Bored
    Huh, I didn't know voice commands was that simple, nice job.

  4. #3
    Sixx93's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    673
    Reputation
    21
    Thanks
    250
    My Mood
    Cool
    When I import the Speech i got this error:

    Warning 1 Namespace or type specified in the Imports 'System.Speech' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.

    Then, when i put these lines of code:
    Code:
    Dim gram As New System.Speech.Recognition.DictationGrammar()
    Dim WithEvents reco As New Recognition.SpeechRecognitionEngine
    I got these errors:

    Error 2 Type 'System.Speech.Recognition.DictationGrammar' is not defined.
    Error 3 Type 'Recognition.SpeechRecognitionEngine' is not defined.

    Do I need some SDK or what?

  5. #4
    unknownartist0's Avatar
    Join Date
    May 2013
    Gender
    male
    Location
    Murica
    Posts
    667
    Reputation
    378
    Thanks
    834
    Quote Originally Posted by Sixx93 View Post
    When I import the Speech i got this error:

    Warning 1 Namespace or type specified in the Imports 'System.Speech' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.

    Then, when i put these lines of code:
    Code:
    Dim gram As New System.Speech.Recognition.DictationGrammar()
    Dim WithEvents reco As New Recognition.SpeechRecognitionEngine
    I got these errors:

    Error 2 Type 'System.Speech.Recognition.DictationGrammar' is not defined.
    Error 3 Type 'Recognition.SpeechRecognitionEngine' is not defined.

    Do I need some SDK or what?
    If you did everything correctly and get this then

    Maybe, you might need to be on .Net framework 4.0 too but im not sure.

    https://www.microsof*****m/en-us/downl....aspx?id=10121
    Last edited by unknownartist0; 07-22-2013 at 08:48 PM.

  6. #5
    Sixx93's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    673
    Reputation
    21
    Thanks
    250
    My Mood
    Cool
    Quote Originally Posted by unknownartist0 View Post
    If you did everything correctly and get this then

    Maybe, you might need to be on .Net framework 4.0 too but im not sure.

    Download Speech SDK 5.1 from Official Microsoft Download Center
    I'm on framework 4.5 .-.

    I'm trying this speech SDK

    ---------- Post added at 10:54 AM ---------- Previous post was at 10:42 AM ----------

    Have I to add the SDK in the project references?

    Because I've installed the SDK but I still get the error
    Attached Thumbnails Attached Thumbnails
    Immagine.png  

    Last edited by Sixx93; 07-23-2013 at 06:36 AM.

  7. #6
    unknownartist0's Avatar
    Join Date
    May 2013
    Gender
    male
    Location
    Murica
    Posts
    667
    Reputation
    378
    Thanks
    834
    Quote Originally Posted by Sixx93 View Post
    I'm on framework 4.5 .-.

    I'm trying this speech SDK

    ---------- Post added at 10:54 AM ---------- Previous post was at 10:42 AM ----------

    Have I to add the SDK in the project references?

    Because I've installed the SDK but I still get the error

    Don't post attatchment images, just go by URL and uncheck the remote url thing.

    Did you add the reference? Ope up your project files, then go to References, then add Speech.

  8. #7
    wut12345's Avatar
    Join Date
    Oct 2012
    Gender
    male
    Posts
    294
    Reputation
    16
    Thanks
    1,453
    I like dis.

  9. #8
    Sixx93's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    673
    Reputation
    21
    Thanks
    250
    My Mood
    Cool
    ok, I've added the references and now I don't get any errors... But when I try to run the app, on the line:
    Code:
    reco.SetInputToDefaultAudioDevice()
    I got this:

    A first chance exception of type 'System.PlatformNotSupportedException' occurred in System.Speech.dll


    This is the source:

    Code:
    Imports System.Speech
    Public Class Form1
        Dim gram As New System.Speech.Recognition.DictationGrammar()
        Dim WithEvents reco As New Recognition.SpeechRecognitionEngine
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            reco.SetInputToDefaultAudioDevice()
            Dim gram As New Recognition.SrgsGrammar.SrgsDocument
            Dim Rule As New Recognition.SrgsGrammar.SrgsRule("Rule")
            Dim List As New Recognition.SrgsGrammar.SrgsOneOf("Back", "Forward", "refresh", "Set as Homepage", "Google", "Go to Homepage")
            Dim Items As New Recognition.SrgsGrammar.SrgsText
            Rule.Add(List)
            gram.Rules.Add(Rule)
            gram****ot = Rule
    
            reco.LoadGrammar(New Recognition.Grammar(gram))
            reco.RecognizeAsync()
        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 "refresh"
                    MsgBox("refresh")
                Case "Back"
                    MsgBox("Back")
                Case "Forward"
                    MsgBox("forward")
                Case "Set as Homepage"
                    MsgBox("Set as Homepage")
                Case "Google"
                    MsgBox("Google")
                Case "Go to Homepage"
                    MsgBox("Go to Homepage")
            End Select
        End Sub
        Private Sub reco_RecognizeCompleted(ByVal sender As Object, ByVal e As System.Speech.Recognition.RecognizeCompletedEventArgs) Handles reco.RecognizeCompleted
            reco.RecognizeAsync()
        End Sub
    End Class

  10. #9
    wut12345's Avatar
    Join Date
    Oct 2012
    Gender
    male
    Posts
    294
    Reputation
    16
    Thanks
    1,453
    Quote Originally Posted by Sixx93 View Post
    ok, I've added the references and now I don't get any errors... But when I try to run the app, on the line:
    Code:
    reco.SetInputToDefaultAudioDevice()
    I got this:

    A first chance exception of type 'System.PlatformNotSupportedException' occurred in System.Speech.dll


    This is the source:

    Code:
    Imports System.Speech
    Public Class Form1
        Dim gram As New System.Speech.Recognition.DictationGrammar()
        Dim WithEvents reco As New Recognition.SpeechRecognitionEngine
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            reco.SetInputToDefaultAudioDevice()
            Dim gram As New Recognition.SrgsGrammar.SrgsDocument
            Dim Rule As New Recognition.SrgsGrammar.SrgsRule("Rule")
            Dim List As New Recognition.SrgsGrammar.SrgsOneOf("Back", "Forward", "refresh", "Set as Homepage", "Google", "Go to Homepage")
            Dim Items As New Recognition.SrgsGrammar.SrgsText
            Rule.Add(List)
            gram.Rules.Add(Rule)
            gram****ot = Rule
    
            reco.LoadGrammar(New Recognition.Grammar(gram))
            reco.RecognizeAsync()
        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 "refresh"
                    MsgBox("refresh")
                Case "Back"
                    MsgBox("Back")
                Case "Forward"
                    MsgBox("forward")
                Case "Set as Homepage"
                    MsgBox("Set as Homepage")
                Case "Google"
                    MsgBox("Google")
                Case "Go to Homepage"
                    MsgBox("Go to Homepage")
            End Select
        End Sub
        Private Sub reco_RecognizeCompleted(ByVal sender As Object, ByVal e As System.Speech.Recognition.RecognizeCompletedEventArgs) Handles reco.RecognizeCompleted
            reco.RecognizeAsync()
        End Sub
    End Class
    Do you even know what your doing?
    Try using "try statements"

    Maybe try rewriting your own method. I usually c&p then I think of a better and more CPU friendly later.
    Unless your a fan boy of c&p.

    Anyways have fun with what your doing..
    Last edited by wut12345; 07-23-2013 at 06:19 PM. Reason: I hate apple.

  11. #10
    Sixx93's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    673
    Reputation
    21
    Thanks
    250
    My Mood
    Cool
    Quote Originally Posted by wut12345 View Post
    Do you even know what your doing?
    Try using "try statements"

    Maybe try rewriting your own method. I usually c&p then I think of a better and more CPU friendly later.
    Unless your a fan boy of c&p.

    Anyways have fun with what your doing..
    I'm asking because I'm trying to learn something new... If you are here only to post something to increase your post counter (like you're doing in every thread, posting answers un-needed like this one )
    Quote Originally Posted by wut12345 View Post
    I like dis.
    or

    Quote Originally Posted by wut12345 View Post
    1+3+3=7 1337

    then go somewhere else.

  12. #11
    unknownartist0's Avatar
    Join Date
    May 2013
    Gender
    male
    Location
    Murica
    Posts
    667
    Reputation
    378
    Thanks
    834
    Quote Originally Posted by wut12345 View Post
    Do you even know what your doing?
    Try using "try statements"

    Maybe try rewriting your own method. I usually c&p then I think of a better and more CPU friendly later.
    Unless your a fan boy of c&p.

    Anyways have fun with what your doing..
    I don't care If I handle things correctly, I don't care if this is a good method, I've wrote 'perfect' methods before on my own preknowledge so I could give a shit less about an Example, of using the Speech reference, I had this idea way before I knew there was a reference to use in Visual studio for speech/audio recognition.

  13. #12
    wut12345's Avatar
    Join Date
    Oct 2012
    Gender
    male
    Posts
    294
    Reputation
    16
    Thanks
    1,453
    Quote Originally Posted by Sixx93 View Post
    I'm asking because I'm trying to learn something new... If you are here only to post something to increase your post counter (like you're doing in every thread, posting answers un-needed like this one )

    or





    then go somewhere else.
    No need to get mad.

    ---------- Post added at 09:12 AM ---------- Previous post was at 09:03 AM ----------

    Quote Originally Posted by unknownartist0 View Post
    I don't care If I handle things correctly, I don't care if this is a good method, I've wrote 'perfect' methods before on my own preknowledge so I could give a shit less about an Example, of using the Speech reference, I had this idea way before I knew there was a reference to use in Visual studio for speech/audio recognition.
    Nope your method is bad.
    Last edited by wut12345; 07-24-2013 at 08:07 AM. Reason: People flaming again lol

  14. #13
    Sixx93's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    673
    Reputation
    21
    Thanks
    250
    My Mood
    Cool
    I'm not getting mad... I mean, if you don't want to help, then don't post useless things :\

  15. The Following 2 Users Say Thank You to Sixx93 For This Useful Post:

    Cryptonic (07-26-2013),unknownartist0 (07-26-2013)

Similar Threads

  1. [Outdated] Legit DragonFable Trainer v3.0 (Voice Command Recognition!)
    By unknownartist0 in forum DragonFable (DF) Hacks / Cheats / Trainers
    Replies: 24
    Last Post: 09-09-2013, 05:42 AM
  2. Send Command To console example code
    By 1ackass in forum Call of Duty Modern Warfare 2 Coding / Programming / Source Code
    Replies: 2
    Last Post: 06-17-2013, 12:38 PM
  3. Changing basic game voices from male voice to female voice
    By ninjastormns in forum CrossFire Mods & Rez Modding
    Replies: 2
    Last Post: 07-10-2012, 04:43 AM
  4. Voice commands language [Project Nova]
    By Glaceon in forum CrossFire Mods & Rez Modding
    Replies: 7
    Last Post: 04-21-2012, 10:50 AM
  5. The Command Voices?
    By Razorx12 in forum Call of Duty Modern Warfare 2 Help
    Replies: 0
    Last Post: 04-16-2011, 08:07 AM