Grammars for Windows Phone 8

July 21, 2014

Applies to: Windows Phone 8 and Windows Phone Silverlight 8.1 only

A grammar defines the words and phrases that an app will recognize in speech input. Grammars are at the core of speech recognition and are perhaps the most important factor under your control that influences the accuracy of speech recognition.

You can use three different types of grammars to enable your app to perform speech recognition:

  1. Predefined grammars. Use the predefined dictation and web search grammars provided by Windows Phone.

  2. List grammars. Create lightweight, custom grammars programmatically in the form of simple lists.

  3. XML grammars. Create custom grammars for your app in the XML format defined by the Speech Recognition Grammar Specification (SRGS) Version 1.0.

Which grammar type you use may depend on the complexity of the recognition experience you want to create and your level of expertise in creating grammars. Any one approach may be the best choice for a specific recognition task, and you may find uses for all three types of grammars in your app.

This topic contains the following sections.

Dictation and web search grammars

The predefined dictation and web search grammars provide speech recognition for your app without requiring you to author a grammar. When using these grammars, speech recognition is performed by a remote service and the results are returned to the phone.

The free-text dictation grammar will potentially recognize most words and phrases that a user will say in a given language, and is optimized to recognize short phrases. The predefined dictation grammar is used by default if you don't specify a grammar. Free-text dictation is useful when you want users to be able to say anything. Typical uses include creating notes or dictating the content for a message.

The web search grammar is like a dictation grammar in that it contains a large number of words and phrases that a user might say in a given language, but is optimized to recognize terms that people typically use when searching the web.

Because the predefined dictation and web search grammars are large, and because they are online (not on the phone), performance may not be as fast as with custom grammars that are located on the phone.

Programmatic list grammars

Programmatic list grammars provide a lightweight approach to creating a simple grammar as a list of phrases. A list grammar consists of an array of strings that represents speech input that your app will accept for a recognition operation. You can create list grammars inside your app by passing an array of strings to the M:Windows.Phone.Speech.Recognition.SpeechGrammarSet.AddGrammarFromList(System.String,Windows.Foundation.Collections.IIterable`1) method. Recognition is successful when the speech recognizer recognizes any one of the strings in the array.

List grammars may provide faster performance and greater accuracy than the built-in dictation grammar. However, list grammars are best suited to simple recognition scenarios. For greater authoring flexibility in more complex recognition scenarios, you can create an SRGS grammar.

SRGS grammars

Unlike a programmatic list grammar, you author an SRGS grammar as a static document using the XML format defined by the Speech Recognition Grammar Specification (SRGS) Version 1.0. The XML schema for SRGS provides a powerful set of tools that allows you to create grammars for speech recognition scenarios ranging from basic to complex.

For more info, see SRGS grammars for Windows Phone 8.

Show:
© 2014 Microsoft