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
god damn your clicking is fucking anoying, and your slow, you drag shit out way too much. thumbs down
AZIlluminati08 3 months ago
@AZIlluminati08 When you upload something better than this I will stop ignoring your comments.
DuckHouseProductions 3 months ago