private async void InitializeSpeechRecognizer() { // Create an instance of SpeechRecognizer. this.speechRecognizer = new Windows.Media.SpeechRecognition.SpeechRecognizer(); // Add a grammar file constraint to the recognizer. var storageFile = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Colors.grxml")); var grammarFileConstraint = new Windows.Media.SpeechRecognition.SpeechRecognitionGrammarFileConstraint(storageFile, "colors"); this.speechRecognizer.UIOptions.ExampleText = @"Ex. ""blue background"", ""green text"""; this.speechRecognizer.Constraints.Add(grammarFileConstraint); // Compile the constraint. await this.speechRecognizer.CompileConstraintsAsync(); }