public NewsModel(NewsViewModel vm) { viewModel = vm; VoiceController = new NewsVoiceController("Grammar\\newsGrammar.xml", this); //Start the news on top stories. UpdateNews("cnn_topstories.rss"); }
public WeatherModel(WeatherCurrentViewModel current, WeatherDayViewModel today, WeatherDayViewModel tomorrow, WeatherWeekViewModel week) { currentWeather = current; todaysWeather = today; tomorrowsWeather = tomorrow; weeksWeather = week; currentlyVisible = currentWeather; VoiceController = new WeatherVoiceController("Grammar\\weatherGrammar.xml", this); }
public async Task <bool> LoadVoiceControlModule(IVoiceController module) { //If the module is not loaded. if (!IsModuleLoaded(module)) { //Create the grammar for the passed in module. SpeechRecognitionGrammarFileConstraint grammar = await CreateGrammarFromFile(module.GrammarFilePath, module.VoiceControlKey); //Add the grammar file from the passed in module to the speech recognizer _recognizer.Constraints.Add(grammar); //Store the module into the activeModules Dictionary activeModules[module.VoiceControlKey] = module; //Set the voice control memeber variables of the module. module.IsVoiceControlLoaded = true; module.IsVoiceControlEnabled = true; module.Grammar = grammar; return(true); } return(false); }
//Handle appropriate voice commands private void RecognizerResultGenerated(SpeechContinuousRecognitionSession session, SpeechContinuousRecognitionResultGeneratedEventArgs args) { // Output debug strings // Debug.WriteLine(args.Result.Status); // Debug.WriteLine(args.Result.Text); //This is how we will tell which module grammar the command came from // Debug.WriteLine("Grammar File Constraint Tag: " + args.Result.Constraint.Tag); // // Debug.WriteLine(args.Result.Confidence.ToString()); // Debug.WriteLine("Confidence 0 = High, 1 = Medium, 2 = Low"); // // int count = args.Result.SemanticInterpretation.Properties.Count; // Debug.WriteLine("Count: " + count); // Debug.WriteLine("Tag: " + args.Result.Constraint.Tag); //Receive the commands and pass it to the appropriate module to handle IVoiceController commandsModule = activeModules[args.Result.Constraint.Tag]; commandsModule.EnqueueCommand(args.Result); }
public bool IsModuleLoaded(IVoiceController module) { return(activeModules.ContainsValue(module)); }