Walkthrough: ASP.NET Application Speech Control Development
ASP.NET Application Speech Controls enable application authors to quickly and easily add speech to Web pages. Application Speech Controls provide a speech interface that allows users to perform common tasks such as picking a date, choosing a ZIP Code, or selecting an item in a list. A control can be developed for use in both multimodal and voice-only modes; the control developer chooses the mode that the control supports.
The goal of developing a custom control is to provide application authors with a tool that enables them to quickly and easily add speech to a well-defined user task. Good control design strikes a balance between hiding information and allowing customization by application authors. If too much information is hidden, authors may not be able to adapt the control to their specific needs; if too much customization is allowed, control setup may become prohibitively complicated.
Design Application Speech Controls so that they inherit from the ApplicationControl class to ensure that the controls have the common customization capability of Application Speech Controls. Refer to the documentation on ApplicationControl Class for a complete description of the methods that this class provides. Use of the ApplicationControl class is illustrated in the topic ColorChooser: A Custom Application Speech Control.
Developing Application Speech Controls requires familiarity with ASP.NET Speech Controls and World Wide Web Consortium (W3C) standards. Knowledge of ASP.NET custom controls is beneficial.
Developing a Control: Basic Considerations
Application Speech Controls use Speech Controls to manage interaction with users. They contain built-in prompts, grammars, and a predefined dialogue flow. It is best practice to first design the prompts, grammars, and dialogue flow for the control. Consider the following design points when developing Application Speech Controls:
- The required semantic items. Determine the number of semantic items that are needed to store the information obtained from the users.
- The required grammars. Define grammars that will recognize the words and phrases that users are expected to say.
- The supported modes of operation. Decide what the most effective interfaces will be for users to obtain the information they need: a multimodal interface, a voice-only interface, or a combination of both.
- The required dialogue flow (for voice-only mode). Define the anticipated series of user speech input and application speech output.
- The required prompts (for voice-only mode). Define prompts that elicit the appropriate information from users.
Developing a Control: Choosing a Parent Class
In order to maintain consistency across controls and offer a standard ability to customize, controls should inherit from one of the following classes.
- The ApplicationControl class in the Microsoft.Web.UI.SpeechControls.ApplicationControls namespace. This class defines common properties that are useful when building an application control.
- The SpeechControlContainer class in the Microsoft.Web.UI.SpeechControls namespace. Use this class only if the ApplicationControl class is not suitable for the application control.
The SASDK ColorChooser Application Speech Control
The documents in this topic demonstrate the step-by-step creation of the Speech Application SDK (SASDK) ColorChooser control. When the sample runs, it prompts the user to select a color. Saying help causes the application to list the colors that the user can select. The colors that the user can select are blue, red, green, and yellow. When the user selects a color, the application confirms the color choice. The documents in this topic illustrate the code behind the following development steps:
- Creating ColorChooser: A Custom Application Speech Control
- Creating the Class and SemanticItem Property
- Creating the Grammars
- Implementing the Dialogue Flow
- Generating Prompts
- Creating a Client-Side Object and SALT
For reference, the finished code for this sample is included in the Samples.sln file that is included with the SASDK. The default installation location for the solution file is:
C:\Program Files\Microsoft Speech Application SDK 1.1\Applications\Samples.sln
Building and Running ColorChooser
To build and run the ColorChooser control sample:
- Open Samples.sln in Visual Studio.
- In the Build menu, select Rebuild Solution....
- In Solution Explorer, expand the ColorChooser subdirectory that is inside the Samples project.
- Right-click ChooseColor.aspx and select Set As Start page.
- Press F5 to build and run the sample.
The sample opens and runs in voice-only mode.