SpeechRecognitionGrammarFileConstraint SpeechRecognitionGrammarFileConstraint SpeechRecognitionGrammarFileConstraint SpeechRecognitionGrammarFileConstraint Class

Definition

A custom grammar constraint based on a list of words or phrases (defined in a Speech Recognition Grammar Specification (SRGS) file) that can be recognized by the SpeechRecognizer object.

Note

Speech recognition using a custom constraint is performed on the device.

public : sealed class SpeechRecognitionGrammarFileConstraint : ISpeechRecognitionConstraint, ISpeechRecognitionGrammarFileConstraint
public sealed class SpeechRecognitionGrammarFileConstraint : ISpeechRecognitionConstraint, ISpeechRecognitionGrammarFileConstraint
Public NotInheritable Class SpeechRecognitionGrammarFileConstraint Implements ISpeechRecognitionConstraint, ISpeechRecognitionGrammarFileConstraint
var speechRecognitionGrammarFileConstraint = new speechRecognitionGrammarFileConstraint(file);
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

Constraints, or grammars, define the spoken words and phrases that can be matched by the speech recognizer. You can specify one of the pre-defined, web-service grammars (SpeechRecognitionTopicConstraint ) or you can create a custom grammar, described here, that is installed with your app (speech recognition using a custom constraint is performed on the device).

  • Programmatic list constraints (SpeechRecognitionListConstraint ) provide a lightweight approach to creating simple grammars using a list of words or phrases. A list constraint works well for recognizing short, distinct phrases. Explicitly specifying all words in a grammar also improves recognition accuracy, as the speech recognition engine must only process speech to confirm a match. The list can also be programmatically updated.
  • An Speech Recognition Grammar Specification (SRGS) grammar (SpeechRecognitionGrammarFileConstraint ) is a static document that, unlike a programmatic list constraint, uses the XML format defined by the Version 1.0. An Speech Recognition Grammar Specification (SRGS) grammar provides the greatest control over the speech recognition experience by letting you capture multiple semantic meanings in a single recognition.

CompileConstraintsAsync must always be called before RecognizeAsync or RecognizeWithUIAsync, even if no constraints are specified in the Constraints property.

Constructors

SpeechRecognitionGrammarFileConstraint(StorageFile) SpeechRecognitionGrammarFileConstraint(StorageFile) SpeechRecognitionGrammarFileConstraint(StorageFile) SpeechRecognitionGrammarFileConstraint(StorageFile)

Creates an instance of the SpeechRecognitionGrammarFileConstraint class from a file object.

public : SpeechRecognitionGrammarFileConstraint(StorageFile file)
public SpeechRecognitionGrammarFileConstraint(StorageFile file)
Public Sub New(file As StorageFile)
var speechRecognitionGrammarFileConstraint = new speechRecognitionGrammarFileConstraint(file);
Parameters
file
StorageFile StorageFile StorageFile StorageFile

An object representing a Speech Recognition Grammar Specification (SRGS) grammar file.

See Also

SpeechRecognitionGrammarFileConstraint(StorageFile, String) SpeechRecognitionGrammarFileConstraint(StorageFile, String) SpeechRecognitionGrammarFileConstraint(StorageFile, String) SpeechRecognitionGrammarFileConstraint(StorageFile, String)

Creates an instance of the SpeechRecognitionGrammarFileConstraint class from a file object and a tag.

public : SpeechRecognitionGrammarFileConstraint(StorageFile file, Platform::String tag)
public SpeechRecognitionGrammarFileConstraint(StorageFile file, String tag)
Public Sub New(file As StorageFile, tag As String)
var speechRecognitionGrammarFileConstraint = new speechRecognitionGrammarFileConstraint(file, tag);
Parameters
file
StorageFile StorageFile StorageFile StorageFile

An object representing a Speech Recognition Grammar Specification (SRGS) grammar file.

tag
Platform::String String String String

The tag to assign to the constraint.

See Also

Properties

GrammarFile GrammarFile GrammarFile GrammarFile

Gets the StorageFile object representing the Speech Recognition Grammar Specification (SRGS) grammar file.

public : StorageFile GrammarFile { get; }
public StorageFile GrammarFile { get; }
Public ReadOnly Property GrammarFile As StorageFile
var storageFile = speechRecognitionGrammarFileConstraint.grammarFile;
Value
StorageFile StorageFile StorageFile StorageFile

The object representing the Speech Recognition Grammar Specification (SRGS) grammar file.

See Also

IsEnabled IsEnabled IsEnabled IsEnabled

Gets or sets whether the constraint can be used by the speech recognizer to perform recognition.

public : Platform::Boolean IsEnabled { get; set; }
public bool IsEnabled { get; set; }
Public ReadWrite Property IsEnabled As bool
var bool = speechRecognitionGrammarFileConstraint.isEnabled;
speechRecognitionGrammarFileConstraint.isEnabled = bool;
Value
Platform::Boolean bool bool bool

True if a speech recognizer can perform recognition using the constraint; otherwise false.

See Also

Probability Probability Probability Probability

Gets or sets the weighted value of the constraint.

public : SpeechRecognitionConstraintProbability Probability { get; set; }
public SpeechRecognitionConstraintProbability Probability { get; set; }
Public ReadWrite Property Probability As SpeechRecognitionConstraintProbability
var speechRecognitionConstraintProbability = speechRecognitionGrammarFileConstraint.probability;
speechRecognitionGrammarFileConstraint.probability = speechRecognitionConstraintProbability;
See Also

Tag Tag Tag Tag

Gets or sets a tag that can be useful for identifying the constraint.

public : Platform::String Tag { get; set; }
public string Tag { get; set; }
Public ReadWrite Property Tag As string
var string = speechRecognitionGrammarFileConstraint.tag;
speechRecognitionGrammarFileConstraint.tag = string;
Value
Platform::String string string string

A string representing the tag.

See Also

Type Type Type Type

Gets the type of the constraint.

public : SpeechRecognitionConstraintType Type { get; }
public SpeechRecognitionConstraintType Type { get; }
Public ReadOnly Property Type As SpeechRecognitionConstraintType
var speechRecognitionConstraintType = speechRecognitionGrammarFileConstraint.type;
See Also

See Also