Share via


Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

Grammar.Enabled Property

Gets or sets a value that controls whether a Grammar can be used by a recognition engine to perform recognition.

Namespace:  Microsoft.Speech.Recognition
Assembly:  Microsoft.Speech (in Microsoft.Speech.dll)

Syntax

'Declaration
Public Property Enabled As Boolean
    Get
    Set
'Usage
Dim instance As Grammar
Dim value As Boolean

value = instance.Enabled

instance.Enabled = value
public bool Enabled { get; set; }

Property Value

Type: System.Boolean
The Enabled property returns true if a speech recognizer can perform recognition using the speech recognition grammar; otherwise the property returns false. The default is true.

Remarks

An instance of Grammar may be enabled or disabled independently of being loaded by a SpeechRecognitionEngine object.

Examples

The following example shows a check box handler for a TreeView. When the box is checked, the grammar is enabled.

private void _grammarTreeView_AfterCheck(object sender, TreeViewEventArgs eventArgs) 
{
  if (eventArgs.Action != TreeViewAction.Unknown) 
  { // Avoid recursion due to handlers
    if (eventArgs.Node.Parent == null) 
    {
      Grammar grammar = ((Grammar)eventArgs.Node.Tag);
      grammar.Enabled = eventArgs.Node.Checked;
      PropagateCheckStatus(eventArgs.Node);
    } 
    else 
    {
      PropagateCheckStatus(eventArgs.Node.Parent);
    }
  }
}

See Also

Reference

Grammar Class

Grammar Members

Microsoft.Speech.Recognition Namespace

Grammar

SpeechRecognitionEngine

Other Resources

Speech Recognition Grammar Specification Version 1.0