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
 

Design and Implement a Voice-only Web Application in ASP.NET : Page 6

This whitepaper demonstrates how to use the Microsoft .NET Speech SDK to build a complete e-commerce starter application. Use these detailed techniques to build your own commerce system that will have your customers browsing, shopping, and making purchases using nothing but the sounds of their voices.


advertisement
Prompt Generation (PromptGenerator.js)
Prompt Generation is perhaps the most central element when creating a successful voice-only application. Providing a consistent voice interface is essential to creating a successful user experience. PromptGenerator.js does just this by encapsulating all common prompt-generation functionality in one place.

A prompt function in a typical page will always return the result of a call PromptGenerator.Generate() as its prompt:

return PromptGenerator.Generate( lastCommandOrException, count, "Prompt Text Here", "Help Text Here" );

Notice that the prompt function passes both its main prompt and its help prompt into the function every time. PromptGenerator.Generate() decides the appropriate prompt to play given the current lastCommandOrException, the NoReco/Silence state (see the topic HandleNoRecoAndSilence), and other factors:

function PromptGenerator.Generate( lastCommandOrException, count, text, help) { help += " You can always say Instructions " + "for more options." switch (lastCommandOrException) { case "NoReco": if (PromptGenerator.noRecoOrSilenceCount > 1) return "Sorry, I still don't understand " "you. " + help; else return "Sorry, I am having trouble " + "understanding you. " + "If you need help, say help. " + text; case "Silence": if (PromptGenerator.noRecoOrSilenceCount > 1) return "Sorry, I still don't hear you. " + help; else return "Sorry, I am having trouble " + "hearing you. " + "If you need help, say help. " + text; case "Help": PromptGenerator.RepeatPrompt = help; return help; case "Instructions": var instructionsPrompt = "Okay, here are a few instructions..."; PromptGenerator.RepeatPrompt = instructionsPrompt + text; return instructionsPrompt; case "Repeat": return "I repeat: " + PromptGenerator.RepeatPrompt; default: PromptGenerator.RepeatPrompt = text; return text; } }

Author's Note: Some of the longer strings have been shortened here to save space.

A note on "Repeat": The PromptGenerator.RepeatPrompt variable stores the current text that will be read if the user says "Repeat." The first time the function is executed for any prompt, the RepeatPrompt will be set to the standard text. The RepeatPrompt is then only reset when the user says "Help" or "Instructions."

Other PromptGenerator functions: PromptGenerator also includes a number of other functions for generating prompts in the application. They include

  • GenerateNavigator(lastCommandOrException, count, text, help): This function adds to the functionality of Generate() by including standard prompts commonly needed while in a Navigator control. These prompts include additional help text and messages for when the user tries to navigate beyond the boundaries of the navigator.
  • ConvertNumberToWords(number, isMoney): In order to generate recorded prompts for all possible number values, we must convert numbers (i.e. 123,456) to a readable string (i.e. "one hundred twenty three thousand four hundred fifty six"). This reduces the number of unique words that must be recorded to a manageable amount.
  • ConvertDateToWords( dateString ): Like ConvertNumberToWords, this function converts dates to a prompt-ready format (i.e. "12/2/02" becomes "December Twelfth Two Thousand Two").


Comment and Contribute

 

 

 

 

 


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

 

 

Sitemap