Browse DevX
Sign up for e-mail newsletters from DevX


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

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.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

here are thousands of ways of applying speech recognition technology to business applications. If you're not already using some form of speech recognition in your organization, you've probably thought of several ways in which you'd like to use it one day. The .NET Speech SDK from Microsoft gives you some new options for making applications that respond to voice commands from end users. In this article, we'll take you step-by-step through the process of using this SDK to build a demo application to buy and sell stocks and perform other related financial transactions using voice. The application we'll build in this article will be for a fictional financial services company called "Fitch and Mather" and the application itself will be called "FMStocks Voice." It is a voice-only version of the traditional (non-voice) Web application that Fitch and Mather already uses to let its customers buy and sell stocks online. The voice and Web versions share business and data layers. You can find more information on the Fitch and Mather Web application, including downloads and documentation, here.

While our goals are to shed light on the process of building voice-only applications in general, we'll discuss lessons learned from the testing, design, and development stages, as well as thoughts about the differences between building visual applications for the Web and speech applications for telephony. Specifically, we'll show how to create a voice-only service from an existing Web application. FMStocks Voice leverages the existing business- and data-layers of the Fitch and Mather sample it is based on, with only minor modifications. To this end, the Web-based version is included with this sample to illustrate how the two presentation-layers work together simultaneously on the same data. It is possible to place a trade in the voice-only application and see the account change immediately reflected in the Web version. And we'll demonstrate best-practice programming and design techniques for using the Speech SDK. FMStocks Voice will deliver these functions:

  • Buying a Stock.
  • Selling a Stock from the user's portfolio.
  • Getting current stock quotes.
  • Browsing stocks.
  • Viewing current portfolio.
  • Account login security using Windows Authentication.
  • Leveraging pre-existing business-layer and data-layer code.
Code Reuse
In essence, a voice-only version of an existing application is in fact a new presentation layer. The user interface is now auditory rather than graphical. This means that the business logic and the data layer should essentially remain unchanged. With a few exceptions, we have followed this concept as a development guideline. In the sample VS.NET solution, note that the FMStocksVoice project file includes a reference to the Components folder in FMStocksWeb (the included Web-based version, see Figure 1). Because the two applications share this same code, trades that occur in one interface are immediately reflected in the other.

Figure 1: The FMStocksVoice project file includes a reference to the Components folder.
This will come in very handy in cases where we want to extend the functionality of both applications while writing the voice version. For example, in the current FMStocksVoice implementation the user must already have an account in order to use the voice-only application. It would be useful (though it is not covered in this article) to extend the FMStocksVoice application to allow the user to create an account. The challenge is handling the entry of the user's personal information (i.e. name, username, password, PIN, etc.). One solution would be to limit the amount of information required to set up an account.

Comment and Contribute






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



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