VB.NET Tutorial - Voice Commands

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
4,165
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Apr 22, 2011

In this tutorial I show you how to embed voice commands into your application using VB.NET.

http://duckhouse.weebly.com/tutorials.html

Download Module - http://bit.ly/hLBo9W
Download All Project Files - http://bit.ly/g7qIiK

Code:


Imports SpeechLib

Module SpeechForm1 'Copyrighted By Ashley M Begley 'DECLARING THE VARIABLES THAT ARE NEEDED FOR VOICE RECOGNITION Dim WithEvents RecoContext As SpSharedRecoContext 'Used to store the charectar of each letter spoken Dim Grammar As ISpeechRecoGrammar 'Used to store a dictionary of words and letters so the program can recognise them Dim CharCount As Integer 'Counts the amount of letters used at a time Public SpeechLibrary_ResultToString As String 'All the results from the text will be made here 'This is the sub which activates once the command has been recognised 'Use this sub to say what happens if certain words are used. Private Sub SpeechLibrary_COMMAND_LIST() '- - - - - Example Use - - - - - 'If SpeechLibrary_ResultToString = "whatever you have said" Then ' DO THIS 'End If If SpeechLibrary_ResultToString = "hello" Then Form1.Label3.Text = "Hello" End If End Sub 'This function will convert any text entered into it into speech! Public Sub SpeechLibrary_TextToSpeech(ByVal TextToSpeak) Dim SAPI SAPI = CreateObject("sapi.spvoice") 'sapi.spvoice' meaning the Speech engine SAPI.Speak(TextToSpeak) 'Speak what the user has requested. End Sub 'This function will stop the speech recognition feature. Public Sub SpeechLibrary_StopSpeechRecognition() Grammar.DictationSetState(SpeechRuleState.SGDSInactive) 'Turns off the Recognition End Sub 'This function will start the speech recognition feature. 'NOTE: This must be turned on before you can start to use speech recognition Public Sub SpeechLibrary_StartSpeechRecognition() 'First check to see if reco has been loaded before. If not lets load it. If (RecoContext Is Nothing) Then RecoContext = New SpSharedRecoContextClass 'Create a new RecoContextClass Grammar = RecoContext.CreateGrammar(1) 'Setup the Grammar Grammar.DictationLoad() 'Load the Grammar End If Beep() 'Make the computer beep so the user knows that speech recognition has started Grammar.DictationSetState(SpeechRuleState.SGDSActive) 'Turns on the Recognition End Sub 'This function is here for when the speech is recognised. Private Sub OnReco(ByVal StreamNumber As Integer, ByVal StreamPosition As Object, ByVal RecognitionType As SpeechRecognitionType, ByVal Result As ISpeechRecoResult) Handles RecoContext.Recognition Dim recoResult As String = Result.PhraseInfo.GetText 'Create a new string, and assign the recognized text to it. Dim txt As New Windows.Forms.TextBox txt.SelectionStart = CharCount txt.SelectedText = recoResult.ToLower CharCount = CharCount + 1 + Len(recoResult) SpeechLibrary_ResultToString = txt.Text SpeechLibrary_COMMAND_LIST() txt.Clear() End Sub
End Module

Link to this comment:

Share to:

Uploader Comments (DuckHouseProductions)

  • god damn your clicking is fucking anoying, and your slow, you drag shit out way too much. thumbs down

  • @AZIlluminati08 When you upload something better than this I will stop ignoring your comments.

see all

All Comments (16)

Sign In or Sign Up now to post a comment!
  • could u but the link for code source and the projet ? pls.  any body with me?

  • @Hamilation haha

  • thanks for ur video realy very cool . i whant to tell u thes is my projet and i have some pb could u help me pls?

    the pb i dont have thise commande speechlibrary_startspeechrecog­nition()

    i have vb.net 2010 pro

  • @DuckHouseProductions he just got OWNED!

  • i have followed this to the letter and mine just will not action any command that i tell it it do. do i have to reference the module somewhere within the form loading. I just dont know im all out of ideas here. Please lend a hand. I have no errors at all, it just will not confirm any actions that i place under any particular string i dictate. Again please help me.

  • @DuckHouseProductions not oploading anything is better than your garbage, good day

  • What is wrong with you guys??? Why everybody uses the most annoying sound in the world for the mouse buttons??? It is annoying for everybody, including the ones posting them. PEOPLE WILL START TO USE THE MUTE BUTTON GUYS, DON'T YOU REALIZE???

  • @gasdav08 it must be vs 2010...

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more