Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Buy and Sell Stocks with the Sound of Your Voice Using the .NET Speech SDK : Page 9

Some applications are even more useful when people can interact with them using nothing but a telephone. We used the .NET Speech SDK to voice-enable the existing FMStocks sample application—and learned some useful lessons along the way.


advertisement
Step 2—Parse user input: Client Normalization Function
After the grammar is matched and the SML document is returned, we'll next want to have our server-side code retrieve a list of companies from the database that matches these criteria. However, we'll need to run a different business logic function based on which type of information we have: company or ticker. We need a way to pass some information to our code telling it which SML element was matched.

When we set up the CompanyOrTickerQA, we specified that the value of the answer that was matched should be stored in the siTicker semantic item (see Figure 6). It will recognize that as a match only if the SML element returned is satisfied by the expression in the XPath Trigger column. So in our example, the XPath Trigger string "/SML/Ticker | /SML/Company" signifies that a match has been satisfied if either the SML element "Ticker" has been returned, or the SML element "Company" has been returned.

Figure 6: The CompanyOrTickerQA Property Pages
In the Answers tab, we also have a field for "Client Normalization Function." This holds the name of a client-side script function that we want to run when the SML is recognized, before siTicker is filled. This allows us to query the value returned by the grammar match and manipulate it, and fill in the semantic item with the updated value.

In our case, we use the JScript function "SetResponseType" as our Client Normalization Function for the CompanyOrTickerQA control.

function SetResponseType(smlNode, semanticItem) { semanticItem.attributes["ResponseType"] = smlNode.nodeName; }

Here we set an attribute of the semantic item siTicker, called "ResponseType," to the node name of the SML returned—which will be either "Company" or "Ticker."



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date