Skip to content

Latest commit

 

History

History
109 lines (60 loc) · 5.75 KB

specify-the-speech-recognizer-language.md

File metadata and controls

109 lines (60 loc) · 5.75 KB
author Description title ms.assetid label template keywords ms.author ms.date ms.topic ms.prod ms.technology ms.localizationpriority
Karl-Bridge-Microsoft
Learn how to select an installed language to use for speech recognition.
Specify the speech recognizer language
4C463A1B-AF6A-46FD-A839-5D6724955B38
Specify the speech recognizer language
detail.hbs
speech, voice, speech recognition, natural language, dictation, input, user interaction
kbridge
02/08/2017
article
windows
uwp
medium

Specify the speech recognizer language

Learn how to select an installed language to use for speech recognition.

Important APIs: SupportedTopicLanguages, SupportedGrammarLanguages, Language

Here, we enumerate the languages installed on a system, identify which is the default language, and select a different language for recognition.

Prerequisites:

This topic builds on Speech recognition.

You should have a basic understanding of speech recognition and recognition constraints.

If you're new to developing Universal Windows Platform (UWP) apps, have a look through these topics to get familiar with the technologies discussed here.

User experience guidelines:

For helpful tips about designing a useful and engaging speech-enabled app, see Speech design guidelines .

Identify the default language

A speech recognizer uses the system speech language as its default recognition language. This language is set by the user on the device Settings > System > Speech > Speech Language screen.

We identify the default language by checking the SystemSpeechLanguage static property.

var language = SpeechRecognizer.SystemSpeechLanguage; 

Confirm an installed language

Installed languages can vary between devices. You should verify the existence of a language if you depend on it for a particular constraint.

Note  A reboot is required after a new language pack is installed. An exception with error code SPERR_NOT_FOUND (0x8004503a) is raised if the specified language is not supported or has not finished installing.

 

Determine the supported languages on a device by checking one of two static properties of the SpeechRecognizer class:

Specify a language

To specify a language, pass a Language object in the SpeechRecognizer constructor.

Here, we specify "en-US" as the recognition language.

var language = new Windows.Globalization.Language(en-US); 
var recognizer = new SpeechRecognizer(language); 

Remarks

A topic constraint can be configured by adding a SpeechRecognitionTopicConstraint to the Constraints collection of the SpeechRecognizer and then calling CompileConstraintsAsync. A SpeechRecognitionResultStatus of TopicLanguageNotSupported is returned if the recognizer is not initialized with a supported topic language.

A list constraint is configured by adding a SpeechRecognitionListConstraint to the Constraints collection of the SpeechRecognizer and then calling CompileConstraintsAsync. You cannot specify the language of a custom list directly. Instead, the list will be processed using the language of the recognizer.

An SRGS grammar is an open-standard XML format represented by the SpeechRecognitionGrammarFileConstraint class. Unlike custom lists, you can specify the language of the grammar in the SRGS markup. CompileConstraintsAsync fails with a SpeechRecognitionResultStatus of TopicLanguageNotSupported if the recognizer is not initialized to the same language as the SRGS markup.

Related articles

Developers

Designers

Samples