Partilhar via


Recognizing Answers Using Application Speech Controls

  Microsoft Speech Technologies Homepage

Built from Speech Controls such as QA and Command, Application Speech Controls use the predefined grammar rules in the Voice Mode Grammar Library. Use Application Speech Controls when implementing dialogs that involve commonly requested data and that require more complexity than Speech Controls can easily provide.

Application Speech Controls can substitute for QA controls because they already contain built-in prompts and grammars, and manage many of the frequent events occurring in human-computer speech interaction. Use SemanticMap controls to bind the data collected by Application Speech Controls to SemanticItems.

Each Application Speech Control provides a built-in set of Answers that map to SemanticItems. For example, the Phone control contains an AreaCodeSemanticItem, a LocalNumberSemanticItem, and an ExtensionSemanticItem, where each SemanticItem represents a portion of a U.S. phone number. The ZipCode control contains a ZipcodeSemanticItem and an ExtensionSemanticItem, where each SemanticItem represents a portion of a U.S. ZIP Code. Application Speech Controls do not contain ExtraAnswers, but they contain options for specifying grammars that define pre- and post-answer speech and Confirms.

AC Answers panel

To associate Application Speech Controls with SemanticItems

  1. Create one SemanticItem for each piece of collected data.
  2. From the Speech Toolbox, drag any appropriate Application Speech Control onto the design canvas of an .aspx page.
  3. Right-click the control, and on the shortcut menu, click Property Builder to open the General panel of the Property Builder for Application Speech Control. This panel contains the same information as the General panel of the QA Property Builder.
  4. In the tree view pane on the left, under the Input heading, click General.
  5. In the General panel, under the Answers heading, enter the ID or IDs of the SemanticItem or SemanticItems to bind to this control.

Note  The SemanticItem Property Builder contains a SensitiveData flag that can specify whether the semantic data specified by the SemanticItem is sensitive in nature, such as the data collected by SocialSecurityNumber and CreditCardNumber Application Speech Controls, or for other Speech Controls. Set this flag to True to specify that sensitive data is not logged on the server (if logging is turned on).

In addition to the built-in grammars contained in Application Speech Controls, developers can specify optional grammar rules for these controls that define phrases user speak before and after Answers and Confirms.

For example, the Phone Application Speech Control contains built-in grammar rules that recognize only phone numbers, such as "zero zero zero five five five one one one one." The built-in Phone grammar would not recognize user input such as "My area code is zero zero zero, my local number is five five five one one one one, and my extension is one two three." To account for the additional user input, associate additional grammar rules with the Phone control.

AC optional rules

To specify additional grammar rules

  1. Right-click any Application Speech Control, and on the shortcut menu, click Property Builder to open the General panel of the Property Builder for Application Speech Control.

  2. In the tree view pane on the left, under the Input heading, click Optional Rules.

  3. In the OptionalRulesGrammarUrl text box, click Browse.

  4. In the Add New Grammar File dialog box, click the file type for the existing grammar file (.cfg, .xml, or .grxml), and then click a URL type (Absolute, Document Relative, or Root Relative). If the grammar file exists outside the current project, click Browse to locate the file, and then click Open.

    Note  Microsoft Speech Server does not support grammar Uniform Resource Identifiers (URIs) with the scheme "file." Including grammar paths that contain the "file" scheme may lead to unexpected behavior when the application is deployed. Move grammar files into the current project before adding them to Application Speech Control.

  5. In the Property Builder, click Browse next to the OptionalPreAnswerRule, OptionalPostAnswerRule, OptionalPreConfirmRule, or OptionalPostConfirmRule fields to browse for rules that define phrases outside the built-in grammar of Application Speech Control.

  6. Click Apply to save changes.

The rest of a Property Builder for Application Speech Control is similar to a Property Builder for QA.

Application Speech Controls can also specify the CompleteLast server-side event. If AutoPostBack is True, the CompleteLast event raises after the function contained in the OnClientCompleteLast property executes. If AutoPostBack is False, CompleteLast raises at the next postback.

To specify the CompleteLast event

  1. Right-click any Application Speech Control, and on the shortcut menu, click Property Builder to open the General panel of the Application Speech Control Property Builder.
  2. In the tree view pane on the left, under the Events heading, click General.
  3. In the Complete Last field, type or select the name of an existing server-side function, or specify a new one by clicking New.

Use the DataTableNavigator Application Speech Control to navigate though a table of template-specified header/content elements using speech.

Developers specify various columns of a dataset as headers, and other columns as content. By default, the DataTableNavigator control dynamically creates prompts for each row in the dataset based on the specified headers and content. The application reads a header prompt to a user, the user issues a command, such as Read, and the application reads the content prompt associated with the header.

DataTableNavigator data bindings

To bind a dataset to a DataTableNavigator control

  1. From the Speech Toolbox, drag a DataTableNavigator control onto the design canvas of an .aspx page.
  2. Right-click the control, and on the shortcut menu, click Property Builder to open the General panel of the DataTableNavigator Property Builder.
  3. In the DataSource list, click the ID of the dataset to bind to this DataTableNavigator.
  4. If the data source contains more than one table, in the DataMember list, click the ID of the table to bind to this DataTableNavigator.
  5. If applicable, in the DataBindField list, click the dataset field that provides the binding values of the table items, and in the DataTextField list, click the dataset field that provides the grammar for each item in the table.
  6. In the DataHeaderFields list, click the dataset field or fields to include in the header prompt.
  7. In the DataContentFields list, click the dataset field or fields to include in the content prompt.

The DataTableNavigator control also contains a set of built-in grammar rules that accept single-word table navigation commands such as "Read," "Next," "Previous," and other commands. If necessary, developers can substitute a custom grammar rule for each built-in command.

DataTableNavigator data bindings

To specify custom command grammar rules for a DataTableNavigator control

  1. From the Speech Toolbox, drag a DataTableNavigator control onto the design canvas of an .aspx page.
  2. Right-click the control, and on the shortcut menu, click Property Builder to open the General panel of the DataTableNavigator Property Builder.
  3. In the tree view pane on the left, under the Input heading, click Command Rules.
  4. To specify a custom command rule for a built-in command rule, click Browse next to the command rule to receive a custom rule.
  5. If necessary, clear the check box next to a built-in command rule to disable recognition of that command.
  6. If applicable, select Disable column navigation to specify that the columns of the data fields are not spoken by the control.

Customize additional general grammar rules by creating custom grammar templates.

DataTableNavigator grammar template

To specify a custom grammar template

  1. From the Speech Toolbox, drag a DataTableNavigator control onto the design canvas of an .aspx page.
  2. Right-click the control, and on the shortcut menu, click Property Builder to open the General panel of the DataTableNavigator Property Builder.
  3. In the tree view pane on the left, under the Input heading, click General.
  4. In the Grammar template text box, type a custom grammar template, and then click Apply to save changes.

The DataTableNavigator control also contains built-in prompts. Create custom prompts by associating customized header and content templates with the DataTableNavigator.

The following custom header code example illustrates how to change a header template to play a prompt like "Employee number ID."

  Employee number <%# DataBinder.Eval(Container.DataItem, "EmployeeID")%>

The following custom content code example illustrates how to change a content template to play a prompt like "Employee number ID is Name."

  Employee number
<%# DataBinder.Eval(Container.DataItem, "EmployeeID")%>
is
<%# DataBinder.Eval(Container.DataItem, "LastName")%>

DataTableNavigator header and content prompt templates

To specify custom header and content prompt templates

  1. From the Speech Toolbox, drag a DataTableNavigator control onto the design canvas of an .aspx page.
  2. Right-click the control, and on the shortcut menu, click Property Builder to open the General panel of the DataTableNavigator Property Builder.
  3. In the tree view pane on the left, under the Voice Output heading, click Prompt Templates.
  4. In the Header prompt template text box, type a custom header prompt template.
  5. In the Content prompt template text box, type a custom content prompt template.
  6. Click Apply to save changes.

For an example of using the DataTableNavigator control, see the Navigating Tabular Data sample application in the SASDK.

Dynamically Creating Lists Using Speech

Use the ListSelector Application Speech Control to dynamically create a grammar containing a list of text items, from which a user selects a single item.

ListSelector custom grammar template

To bind a dataset to a ListSelector control

  1. From the Speech Toolbox, drag a ListSelector control onto the design canvas of an .aspx page.
  2. Right-click the control, and on the shortcut menu, click Property Builder to open the General panel of the ListSelector Property Builder.
  3. In the DataSource list, click the ID of the dataset to bind to this ListSelector.
  4. If the data source contains more than one table, in the DataMember list, click the ID of the table to bind to this ListSelector.
  5. In the DataBindField list, click the dataset field that provides the binding values of the list items.
  6. In the DataTextField list, click the dataset field that provides the grammar for each item in the list.

The built-in grammar contained in the ListSelector lists in parallel all the objects in the data source. The control puts the binding value corresponding to the recognized value into the TargetElement attribute. Developers customize the grammar by providing a comma-separated list of synonyms rather than a single element. Users can then select the list items using any of the synonym names.

Override the default grammar by providing a grammar template. The following code example illustrates how to enable users to refer to a person in different ways, such as "Samarawickrama," "Prasanna," or "Prasanna Samarawickrama," assuming the data source contains a FirstName and LastName column.

  <%# DataBinder.Eval(Container.DataItem, "LastName") %>, 
<%# DataBinder.Eval(Container.DataItem, "FirstName") %>, 
<%# DataBinder.Eval(Container.DataItem, "FirstName") %> 
<%# DataBinder.Eval(Container.DataItem, "LastName") %>

ListSelector custom grammar template

The following code example illustrates how to retrieve the grammar from a resource, assuming that a resource manager has been initialized and the data source contains a LastName column.

  <%# ResourceManager.GetString(DataBinder.Eval(Container.DataItem, "LastName")) %>

To specify a custom grammar template

  1. From the Speech Toolbox, drag a ListSelector control onto the design canvas of an .aspx page.
  2. Right-click the control, and on the shortcut menu, click Property Builder to open the General panel of the ListSelector Property Builder.
  3. In the tree view pane on the left, under the Input heading, click General.
  4. In the Grammar template text box, type a custom grammar template, and then click Apply to save changes.

The ListSelector control also contains default command prompts that provide the user with help. Create a Command of type "Help" whose scope contains the ListSelector. If developers provide another prompt in the Command control, it will be played before the default prompt.

For an example of using the ListSelector control, see the ListSelector and YesNo sample application in the SASDK.

See Also

Recognizing and Confirming Answers | Application Speech Controls