Click here to Skip to main content
14,330,512 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi,
I'm try to develop a voice recognition program using vb.net. My question is how can i add "paint" to commandchoices at run time when a button is pressed.

Dim commandChoices As New Choices("wordpad", "notepad", "word")
I need to add/append "paint"to this line when a button is pressed at runtime.

Please help me with sample code.

What I have tried:

recog = New SpeechRecognitionEngine()
recog.SetInputToDefaultAudioDevice()
recog.RecognizeAsyncStop()
recog.UnloadAllGrammars()

---form load event---
Dim commandChoices As New Choices("wordpad", "notepad", "word")
Dim grammarBuilder As New GrammarBuilder(New Choices("open", "close", "Hello"))
grammarBuilder.Append(commandChoices)
Dim commandChoices1 As New Choices("google", "facebook", "yahoo", "apple")
Dim grammarBuilder1 As New GrammarBuilder(New Choices("goto"))
grammarBuilder1.Append(commandChoices1)
Dim grammarbuilder2 As New GrammarBuilder(New Choices("Calculator", "TaskManager", "MyComputer", "CommandPrompt", "C-Panel", "D-Drive", "C-Drive"))
Dim g As New Grammar(New Choices(grammarBuilder, grammarBuilder1, grammarbuilder2))
g.Name = "Available programs"
recog.LoadGrammarAsync(g)
recog.RecognizeAsync(RecognizeMode.Multiple)


AddHandler recog.AudioLevelUpdated, AddressOf Me.auevent
AddHandler recog.SpeechRecognized, AddressOf Me.recevent
AddHandler recog.SpeechRecognitionRejected, AddressOf Me.recfailevent
Posted
Updated 8-Oct-19 8:10am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Start with some type of dynamic array/list, a List(Of String) would probably be a good idea. Add the fixed choices at form load time. You can then let the user add any other choices via a dialog or simple text box, and append them to your list. You then need to recreate your grammar for each additional word.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100