Handling Data
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.
The speech recognition engine sends recognized text results to voice response applications using Semantic Markup Language (SML). Use the following Microsoft ASP.NET Speech Controls to validate the SML results and bind them to other controls or script variables.
Speech Control | Description |
---|---|
Speech CompareValidator |
Use the Speech CompareValidator (CompareValidator) control to validate the data in a SemanticItem by comparing its data to the data in another control or to a constant value. |
Speech CustomValidator |
Use the Speech CustomValidator (CustomValidator) control to validate the data in a SemanticItem using a custom client-side script. |
Speech RecordSound |
Use the Speech RecordSound (RecordSound) control to record input spoken by a user. |
Speech SemanticMap |
Use the Speech SemanticMap (SemanticMap) control to define semantic properties that a QA control sends to an application using SML output. SemanticMap controls are comprised of a set of SemanticItem controls, which contain information about a QA control's semantic state and its binding and autopostback characteristics. |
Validating Data
Use the CompareValidator and CustomValidator controls to validate data. Although both controls are similar in purpose, the CompareValidator control supports validation with a fixed set of operators and the CustomValidator control supports validation by means of application-specific client-side scripts.
Validating Data by Comparing Values
The SemanticItemToValidate property of the CompareValidator control references the SemanticItem that contains the data to be validated. The CompareValidator is activated when this data is changed or confirmed, depending on the setting of the ValidationEvent property. The data to be validated is compared either with data in the control referenced by the SemanticItemToCompare property or with constant data in the ValueToCompare property.
The Operator property specifies the type of comparison, such as equal to or less than. If the result of the comparison is false, CompareValidator invalidates the item specified by SemanticItemToValidate. If the result is false and the InvalidateBoth property is true, the SemanticItemToValidate and SemanticItemToCompare properties are both invalidated.
When the result of the comparison is false, the CompareValidator plays an associated prompt to inform the user that the data is invalid.
To validate data by comparing data
In the Toolbox, drag a CompareValidator control onto the design canvas of an ASP.NET (.aspx) page.
Right-click the CompareValidator control, and then click Property Builder to open the General panel of the CompareValidator Property Builder.
In the ID box, type a unique ID for this CompareValidator control.
Note
The ID of a Speech Control or Application Speech Control must consist entirely of ASCII characters in the ranges A???Z, a???z, and 0???9. IDs containing characters outside this range might fail to display properly and references to these IDs might fail.
If applicable, in the Speech Control Settings box, type or select the ID of the SpeechControlSettingsItem to apply to this CompareValidator control.
In the ValidationEvent list, do one of the following:
- Click onconfirmed to specify that the CompareValidator control runs each time the State property of the associated SemanticItem control changes to Confirmed.
- Select onchanged to specify that the CompareValidator control runs each time the Text property of the associated SemanticItem control changes.
In the SemanticItemToValidate list, type or select the ID of the SemanticItem containing the data to be validated, and then do one of the following:
- If comparing data to a SemanticItem, type or select the ID of the SemanticItem containing comparison data in the SemanticItemToCompare box.
- If comparing data to a constant value, enter the constant value in the ValueToCompare box.
In the Type list, click the data type of the data being compared, and then click the comparison operator in the Operator list.
To inform users of invalid data
In the CompareValidator Property Builder, click Prompt under the Voice Output heading.
Associate either an inline prompt or a prompt function with the CompareValidator control to play a prompt when the compared data is not valid.
Note
The process of associating prompts with a CompareValidator control is identical to the process of associating prompts with a QA control.
Validating Data by Using Client-Side Scripts
The SemanticItemToValidate property of the CustomValidator control references the SemanticItem containing the data to be validated. The CustomValidator is activated when this data is changed or confirmed, depending on the setting of the ValidationEvent property. The data to be validated is evaluated by the client-side script procedure specified in the ClientValidationFunction property. If the script returns false, the data in the control is invalidated.
When the result of the comparison is false, the CustomValidator control plays an associated prompt to inform the user that the data is invalid.
To validate data using client-side scripts
In the Toolbox, drag a CustomValidator control onto the design canvas of an .aspx page.
Right-click the CompareCustomValidator control, and then click Property Builder to open the General panel of the CustomValidator Property Builder.
In the ID box, type a unique ID for this CustomValidator control.
In the ValidationEvent list, do one of the following:
- Click onconfirmed to specify that the CustomValidator control runs each time the State property of the associated SemanticItem control changes to Confirmed.
- Click onchanged to specify that the CompareValidator control runs each time the Text property of the associated SemanticItem control changes.
In the SemanticItemToValidate box, type or select the ID of the SemanticItem control containing the data to be validated.
In the ClientValidationFunction box, type the name of the client-side script that evaluates the data.
To inform users of invalid data
In the CustomValidator Property Builder, click Prompt under the Voice Output heading.
Associate either an inline prompt or a prompt function with the CustomValidator control to play a prompt when the compared data is invalid.
Note
The process of associating prompts with a CustomValidator control is identical to the process of associating prompts with a QA control.
Binding Data to Controls or Script Variables
Bind recognition data to Web page elements and JScript variables using the value or selectedIndex of SemanticItems and Web page elements as source data. Voice response applications retrieve data from SemanticItems.
Recording Input Spoken by a User
Use the RecordSound control to record input spoken by a user and to copy the recorded file to the Web server from Speech Server for future playback.
For example, use the RecordSound control to record the user's response to the application prompt "Please say your name and address after the beep."
To record input spoken by a user
In the Toolbox, drag a RecordSound control onto the design canvas of an .aspx page.
Right-click the control, and then click Properties.
In the SavePath box, type the full local path on the Web server where the file is saved.
For example, C:\RecordedSounds\Sound001.wav.
In the PlaybackUrlBase box, type the base URL used to construct a playback path for replaying the sound from the Web server.
For example, http://localhost/CompanySounds.
Enter other property values as appropriate.
When the saved file is accessed for playback, the base URL is concatenated with the saved file, as shown in the following code example.
PlaybackUrlBase = http://localhost/CompanySounds
Saved file = Sound001.wav
Downloaded file = http://localhost/CompanySounds/Sound001.wav