Specifying and Testing User Input

  Microsoft Speech Technologies Homepage

User input in voice-only applications can consist of the words or phrases a user speaks into a telephone, or keypresses on a numeric keypad (keypad). The guidelines that specify what words or phrases a user can say or the keypresses a user can enter are defined using grammars. Speech grammars define the words or phrases users can speak, and dual tone multi-frequency (DTMF) grammars define the keypresses users can enter.

Use the Input panels of the QA Property Builder to associate both speech and DTMF grammars with a QA control, test sample phrases and keypresses against the grammars, and specify speech and DTMF time-out properties.

To associate a new speech or DTMF grammar file with a QA control

  1. Right-click a QA control on an .aspx page, and on the shortcut menu, click Property Builder to open the General panel of the QA Property Builder.
  2. In the tree view pane on the left, under the Input heading, click General, and then do one of the following.
    • For a new speech grammar, click the Grammar tab, and then click Add New Grammar.
    • For a new DTMF grammar, click the DTMF tab, and then click Add New Grammar.
  3. In the Add New Grammar dialog box, enter a unique ID for the new grammar file, and then click OK.
  4. In the Add New Grammar File dialog box, browse to the correct location, and then click Save.
  5. Click Apply to save changes.

To associate a new inline speech or DTMF grammar with a QA control

  1. Right-click a QA control on an .aspx page, and on the shortcut menu, click Property Builder to open the General panel of the QA Property Builder.
  2. In the tree view pane on the left, under the Input heading, click General, and then do one of the following.
    • For a new inline speech grammar, click the Grammar tab, and then click Add New Inline Grammar.
    • For a new inline DTMF grammar, click the DTMF tab, and then click Add New Inline Grammar.
  3. In the Add Grammar dialog box, enter a unique ID for the inline grammar.
  4. In the Inline Grammar Text text box, manually modify the grammar template, and then click OK to close.

To associate an existing speech or DTMF grammar file with a QA control

  1. Right-click a QA control on an .aspx page, and on the shortcut menu, click Property Builder to open the General panel of the QA Property Builder.

  2. In the tree view pane on the left, under the Input heading, click General, and then do one of the following.

    • For an existing speech grammar, click the Grammar tab, and then click Add Existing Grammar.
    • For an existing DTMF grammar, click the DTMF tab, and then click Add Existing Grammar.
  3. In the Add Existing Grammar dialog box, type a unique ID for this grammar file, and then click Browse.

  4. In the Grammar URL browser 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. Developers should move grammar files into the current project before adding them to a QA control.

  5. Click OK to close the Grammar URL browser dialog box.

  6. In the Add Existing Grammar dialog box, specify the active or root rule that applies to this QA control.

Note  Speech Control Editor does not validate grammar files when developers associate them with a QA control. Speech Control Editor attempts to resolve the specified URI to a local path, and then does one of the following.

  • If the URI is successfully resolved to a local path, but the specified file does not exist at the URI, a warning message appears stating that unexpected behavior may result if the file is added. Developers can bypass the warning, and continue adding the file.
  • If the URI is not successfully resolved to a local path, Speech Control Editor does not verify whether the file is actually present at the specified URI.

Note  It is not necessary to add a grammar library file directly to a QA control. Specifying a grammar library in the QA control may cause undefined behavior when the application is deployed. If using the Speech Web Application Project Wizard to create a project, the system automatically adds a copy of the cmnrules.grxml file, named Library.grxml, to the project.

To delete a speech or DTMF grammar associated with a QA control

  1. Right-click a QA control on an .aspx page, and on the shortcut menu, click Property Builder to open the General panel of the QA Property Builder.
  2. In the tree view pane on the left, under the Input heading, click General, and then do one of the following.
    • For a speech grammar, click the Grammar tab, click the grammar file to delete, and then click Delete Grammar.
    • For a DTMF grammar, click the DTMF tab, click the grammar file to delete, and then click Delete Grammar.

To edit a speech or DTMF grammar associated with a QA control

  1. Right-click a QA control on an .aspx page, and on the shortcut menu, click Property Builder to open the General panel of the QA Property Builder.
  2. In the tree view pane on the left, under the Input heading, click General, and then do one of the following.
    • For a speech grammar, click the Grammar tab, click the grammar file to edit, and then click Edit Grammar.
    • For a DTMF grammar, click the DTMF tab, click the grammar file to edit, and then click Edit Grammar.

For grammar files, the name of the grammar file to edit appears in Grammar Explorer. For inline grammars, the inline grammar template appears in the Edit Grammar window.

Note  Editing a grammar file requires Property Builder to close and save all changes.

Testing User Responses Against Speech or DTMF Grammars

Use the XPathTrigger Sample Sentence Tool to test sample phrases or keypresses against a grammar associated with a control, and identify the path through the grammar that creates the resulting Semantic Markup Language (SML). The tool performs this test without opening Speech Grammar Editor.

To test words, phrases, or keypresses against a speech or DTMF grammar

  1. Right-click a QA control on an .aspx page, and on the shortcut menu, click Property Builder to open the General panel of the QA Property Builder.
  2. In the tree view pane on the left, under the Input heading, click General.
  3. Associate a new grammar file, a new inline grammar, or an existing grammar file with the QA control, and then do one of the following.
    • To test against speech grammars, click the Grammar tab, and then click XPathTrigger Sample Sentence Tool to expand the XPathTrigger Sample Sentence tool.
    • To test against DTMF grammars, click the DTMF tab, and then click XPathTrigger Sample Sentence Tool to expand the XPathTrigger Sample Sentence tool.
  4. In the Sample speech input text box, do one of the following.
    • For speech grammars, type the words or phrases to test against the associated speech grammar or grammars, and then click Go.
    • For DTMF grammars, type the keypresses to test against the associated DTMF grammar or grammars, and then click Go.

If the grammars are able to recognize the words, phrases, or keypresses, the resulting SML appears in the window below the Sample speech input field.

XPathTrigger Sample Sentence tool

Note  The city and day SML nodes were created by adding semantic interpretation information (semantic information) to the rule elements that define these items.

If the grammars are not able to recognize the words, phrases, or keypresses, the application displays a window containing the error message "The sample text 'input' was not found in any of the speech grammars in the control. Check that you have the correct root rule set."

Handling User Input

The way an application handles a user's spoken input depends on whether the application implements a system-initiative or mixed initiative dialogue style.

If using the system-initiative dialogue style, the application will accept only one answer in response to a question. Associate a QA control with Answers and Confirms to recognize and confirm the user's response.

If using mixed initiative, the application accepts an answer in response to a specific question, but it can also accept extra answers that apply to questions the application has not asked yet. Associate a QA control with Answers, Extra Answers, and Confirms to recognize and confirm the user's response.

Detailed information about handling user input appears in Recognizing and Confirming Answers.

Specifying Time-out Properties

Enable speech applications to accept pauses in user responses, which allows for a more natural speech pattern, by specifying input time-out properties for both speech and DTMF grammars.

To specify input time-out properties for speech input

  1. Right-click a QA control on an .aspx page, and on the shortcut menu, click Property Builder to open the General panel of the QA Property Builder.
  2. In the tree view pane on the left, under the Input heading, click Speech Time-outs to open the Speech Time-outs Properties panel.
  3. Type any relevant time-out values for the listed properties.

To specify input time-out properties for DTMF input

  1. Right-click a QA control on an .aspx page, and on the shortcut menu, click Property Builder to open the General panel of the QA Property Builder.
  2. In the tree view pane on the left, under the Input heading, click DTMF Properties to open the DTMF Properties panel.
  3. Type any relevant time-out values for the listed time-out properties, and also enter the names of any client-side event handlers that are called when the specified event occurs.

For more information regarding the Input panels of the QA Property Builder, click Help.

See Also

Creating Speech-Enabled Web Pages | Designing Dialogue Flow | Dialogue Organization