Using Web Search Grammars with SpeechRecognizerUI in Windows Phone

The built-in dictation grammar is used for the SpeechRecognizerUI when the grammar is not added to the grammar set of the SpeechRecognizerUI object.

Below is a sample code snippet demonstrating how to set and use the Web Search Grammars for recognizing speech.

Using Web Search Grammars with SpeechRecognizerUI in Windows Phone

async private void Button_Click_1(object sender, RoutedEventArgs e)

{

SpeechRecognizerUI speech = new SpeechRecognizerUI();

speech.Recognizer.Grammars.AddGrammarFromPredefinedType("Web Serach", SpeechPredefinedGrammar.WebSearch);

SpeechRecognitionUIResult result = await speech.RecognizeWithUIAsync();

if (result.ResultStatus == SpeechRecognitionUIStatus.Succeeded)

{

MessageBox.Show(result.RecognitionResult.Text);

}

}