Udostępnij za pośrednictwem


NavigableListActivity.ConfirmationGrammars Property

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Gets the collection of speech grammars that are active during the confirmation phase.

Namespace: Microsoft.SpeechServer.Dialog
Assembly: Microsoft.SpeechServer (in microsoft.speechserver.dll)

Syntax

'Declaration
<DisplayNameAttribute("Confirmation Grammar")> _
<PropertyEditorPanelAttribute("GrammarCollectionPanel")> _
<GlobalizedCategoryAttribute("SpeechCategory")> _
<GlobalizedDescriptionAttribute("DialogActivityCommon_ConfirmationGrammars")> _
<SpeechCustomMarkupSerializerAttribute> _
<TypeConverterAttribute("Microsoft.SpeechServer.Authoring.DialogDesigner.GrammarCollectionConverter, Microsoft.SpeechServer.Authoring.DialogDesigner, Version=2.0.3400.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")> _
<PropertyCodeDomAttribute("GrammarCollectionSerializer")> _
<EditorAttribute("Microsoft.SpeechServer.Authoring.DialogDesigner.GenericSpeechUITypeEditor, Microsoft.SpeechServer.Authoring.DialogDesigner, Version=2.0.3400.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", GetType(UITypeEditor))> _
Public Property ConfirmationGrammars As GrammarCollection
[DisplayNameAttribute("Confirmation Grammar")] 
[PropertyEditorPanelAttribute("GrammarCollectionPanel")] 
[GlobalizedCategoryAttribute("SpeechCategory")] 
[GlobalizedDescriptionAttribute("DialogActivityCommon_ConfirmationGrammars")] 
[SpeechCustomMarkupSerializerAttribute] 
[TypeConverterAttribute("Microsoft.SpeechServer.Authoring.DialogDesigner.GrammarCollectionConverter, Microsoft.SpeechServer.Authoring.DialogDesigner, Version=2.0.3400.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")] 
[PropertyCodeDomAttribute("GrammarCollectionSerializer")] 
[EditorAttribute("Microsoft.SpeechServer.Authoring.DialogDesigner.GenericSpeechUITypeEditor, Microsoft.SpeechServer.Authoring.DialogDesigner, Version=2.0.3400.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", typeof(UITypeEditor))] 
public GrammarCollection ConfirmationGrammars { get; }

Property Value

A GrammarCollection that contains a list of the speech grammars that are active during the confirmation phase.

Remarks

The ConfirmationDtmfGrammars property contains a list of the DTMF grammars that are active during the confirmation phase. The DtmfGrammars property contains a list of the DTMF grammars that are active during the navigation (or get) phase. The Grammars property contains a list of the speech grammars that are active during the navigation phase.

Example

The following example shows some of the steps that are necessary if you provide custom navigation and confirmation grammars. The example carries out three broad tasks: initialization, adding grammar rules to the Grammars and ConfirmationGrammars properties, and attaching an event handler for the Recognized event on each of the grammars that were added.

After the grammar rules are added to the appropriate grammar collection, a while loop iterates through each collection to find the name of each rule and then to attach the appropriate event handler to that rule.

public NavListWorkflow()
{
  InitializeComponent();
  this.browseCities.DataSource = Destinations;
  this.browseCities.DataBind();
  this.browseCities.UseDefaultGrammars = false;
  // We're not going to use the default navigation grammars or confirmation grammars,
  // so load rules to cover them
  this.browseCities.Grammars.Add(new Microsoft.SpeechServer.Recognition.Grammar(new System.Uri("http://localhost/NavList/Grammars/Navigation.grxml", System.UriKind.RelativeOrAbsolute), "First"));
  this.browseCities.Grammars.Add(new Microsoft.SpeechServer.Recognition.Grammar(new System.Uri("http://localhost/NavList/Grammars/Navigation.grxml", System.UriKind.RelativeOrAbsolute), "Last"));
  this.browseCities.Grammars.Add(new Microsoft.SpeechServer.Recognition.Grammar(new System.Uri("http://localhost/NavList/Grammars/Navigation.grxml", System.UriKind.RelativeOrAbsolute), "Next"));
  this.browseCities.Grammars.Add(new Microsoft.SpeechServer.Recognition.Grammar(new System.Uri("http://localhost/NavList/Grammars/Navigation.grxml", System.UriKind.RelativeOrAbsolute), "Previous"));
  this.browseCities.Grammars.Add(new Microsoft.SpeechServer.Recognition.Grammar(new System.Uri("http://localhost/NavList/Grammars/Navigation.grxml", System.UriKind.RelativeOrAbsolute), "Select"));
  // Add a rule for the cities 
  this.browseCities.Grammars.Add(new Microsoft.SpeechServer.Recognition.Grammar(new System.Uri("http://localhost/NavList/Grammars/Navigation.grxml", System.UriKind.RelativeOrAbsolute), "Cities"));

  // Add rules for yes and no
  this.browseCities.ConfirmationGrammars.Add(new Microsoft.SpeechServer.Recognition.Grammar(new System.Uri("http://localhost/NavList/Grammars/Confirmation.grxml", System.UriKind.RelativeOrAbsolute), "Confirmation_Yes"));
  this.browseCities.ConfirmationGrammars.Add(new Microsoft.SpeechServer.Recognition.Grammar(new System.Uri("http://localhost/NavList/Grammars/Confirmation.grxml", System.UriKind.RelativeOrAbsolute), "Confirmation_No"));

  // Attach handlers for the Recognized event on each grammar rule
  int idx = -1;
  IEnumerator en = this.browseCities.Grammars.GetEnumerator();
  while (en.MoveNext())
  {
    idx++;
    if (((Grammar)en.Current).RuleName.Equals("First"))
    {
      this.browseCities.Grammars[idx].Recognized += First_SpeechRecognized;
    }
    else if (((Grammar)en.Current).RuleName.Equals("Last"))
    {
      this.browseCities.Grammars[idx].Recognized += Last_SpeechRecognized;
    }
    else if (((Grammar)en.Current).RuleName.Equals("Next"))
    {
      this.browseCities.Grammars[idx].Recognized += Next_SpeechRecognized;
    }
    else if (((Grammar)en.Current).RuleName.Equals("Previous"))
    {
      this.browseCities.Grammars[idx].Recognized += Previous_SpeechRecognized;
    }
    else if (((Grammar)en.Current).RuleName.Equals("Select"))
    {
      this.browseCities.Grammars[idx].Recognized += Select_SpeechRecognized;
    }
    else if (((Grammar)en.Current).RuleName.Equals("Cities"))
    {
      this.browseCities.Grammars[idx].Recognized += City_SpeechRecognized;
    }
    else break;
  }
  idx = -1;
  en = this.browseCities.ConfirmationGrammars.GetEnumerator();
  while (en.MoveNext())
  {
    idx++;
    if (((Grammar)en.Current).RuleName.Equals("Confirmation_Yes"))
    {
      this.browseCities.ConfirmationGrammars[idx].Recognized += Yes_SpeechRecognized;
    }
    else if (((Grammar)en.Current).RuleName.Equals("Confirmation_No"))
    {
      this.browseCities.ConfirmationGrammars[idx].Recognized += No_SpeechRecognized;
    }
    else break;
  }
}

Thread Safety

All public static (Shared in Visual Basic) members of this type are thread-safe. Instance members are not guaranteed to be thread-safe.

Platforms

Development Platforms

Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003, Windows Vista Ultimate Edition, Windows Vista Business Edition, Windows Vista Enterprise Edition

Target Platforms

Windows Server 2003

See Also

Reference

NavigableListActivity Class
NavigableListActivity Members
Microsoft.SpeechServer.Dialog Namespace
GrammarCollection Class
NavigableListActivity.ConfirmationDtmfGrammars Property
DtmfGrammars
Grammars
Recognized