Recognizing Speech Using the Dictation and Web Search Grammars

,

The SpeechRecognizerUI uses the online dictation grammar by default if no grammar is added to its grammar set. In the following example, a SpeechRecognizerUI is created and its speech recognizer’s RecognizeAsync method is called. The speech recognizer returns the recognized text in Result property of the SpeechRecognitionResult object, as shown:

SpeechRecognizerUI recognizerUI = new SpeechRecognizerUI();

SpeechRecognitionResult result;

try
{
    result = await recognizerUI.Recognizer.RecognizeAsync();
}
catch (Exception ex)
{
    // Handle unable to recognize speech...
    return;
}

string recognizedText = result.Text;
...

You can explicitly add the dictation, or a web search grammar, to a grammar set using the SpeechGrammarSet.AddGrammarFromPredefinedType, as shown:

SpeechRecognizerUI recognizerUI = new SpeechRecognizerUI();
recognizerUI.Recognizer.Grammars.AddGrammarFromPredefinedType(
    "WebSearch", SpeechPredefinedGrammar.WebSearch);

Unlike the dictation grammar, which is loaded by default, the web search grammar must be added to a speech recognizer’s grammar set before starting recognition.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.25.163