Developer .NET UPDATE, January 21, 2003

Developer .NET UPDATE—brought to you by Windows & .NET Magazine Network.


Microsoft ASP.NET Connections & Visual Studio Connections

DevConnections Events and Windows & .NET Magazine Network

Microsoft ASP.NET Connections + Visual Studio Connections + SQL Server Magazine Connections equals the largest gathering of Microsoft product architects and independent IT gurus, delivering four days of hard-core drill-down sessions that you will not find anywhere else. The Microsoft product team delivers over 35 cutting-edge sessions on the latest product releases. In addition, you can choose from over 100 in-depth sessions presented by our world-class speakers, authors, and consultants who share real-world solutions that will save you months of trial and error. Visit our expo hall to see the latest technology and have a chance to win a Harley Davidson among other cool give-always. After an intense day of sessions unwind at events like "Microsoft Unplugged," where no question is out of line or march in the Mardi Gras Parade to the House of Blues for a night to remember. Register early and get three power-packed events for the price of one. May 6-9, 2003, at the Hilton Riverside New Orleans. For more details, call 800-438-6720 or visit our Web site.

January 21, 2003—In this issue:


  • Getting an Answer


  • Catch the Microsoft Mobility Tour—Time is Running Out!
  • Windows Scripting Solutions for the Systems Administrator


  • Featured Thread: Problems with Installing the .NET Framework SDK


  • Automate the Documentation Process

See this section for a list of ways to contact us.

(contributed by Marquis Howard, [email protected])

  • Getting an Answer

  • Last week, I explained how to make a Web page speak. I introduced the Question/Answer (QA) control, which includes the Prompt object. This object handles the Text-to-Speech (TTS) synthesis that delivers voice output. The Prompt object provided the means to greet the user with a welcome message. Now I want to show how to get the movie preview Web site to accept a voice response. The response will trigger a mechanism to interpret the user's spoken words, process them, and cause the appropriate movie preview to appear.

    Last week, you added the welcomeQA control, which is an instance of the QA control. Now you need to add two more QA controls. Open the project, and select the Speech option in your Toolbox. Drag two additional QA controls into the Web page designer. Right-click the first QA control, select Property Builder, and set the ID property to movieQA. Repeat this process for the second QA control and set its ID property to goodByeQA.

    Next, you need to specify the QA controls' precedence (i.e., the order in which the controls get activated). Open the welcomeQA control's Property Builder. Click "voice only". Set the SpeechIndex property to 1. Repeat this process for the movieQA and goodByeQA controls, setting their SpeechIndex properties to 2 and 3, respectively.

    The original design for the movie preview Web site called for a Web service to provide the movie information for the application. For the purposes here, though, let's just hard-code the names of some fictitious movies. Select the ListBox control that you added last week. In the Properties pane under the Misc category, select the Items property and click the ellipsis button to open the ListItem Collection Editor. In the editor, use the Add button to create four items:

      — Item(0) Dot Net and Beyond
      — Item(1) C Sharp Love Story
      — Item(2) XML for Adults
      — Item(3) The Web Service Matrix Reloaded

    For simplicity, use the same string for the Text and Value properties. For example, set the Text and Value properties of Item(0) to "Dot Net and Beyond".

    The next step is to add a SemanticMap control to the page. When speech recognition occurs, the SemanticMap control binds a QA control's results to another control on the form. For this binding to work, you need to specify the control to receive the results (in this case, ListBox1). Select the Speech tab in the Toolbox, and drag a SemanticMap control onto your page. Open the SemanticMap control's Property Builder, and click Add. Set the ID property to "siName", the TargetElement property to "ListBox1", and the TargetAttribute to "selectedIndex". Then select the BindOnChange check box to complete the binding process.

    Now that the application lists the movies and provides a way for users to select a movie from that list, the application needs to recognize the words the users speak. The QA control handles speech recognition (SR). For the SR engine to recognize a user's speech, you must add one or more "grammars" to each speech control. A grammar is a word or phrase that the QA control will recognize. Grammars use the XML format; when you use Visual Studio .NET's Grammar Editor to save a grammar file, the file has the .grxml extension. The Microsoft Developer Network (MSDN) Web site has a good overview of grammars at this URL.

    The Microsoft .NET Speech platform's SR engine attempts to match audio input it receives against words or phrases within the grammar file. If the SR engine finds a match, recognition occurs and the engine returns the results to the application in Semantic Markup Language (SML) format. The application parses the SML results and displays the words as text input. The January 7 column "Now We're Talking!" discusses how SR works in more detail. For a thorough explanation, you can read the .NET Speech software development kit (SDK) beta 2 documentation or check out the links at this URL.

    Your application already has the QA control needed for SR, so you just need to add a grammar file. From either the File menu or the Project menu, click Add New Item. Select Grammar File in the Templates pane. Change the name from Grammar1 to Movie, then click Open to start the Grammar Editor.

    In the Grammar Editor, you need to add a rule. Rules specify what can be spoken to the application and provide the structure representing how the SR engine interprets words and phrases. In Grammar Explorer, right-click Rule1. In the drop-down list that appears, click Make Root to make Rule1 the startup rule for the application.

    Next, you need to add the words or phrases that will define rule1. Let's anticipate two possible phrases that users might say when they initially start to speak: "I want to watch" and "Let me check out". From the Toolbox, click the Grammar tab and drag a Group control into the rule designer. The top oval object represents a group. Below the Group object is a Phrase object. Because that default isn't what you need, right-click the Phrase object, then select Delete. From the Toolbox's Grammar tab select a List object and place it under the Group object. This action not only creates a List object under the Group object but also creates a Phrase object under the List object. Drag an additional Phrase object from the Toolbox and place it under the Phrase object that was automatically created with the List object.

    With the Phrase objects in place, you need to specify the phrases that these objects represent. Double-click the first Phrase object and type "I want to watch". Double-click the second Phrase object and type "Let me check out".

    Now that you've created the initial phrases, you need to create Phrase objects that represent the four movie names. Reselect the Group object by clicking it. Drag a List object from the Toolbox and place this List object to the right of the Group object. Next, drag three more phrase objects and place them under the new List object. Double-click the first Phrase object and type "Dot Net and Beyond". Double-click the second Phrase object and type "C Sharp Love Story". Repeat this process for the remaining the movie titles.

    To match what the user spoke against what's defined in the grammar rules, the SR engine needs a way to retrieve the correct information. The QA control handles this process; in your application, the movieQA control retrieves the matching value. Because you used the SemanticMap control to bind the movieQA control's results to the ListBox control, the value is delivered to the correct control on the Web page.

    Next, you need to set the properties and values for the grammar rules. Click the Phrase object that represents the movie "Dot Net and Beyond". In the first row of the Semantic Tags table, double-click the Value column and enter the value of 0. Double-click the Property column. After the dollar ($) sign, type ".Movie". Repeat these steps for the rest of the movie names, except increment the number in the Value column by 1 each time.

    After you've saved your grammar file, you can check it by typing a sentence such as "I want to watch Dot Net and Beyond" in the "Recognition string" text box at the top of the Web page designer. Then click Check to validate the phrases you entered.

    Now that you have a custom grammar file, go back to the .aspx page. Right-click movieQA and select the Property Builder. Expand the node labeled Input. Select the General node and click Add Existing Grammar. In the dialog box that appears, select Movie.grxml.

    Next, select the Answer tab in the Property Builder. In the first row of the Semantic Item column, type "siName" (i.e., the name of the SemanticMap control). In the XPath Trigger column, type "/SML/Movie", then close the Property Builder, saving your changes.

    Finally, right-click the goodByeQA control. Set the Inline property to any goodbye message that you want. Save your work.

    You're now ready to test your application. Start your application from Visual Studio .NET by clicking Run. The browser will open and immediately start reading your Web page.

    My experience in dealing with the .NET Speech SDK has been somewhat of a pleasure. Because I used the GUI interface in Visual Studio .NET, I had to write very little code—Visual Studio .NET handled all the "plumbing" for me. The tutorials and help guides provide enough information for even a novice programmer to start developing some fun and useful applications.


    Now you can receive timely information about technical education conferences and seminars from DevConnections Events and Windows & .NET Magazine Network. Stay up to date on the latest details about Microsoft ASP.NET Connections, Visual Studio Connections, SQL Server Magazine Connections, Windows & .NET Magazine Connections, and XML Web Services Connections. Subscribe for FREE by sending a blank email to:
    mailto:[email protected]

    (brought to you by Windows & .NET Magazine and its partners)


  • This outstanding seven-city event will help you support your growing mobile workforce. Industry guru Paul Thurrott discusses the coolest mobility hardware solutions around, demonstrates how to increase the productivity of your "road warriors" with the unique features of Windows XP and Office XP, and much more. You could also win an HP iPAQ Pocket PC. There is no charge for these live events, but space is limited, so register today! Sponsored by Microsoft, HP, and Toshiba.


  • You might not be a programmer, but that doesn't mean you can't learn to create and deploy timesaving, problem-solving scripts. Discover Windows Scripting Solutions, the monthly print publication that helps you tackle common problems and automate everyday tasks with simple tools, tricks, and scripts. Try a sample issue today.



  • Forum member Beaker has installed Microsoft Internet Information Services (IIS) 5.0 on two Windows 2000 Professional machines and subsequently tried to install the Microsoft .NET Framework software development kit (SDK). On his laptop, the installation went smoothly. However, he can't install the .NET Framework SDK on his desktop. If you can help, go to

    (contributed by Sue Cooper, [email protected])


  • Living Address announced Living Doc.NET, a software solution that automates the documentation process while supporting and showing dependencies within Microsoft .NET, Active Server Pages (ASP), and SQL projects. You simply tell Living Doc.NET the project you want to scan; Living Doc.NET then runs the scans in the background so that you can do other work. The software lets you compare scans to see what changes have been made since the last scan. Supports Visual C# .NET and Visual Basic .NET. Introductory pricing is $2000 for a 3-user license. Contact Living Address at 571-332-6058 or [email protected].

    Here's how to reach us with your comments and questions:

    Hide comments


    • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

    Plain text

    • No HTML tags allowed.
    • Web page addresses and e-mail addresses turn into links automatically.
    • Lines and paragraphs break automatically.