winforms - Speech recognition without predefined Choices in C# -


i'm trying develop speechrecognition demo app in c#. code is-

public partial class form1 : form {     speechsynthesizer ss = new speechsynthesizer();     promptbuilder pb = new promptbuilder();     speechrecognitionengine sre = new speechrecognitionengine();     choices choices;     public form1()     {         initializecomponent();     }      private void btnstart_click(object sender, eventargs e)     {         choices = new choices();         choices.add(new string[]{"hello","how you","thank you"});         grammar gr = new grammar(new grammarbuilder(choices));         try         {             sre.requestrecognizerupdate();             sre.loadgrammar(gr);             sre.speechrecognized += sre_speechrecognized;             sre.setinputtodefaultaudiodevice();             sre.recognizeasync(recognizemode.multiple);         }         catch (exception ex)         {             messagebox.show(ex.message,"error");         }     }      void sre_speechrecognized(object sender, speechrecognizedeventargs e)     {         switch (e.result.text.tostring())         {             case "hello":                 ss.speakasync("hello");                 break;             case "how you":                 ss.speakasync("how you");                 break;             case "thank you":                 ss.speakasync("thank you");                 break;             default:                 break;         }          txtvoicetotext.text += e.result.text.tostring() + environment.newline;     } } 

if don't want use predefined choices, there way out?

try speechrecognition in dictationmode. can see example here


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -