Search code examples
c#winformsvoice-recognitionspeech-to-text

How to select specific words in textbox by voice recognization in winforms


I have created Voicepad which have simple 'notepad' or 'ms word' features but in addition i have put some voice commands such as perform bold, italic, cut, paste, change font, size, color etc etc. The problem is that i wanna select specific word for-example ( in textbox this line has written "The quick brown hungry fox jumps over the lazy dog" ). Now what should i do in coding that when i say 'select fox' or 'select hungry' so that word will have selection?


Solution

  • Can you get the words the user has spoken ? if so just separate the words into string array with the " " (space delimiter) using split method so the first item in the array is the command , if it was equal to select then take the second item which will be the word "fox" in your case and use the method indexOf(value) to get the index of the first letter if it was found in the text. then use the properties SelectionStart and SelectionLength of your textbox to highlight the word.