Recognizing Answers and ExtraAnswers Using Speech Controls
Answer objects define how to process recognition results and associate them with SemanticItem controls. The speech recognition engine returns recognition results in SML, which organizes recognition text according to the rules in a grammar. Each semantic interpretation information (semantic information) property corresponds to a node in the SML output. The XPathTrigger property of the Answer object identifies the SML node containing the appropriate text for that Answer object. The SemanticItem property of the Answer object defines the ID of the SemanticItem control. The recognition engine sends recognition results to the ID of the SemanticItem control. The value entered in the SemanticItem property determines which property the QA control updates.
If setting the AutoPostBack property to True, developers are responsible for manually adding server-side event handlers for the Changed event of the SemanticItem. The event handler is of type SemanticItemChanged, and typically looks like the following.
mySemanticItem.Changed += new SemanticEventHandler (this.OnMySemanticItemChanged);
To create a SemanticItem
From the Speech Toolbox, drag a SemanticMap control onto the design canvas of an .aspx page.
Right-click the SemanticMap control, and on the shortcut menu, click Property Builder to open the General panel of the SemanticMap Property Builder.
In the ID text box, type a unique ID for this SemanticMap control.
Note The ID of a Speech Control, Application Speech Control, or Basic Speech Control must consist entirely of ASCII characters in the ranges A-Z, a-z and 0-9. IDs containing characters outside this range may fail to display properly, and references to these IDs may fail.
If applicable, in the Speech Control Settings box, type or select the ID of the SpeechControlSettingsItem to apply to this SemanticMap control.
At the bottom left corner of the Property Builder, click Add to create a new folder item in the tree view pane labeled SemanticItem1. New SemanticItems appear with sequential ID numbers appended to the name, such as SemanticItem1, SemanticItem2, and SemanticItem3.
Select the new SemanticItem and specify its properties.
Note Create a SemanticItem for every SML node to be used by an Answer.
For more information regarding the SemanticItem properties, click Help.
To associate an Answer with a QA control
- From the Speech Toolbox, drag a QA control onto the design canvas of an .aspx page.
- Right-click the QA control, and on the shortcut menu, click Property Builder to open the General panel of the QA Property Builder.
- In the tree view pane on the left, under the Input heading, click General, and then do one of the following.
- For speech grammars, click the Grammar tab, and then either add a new speech grammar file, add an inline speech grammar, or add an existing speech grammar file.
- For DTMF grammars, click the DTMF tab, and then either add a new DTMF grammar file, add an inline DTMF grammar, or add an existing DTMF grammar file.
- In the Answers tab, click XPathTrigger Sample Sentence Tool to expand the XPathTrigger Sample Sentence tool.
- In the Sample speech input field, type the words, phrases, or DTMF keypresses that an associated grammar should recognize, and then click Go. This process generates the available XPath expressions that map to the SML results, and populates the values in the XPathTrigger column.
- In the Answers tab, in the SemanticItem column, type or select the ID of the SemanticItem to bind to this QA control.
- In the Answers tab, in the XPathTrigger column, type or select the XPath expression that semantically identifies this Answer object in the resulting SML output.
The values in the SemanticItem column represent the IDs of all SemanticItems available to this Answer object. The values in the XPathTrigger column represent the XPath expressions to the SML nodes that contain the appropriate text for this Answer object.
Handling ExtraAnswers
An extra answer is an answer to a question that an application has not yet asked.
Consider the following dialog. It illustrates a simple back and forth dialog in which a user supplies only answers to the specific questions asked.
Application: "What day do you want to depart?"
User: "Tomorrow."
Application: "What city do you want to fly to?"
User: "Rome."
The following dialog illustrates a dialog in which a user supplies an extra answer to a question that has not yet been asked.
Application: "What day do you want to depart?"
User: "Tomorrow, to Rome."
The answer "Rome" in the previous dialog is an extra answer because the user answered the question "What city do you want to fly to?" without the application explicitly asking it.
There is nothing in the rule definitions of a grammar that differentiates an Answer from an ExtraAnswer. Grammar authors define rules for both Answers and ExtraAnswers in the same way—the only difference between the two is that developers configure a QA control to accept answers in addition to the specific question it asks. These additional answers are ExtraAnswers.
ExtraAnswers apply to applications that implement mixed initiative dialogs. Use the following list as a suggested order of tasks when handling extra answers.
- Identify all the different variations of answers and extra answers that a user might speak, and then build grammars to recognize all the variations.
- Identify which QA controls might get extra answers. The grammar or grammars associated with a QA control must be able to recognize the extra information a user speaks.
- Add the SemanticItem that represents the extra answer to the ExtraAnswers collection.
To associate an ExtraAnswer with a QA control
- 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.
- In the tree view pane on the left, under the Input heading, click General, and then do one of the following.
- For speech grammars, click the Grammar tab, and then either add a new speech grammar file, add an inline speech grammar, or add an existing speech grammar file.
- For DTMF grammars, click the DTMF tab, and then either add a new DTMF grammar file, add an inline DTMF grammar, or add an existing DTMF grammar file.
- In the Extra Answers tab, click XPathTrigger Sample Sentence Tool to expand the XPathTrigger Sample Sentence tool.
- In the Sample speech input text box, type the words, phrases, or DTMF keypresses that an associated grammar should recognize, and then click Go. This process generates the available XPath expressions that map to the SML results, and populates the values in the XPathTrigger column.
- In the Extra Answers tab, in the SemanticItem column, type or select the ID of the SemanticItem to bind to this QA control.
- In the Extra Answers tab, in the XPathTrigger column, type or select the XPath expression that semantically identifies this Extra Answer object in the resulting SML output.
Note Create a SemanticItem for every SML node or attribute value to be used by an ExtraAnswer.