If only this app could speak…
How’s that to start off my second post to the Coding4Fun blog? A folksy, friendly greeting to try to set the tone for this and future posts. Where, a couple times a week, I’ll be posting about cool coding, development and tech stuff I find around the Net. Stuff that the people who just love to code might also find interesting. Now, on to the show…
There’s something compelling about computers and the spoken word. It just seems normal to expect that we should be able to have a conversation with our computers. For me it began with 2001, A Space Odyssey and the HAL9000 (or was it Star Trek and the Enterprise’s computer?) Since then, every time I see voice control or voice output from a computer or application I find myself drawn to it.
In this article we are going to explore the Speech API library that’s part of the TTS SDK that helps you reading text and speaking it. We’re going to see how to do it programmatically using C# and VB.NET and how to make use of LINQ to make it more interesting. The last part of this article talks about…… won’t tell you more, let’s see!
The Speech API library that we are going to use today is represented by the file sapi.dll which’s located in %windir%\System32\Speech\Common. This library is not part of the .NET BCL and it’s not even a .NET library, so we’ll use Interoperability to communicate with it (don’t worry, using Visual Studio it’s just a matter of adding a reference to the application.)
This article shows how simple it really is to have your C# or VB application talking to your users. In just a couple lines of code, you can quickly add voice output. We’re not talking pre-recorded sound bites or dialogue but real Text To Speech (TTS). Then the sky is the limit. You can add tweaks to improve the pronunciation, change voices and more. Oh have I said that if you have Windows Vista/7 that this capability is just waiting for you to use it already, free?
Here’s a few more links you might find interesting:
- Wikipedia, Microsoft Speech API
- Speech Team Blog, speech @ microsoft
- MSDN Library Technology landing page, Speech Technologies
- System.Speech Namespaces in the .Net 4 Framework
Post thumbnail cutesy of Robert Simmons