static void ListenToBoss() { CultureInfo ci = new CultureInfo("en-US"); _recognizer = new SpeechRecognitionEngine(ci); // Select a voice that matches a specific gender. using (var data = new JONGOS_DBEntities()) { var listCommand = from c in data.Modules orderby c.ID select c; foreach (var item in listCommand.Distinct()) { Perintah.Add(item.VoiceCommand, item); _recognizer.LoadGrammar(new Grammar(new GrammarBuilder(item.VoiceCommand))); } } isRecognizing = false; // load a "hello computer" grammar _recognizer.SpeechRecognized += _recognizer_SpeechRecognized; // if speech is recognized, call the specified method _recognizer.SpeechRecognitionRejected += _recognizer_SpeechRecognitionRejected; _recognizer.SetInputToDefaultAudioDevice(); // set the input to the default audio device _recognizer.RecognizeAsync(RecognizeMode.Multiple); // recognize speech asynchronous }
private static string getDeviceName(int DeviceID) { using (var data = new JONGOS_DBEntities()) { var listCommand = from c in data.Devices where c.DeviceID == DeviceID select c; foreach (var item in listCommand) { return(item.Name); } } return("unknown"); }