MenusAndLists (Managed Code Sample)
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 MenusAndLists sample illustrates the use of a MenuActivity to present a variety of sports and a NavigableListActivity to allow the user to navigate through a list of baseball scores.
Featured Highlights
- Using MenuActivity
- Using NavigableListActivity
- Using bookmarks to identify the item that is active when the user says "that one"
Running the Sample
To run the sample
In the Samples\Workflow\MenusAndLists\ directory of the Speech Server installation directory, open the sample solution file.
To start debugging, press F5.
In the Voice Response Debugging Window dialog box, click the SIP Phone tab, enter any numbers in the Called Party and Calling Party boxes, and then click Call.
Remarks
MenusAndLists features a MenuActivity named chooseSport that functions as the main menu for the sample and enables a user to select one sport from a list of four sports (baseball, football, basketball, and hockey). The user can say the name of the sport he or she wants to hear about or say "exit" to stop the sample. For all types of speech input, click Start Recording before speaking. After the recognized result appears in one of the boxes in the User Input pane, click Submit. The grammar is able to recognize utterances such as "I want baseball," "Let's do hockey," and "How about basketball." In each of the preceding sentences, the grammar is able to recognize any of the four sport names. While the main menu's prompt is being played, the grammar is also able to recognize "that one," "I want that one," "Select," and "Give me that one" to identify the correct sport.
The ability of chooseSport to identify the sport asked for by user is provided in the TurnStarting event handler, chooseSport_TurnStarting. This handler constructs the main prompt for chooseSport by extracting the names of the sports from a string variable and by appending a bookmark after each sport. When the user identifies a sport by saying "that one" or similar, the bookmark is used to identify the most-recently-spoken sport in the main prompt.
After the MenuActivity determines the sport the user wants to hear about, an IfElseActivity directs control to one of its five branches. Four of the branches correspond respectively to baseball, football, basketball, and hockey. One of these branches is taken when the recognition result from the main menu matches a string that contains the sport name associated with that branch. The fifth branch is taken if the recognition result matches "exit."
One of the sports, baseball, has a list of game scores that are elements of a NavigableListActivity. A user can navigate through the list of game scores by saying "next" or "previous." When the last game score is reached, saying "next" returns the user to the main menu.
This code sample is intended to demonstrate specific Speech Server features. It does not necessarily reflect best practices with respect to security and privacy. You should carefully review any code that you deploy in production for potential security risks and privacy issues.