<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Channel 9</title>
    <atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Niners/c4f.Matt-Harrington/Posts/RSS"></atom:link>
    <itunes:summary></itunes:summary>
    <itunes:author>Microsoft</itunes:author>
    <itunes:subtitle></itunes:subtitle>
    <image>
      <url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url>
      <title>Channel 9</title>
      <link>http://channel9.msdn.com/Niners/c4f.Matt-Harrington/Posts</link>
    </image>
    <itunes:image href=""></itunes:image>
    <itunes:category text="Technology"></itunes:category>
    <description>Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.</description>
    <link>http://channel9.msdn.com/Niners/c4f.Matt-Harrington/Posts</link>
    <language>en</language>
    <pubDate>Wed, 19 Jun 2013 18:25:39 GMT</pubDate>
    <lastBuildDate>Wed, 19 Jun 2013 18:25:39 GMT</lastBuildDate>
    <generator>Rev9</generator>
    <c9:totalResults>1</c9:totalResults>
    <c9:pageCount>1</c9:pageCount>
    <c9:pageSize>25</c9:pageSize>
  <item>
      <title>Giving Computers a Voice</title>
      <description><![CDATA[<span id="c4fmetadata">
<table class="" cellspacing="0" cellpadding="1" width="100%" border="0">
<tbody>
<tr class="entry_overview">
<td class="" width="50">&nbsp;</td>
<td class=""><span class="entry_description">This article demonstrates how easy it is to enable managed applications to finally talk back using Microsoft's Speech API (SAPI).</span></td>
</tr>
<tr>
<td class="" colspan="2">
<div class="entry_author">Matt Harrington</div>
<div class="entry_company"><a href="http://blogs.msdn.com/controlpanel/blogs/"></a></div>
<br>
<div class="entry_details"><b>Difficulty: </b><span class="entry_details_input">Easy</span></div>
<div class="entry_details"><b>Time Required:</b> <span class="entry_details_input">
1-3 hours</span></div>
<div class="entry_details"><b>Cost: </b><span class="entry_details_input">Free</span></div>
<div class="entry_details"><b>Software: </b><span class="entry_details_input"><a href="http://msdn.com/express/">Visual Studio Express Editions</a></span></div>
<div class="entry_details"><b>Hardware: </b><span class="entry_details_input"></span></div>
<div class="entry_details"><b>Download: </b>
<ul>
<li><a href="http://ecn.channel9.msdn.com/o9/c4fcontent/migration/909044/TTSHelloWorld-CSharp.msi">C# Download</a>
</li><li><a href="http://ecn.channel9.msdn.com/o9/c4fcontent/migration/909044/TTSHelloWorld-Visual_20Basic.msi">VB Download</a></li></ul>
</div>
</td>
</tr>
</tbody>
</table>
</span>
<p>&nbsp;</p>
<h4>Summary</h4>
<p>Most of us talk to our computers all the time. You wouldn't believe the things my wife says to her poor machine when something goes wrong. This article demonstrates how easy it is to enable managed applications to finally talk back using Microsoft's Speech
 API (SAPI). But don't worry: since you control what the application says, you can ensure it uses nicer language than my wife.
</p>
<h4>SAPI</h4>
<p>SAPI is the speech API that gives applications access to speech recognition and text-to-speech (TTS) engines. This article focuses on TTS. For TTS, SAPI takes text as input and uses the TTS engine to output that text as spoken audio. This is the same technology
 used by the Windows accessibility tool, Narrator. Every version of Windows since XP has shipped with SAPI and an English TTS engine.
</p>
<p>TTS puts user's ears to work. It allows applications to send information to the user without requiring the user's eyes or hands. This is a very powerful output option that isn't often utilized on PCs.
</p>
<p>Three steps are needed to use TTS in a managed application: </p>
<ol>
<li>Create an interop DLL
<p>Since SAPI is a COM component, an interop DLL is needed to use it from a managed app. To create this, open the project in Visual Studio. Select the Project menu and click Add Reference. Select the COM tab, select &quot;Microsoft Speech Object Library&quot; in the
 list, and click OK. These steps add this reference to your project and create an Interop.SpeechLib.dll in the same folder as your executable. This interop DLL must always be in the same folder as your .exe to work correctly.
</p>
</li><li>Reference the interop namespace
<p>Include this namespace in your application. In C#, add &quot;<code>using SpeechLib;</code>&quot;; iIn VB, add “Imports SpeechLib”.
</p>
</li><li>call <code>Speak()</code>
<p>Create a <b>SpVoice</b> object and call <code>Speak()</code>: </p>
<p><b>Visual C#</b> </p>
<pre class="csharpcode">SpVoice voice = <span class="kwrd">new</span> SpVoice();<br>voice.Speak(<span class="str">&quot;Hello World!&quot;</span>, SpeechVoiceSpeakFlags.SVSFDefault);</pre>
<style type="text/css">
<!--
.csharpcode, .csharpcode 
	{font-size:small;
	color:black;
	font-family:consolas,"Courier New",courier,monospace;
	background-color:#ffffff}
.csharpcode 
	{margin:0em}
.csharpcode .rem
	{color:#008000}
.csharpcode .kwrd
	{color:#0000ff}
.csharpcode .str
	{color:#006080}
.csharpcode .op
	{color:#0000c0}
.csharpcode .preproc
	{color:#cc6633}
.csharpcode .asp
	{background-color:#ffff00}
.csharpcode .html
	{color:#800000}
.csharpcode .attr
	{color:#ff0000}
.csharpcode .alt
	{background-color:#f4f4f4;
	width:100%;
	margin:0em}
.csharpcode .lnum
	{color:#606060}
-->
</style>
<p><b>Visual Basic</b> </p>
<pre class="csharpcode">voice = <span class="kwrd">New</span> SpVoice<br>voice.Speak(<span class="str">&quot;Hello World!&quot;</span>, SpeechVoiceSpeakFlags.SVSFDefault)</pre>
<style type="text/css">
<!--
.csharpcode, .csharpcode 
	{font-size:small;
	color:black;
	font-family:consolas,"Courier New",courier,monospace;
	background-color:#ffffff}
.csharpcode 
	{margin:0em}
.csharpcode .rem
	{color:#008000}
.csharpcode .kwrd
	{color:#0000ff}
.csharpcode .str
	{color:#006080}
.csharpcode .op
	{color:#0000c0}
.csharpcode .preproc
	{color:#cc6633}
.csharpcode .asp
	{background-color:#ffff00}
.csharpcode .html
	{color:#800000}
.csharpcode .attr
	{color:#ff0000}
.csharpcode .alt
	{background-color:#f4f4f4;
	width:100%;
	margin:0em}
.csharpcode .lnum
	{color:#606060}
-->
</style></li></ol>
<p>That's it! The downloads for this article are simple C# and VB.NET &quot;hello world&quot; samples to try out.
</p>
<h4>Another Example</h4>
<p>One of the best uses of TTS is for audio notifications. The <a href="http://msdn.microsoft.com/coding4fun/coolapplications/sysmonitor/default.aspx">
System Monitor</a> sample on coding4fun is a perfect candidate to be TTS-enabled. It informs a user when a particular system event has occurred through a message box, system tray balloon tip, or email. I'll use its extensible notification infrastructure to
 add TTS to this list. </p>
<p>First, create an interop DLL and add a reference to the namespace using the steps above.
</p>
<p>Second, add this file to the <b>SystemMonitor</b> project: </p>
<p>SpeechNotifier.cs: </p>
<p><b>Visual C#</b> </p>
<pre class="csharpcode"><span class="kwrd">using</span> System;<br><span class="kwrd">using</span> SpeechLib;<br><span class="kwrd">namespace</span> SystemMonitor.Notifiers<br>{<br>    <span class="kwrd">class</span> SpeechNotifier : NotifierBase<br>    {<br>        <span class="kwrd">public</span> SpeechNotifier()<br>        {<br>            _voice = <span class="kwrd">new</span> SpVoice();<br>        }<br><br>        <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> Execute(<span class="kwrd">string</span> title, <span class="kwrd">string</span> message)<br>        {<br>            <span class="kwrd">string</span> text = <span class="str">&quot;System monitor warning! &quot;</span> &#43; title;<br>            _voice.Speak(text, SpeechVoiceSpeakFlags.SVSFDefault);<br>        }<br><br>        <span class="kwrd">private</span> SpVoice _voice;<br>    }<br>}</pre>
<style type="text/css">
<!--
.csharpcode, .csharpcode 
	{font-size:small;
	color:black;
	font-family:consolas,"Courier New",courier,monospace;
	background-color:#ffffff}
.csharpcode 
	{margin:0em}
.csharpcode .rem
	{color:#008000}
.csharpcode .kwrd
	{color:#0000ff}
.csharpcode .str
	{color:#006080}
.csharpcode .op
	{color:#0000c0}
.csharpcode .preproc
	{color:#cc6633}
.csharpcode .asp
	{background-color:#ffff00}
.csharpcode .html
	{color:#800000}
.csharpcode .attr
	{color:#ff0000}
.csharpcode .alt
	{background-color:#f4f4f4;
	width:100%;
	margin:0em}
.csharpcode .lnum
	{color:#606060}
-->
</style>
<p>SpeechNotifier.vb: </p>
<p><b>Visual Basic</b> </p>
<pre class="csharpcode"><span class="kwrd">imports</span> System<br><span class="kwrd">imports</span> SpeechLib<br><br><span class="kwrd">Namespace</span> SystemMonitor.Notifiers<br><br>    <span class="kwrd">Class</span> SpeechNotifier <span class="kwrd">Inherits</span> NotifierBase<br><br>        <span class="kwrd">Public</span> <span class="kwrd">Sub</span> <span class="kwrd">New</span>()<br>            _voice = <span class="kwrd">new</span> SpVoice<br>        <span class="kwrd">End</span> <span class="kwrd">Sub</span>

        <span class="kwrd">Public</span> <span class="kwrd">Overrides</span> <span class="kwrd">Sub</span> Execute(title <span class="kwrd">As</span> <span class="kwrd">String</span>, message <span class="kwrd">As</span> <span class="kwrd">String</span>)<br><br>            <span class="kwrd">String</span> text = <span class="str">&quot;System monitor warning! &quot;</span> &#43; title;<br>            _voice.Speak(text, SpeechVoiceSpeakFlags.SVSFDefault);<br>        <span class="kwrd">End</span> <span class="kwrd">Sub</span>

        <span class="kwrd">Private</span> SpVoice _voice<br>        <span class="kwrd">End</span> <span class="kwrd">Sub</span>
    <span class="kwrd">End</span> <span class="kwrd">Class</span>
<span class="kwrd">End</span> <span class="kwrd">Namespace</span>
</pre>
<style type="text/css">
<!--
.csharpcode, .csharpcode 
	{font-size:small;
	color:black;
	font-family:consolas,"Courier New",courier,monospace;
	background-color:#ffffff}
.csharpcode 
	{margin:0em}
.csharpcode .rem
	{color:#008000}
.csharpcode .kwrd
	{color:#0000ff}
.csharpcode .str
	{color:#006080}
.csharpcode .op
	{color:#0000c0}
.csharpcode .preproc
	{color:#cc6633}
.csharpcode .asp
	{background-color:#ffff00}
.csharpcode .html
	{color:#800000}
.csharpcode .attr
	{color:#ff0000}
.csharpcode .alt
	{background-color:#f4f4f4;
	width:100%;
	margin:0em}
.csharpcode .lnum
	{color:#606060}
-->
</style>
<p>Third, add this line in the App.config file to any monitors you want to be spoken:</p>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">notifier</span> <span class="attr">type</span><span class="kwrd">=&quot;SystemMonitor.Notifiers.SpeechNotifier,SystemMonitor&quot;</span> <span class="kwrd">/&gt;</span></pre>
<p>&nbsp;</p>
<p>For example:</p>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">monitor</span> <span class="attr">runFrequency</span><span class="kwrd">=&quot;00:04&quot;</span> <span class="attr">type</span><span class="kwrd">=&quot;SystemMonitor.Monitors.DiskSpaceMonitor,SystemMonitor&quot;</span><span class="kwrd">&gt;</span><br>    <span class="kwrd">&lt;</span><span class="html">settings</span><span class="kwrd">&gt;</span><br>        <span class="kwrd">&lt;</span><span class="html">setting</span> <span class="attr">name</span><span class="kwrd">=&quot;driveLetter&quot;</span> <span class="attr">value</span><span class="kwrd">=&quot;C&quot;</span> <span class="kwrd">/&gt;</span><br>        <span class="kwrd">&lt;</span><span class="html">setting</span> <span class="attr">name</span><span class="kwrd">=&quot;freeMegabytes&quot;</span> <span class="attr">value</span><span class="kwrd">=&quot;10000&quot;</span> <span class="kwrd">/&gt;</span><br>    <span class="kwrd">&lt;/</span><span class="html">settings</span><span class="kwrd">&gt;</span><br>    <span class="kwrd">&lt;</span><span class="html">notifiers</span><span class="kwrd">&gt;</span><br>        <span class="kwrd">&lt;</span><span class="html">notifier</span> <span class="attr">type</span><span class="kwrd">=&quot;SystemMonitor.Notifiers.SpeechNotifier,SystemMonitor&quot;</span> <span class="kwrd">/&gt;</span><br>    <span class="kwrd">&lt;/</span><span class="html">notifiers</span><span class="kwrd">&gt;</span><br><span class="kwrd">&lt;/</span><span class="html">monitor</span><span class="kwrd">&gt;</span></pre>
<p>&nbsp;</p>
<p>This example will say &quot;System monitor warning! Disk space low.&quot; when the space on c:\ drops below the specified value.
</p>
<h4>General TTS Tips</h4>
<ul>
<li><b>Keep it short.</b> The voice used by the default XP TTS engine is not exactly soothing. Most users would not want to hear it speak long texts, but it often works well for conveying short, functional pieces of information.
</li><li><b>Have a preface.</b> Many TTS apps are designed to be run in the background and speak audio when the user is focused on a different application. In this case it's helpful to let the user know the context. It wouldn't make sense if your computer randomly
 said &quot;Bill Gates,&quot; but you would know what &quot;New mail from Bill Gates&quot; meant. </li><li><b>Keep it &quot;speakable.&quot;</b> Test out the text your app intends to say. The default TTS engine has some limitations you can avoid. For example, &quot;c:\&quot; would be pronounced &quot;see colon backslash&quot;. This can be avoided by speaking just &quot;c&quot; instead.
</li><li><b>Change defaults.</b> The speech control panel allows the user to select the default TTS engine (for computers with more than one installed) and set the default speaking rate.
</li></ul>
<p><b>Cool project ideas</b> </p>
<p>The TTS functionality on PCs is an under-used resource with much promise. Here are some more project ideas:
</p>
<ul>
<li><a href="http://www.gotdotnet.com/">GotDotNet</a> has the source code of a few email and RSS readers. Reading the title of a message as it arrives in the background would be a great use of TTS.
</li><li>The System Monitor sample above just scratches the surface of event notifications. That application could be the foundation for monitoring any kind of system resource or application event. And with TTS you can let your ears do the work while your hands
 and eyes are busy. </li><li>The <a href="http://msdn.microsoft.com/coding4fun/someassemblyrequired/hotinhere/default.aspx">
It's Hot in Here</a> coding4fun sample uses a web service to read weather forecasts. Don't bother checking a web page for the weather; just modify this app to read it with a hotkey while your eyes do more important things. TTS is great for any similar web service
 update application: news headlines, stock quotes, sports scores, auction prices, and more.
</li><li>Perhaps more importantly, that same article also introduces us to Phidgets. Upstage the guy next door by sending your Phidget battlebot into the fray with a TTS &quot;You killed my father, prepare to die!&quot;.
</li></ul>
<p><b>What's next?</b> </p>
<p>This article outlines how you can use TTS on PCs today. But the <b>real</b> story is what's coming up.
</p>
<p>WinFX will contain the fully managed API for speech. No more ugly COM interop. Developers will get all the benefits of a managed API and full intellisense support.
</p>
<p>The default TTS engine on Windows Vista (formerly Windows code name &quot;Longhorn&quot;) is much better than the default XP engine. Check out some of the resources below for updates as Windows Vista gets closer to shipping.
</p>
<p><b>Resources</b> </p>
<p>Here's some blogs from members of the Speech Components Group at Microsoft: </p>
<ul>
<li><a href="http://blogs.msdn.com/robertbrown">http://blogs.msdn.com/robertbrown</a>
</li><li><a href="http://blogs.msdn.com/texttospeech">http://blogs.msdn.com/texttospeech</a>
</li><li><a href="http://blogs.msdn.com/sprague">http://blogs.msdn.com/sprague</a> </li><li>Robert Brown, the Program Manager for the managed speech API describes speech technology in this
<a href="http://channel9.msdn.com/ShowPost.aspx?PostID=72163">Channel9 video</a>.
</li><li>The <a href="http://msdn.microsoft.com/library/en-us/SAPI51sr/html/Welcome.asp">
SAPI documentation</a> on MSDN contains the full SAPI documentation, including advanced TTS features. For instance, the System Monitor sample above uses basic synchronous TTS. That reduces the responsiveness of the UI while the speaking is occurring. Professional
 applications should use asynchronous TTS, which is described in the docs. </li><li>microsoft.public.speech_tech and microsoft.public.speech_tech.sdk are news groups available to help answer any SAPI questions.
</li><li>The default OS TTS engine is not the only one SAPI can use. Search for &quot;SAPI compliant TTS engine&quot; on
<a href="http://search.msn.com/">http://search.msn.com/</a>. Or, check out a sample list of compliant engines at
<a href="http://www.microsoft.com/speech/evaluation/thirdparty/engines.asp">http://www.microsoft.com/speech/evaluation/thirdparty/engines.asp</a> that we've compiled.</li></ul>
 <img src="http://m.webtrends.com/dcs1wotjh10000w0irc493s0e_6x1g/njs.gif?dcssip=channel9.msdn.com&dcsuri=http://channel9.msdn.com/Niners/c4f.Matt-Harrington/Posts/RSS&WT.dl=0&WT.entryid=Entry:RSSView:f00a467b6951436ba7309e7600dbd805">]]></description>
      <comments>http://channel9.msdn.com/coding4fun/articles/Giving-Computers-a-Voice</comments>
      <itunes:summary>



&amp;nbsp;
This article demonstrates how easy it is to enable managed applications to finally talk back using Microsoft&#39;s Speech API (SAPI).



Matt Harrington


Difficulty: Easy
Time Required: 
1-3 hours
Cost: Free
Software: Visual Studio Express Editions
Hardware: 
Download: 

C# Download
VB Download






&amp;nbsp; 
Summary
Most of us talk to our computers all the time. You wouldn&#39;t believe the things my wife says to her poor machine when something goes wrong. This article demonstrates how easy it is to enable managed applications to finally talk back using Microsoft&#39;s Speech
 API (SAPI). But don&#39;t worry: since you control what the application says, you can ensure it uses nicer language than my wife.
 
SAPI
SAPI is the speech API that gives applications access to speech recognition and text-to-speech (TTS) engines. This article focuses on TTS. For TTS, SAPI takes text as input and uses the TTS engine to output that text as spoken audio. This is the same technology
 used by the Windows accessibility tool, Narrator. Every version of Windows since XP has shipped with SAPI and an English TTS engine.
 
TTS puts user&#39;s ears to work. It allows applications to send information to the user without requiring the user&#39;s eyes or hands. This is a very powerful output option that isn&#39;t often utilized on PCs.
 
Three steps are needed to use TTS in a managed application:  

Create an interop DLL
Since SAPI is a COM component, an interop DLL is needed to use it from a managed app. To create this, open the project in Visual Studio. Select the Project menu and click Add Reference. Select the COM tab, select &amp;quot;Microsoft Speech Object Library&amp;quot; in the
 list, and click OK. These steps add this reference to your project and create an Interop.SpeechLib.dll in the same folder as your executable. This interop DLL must always be in the same folder as your .exe to work correctly.
 
Reference the interop namespace
Include this namespace in your application. In C#, add &amp;quot;using Speech</itunes:summary>
      <link>http://channel9.msdn.com/coding4fun/articles/Giving-Computers-a-Voice</link>
      <pubDate>Tue, 31 Oct 2006 10:20:00 GMT</pubDate>
      <guid isPermaLink="false">http://channel9.msdn.com/coding4fun/articles/Giving-Computers-a-Voice</guid>      
      <dc:creator>Matt Harrington</dc:creator>
      <itunes:author>Matt Harrington</itunes:author>
      <slash:comments>29</slash:comments>
      <wfw:commentRss>http://channel9.msdn.com/coding4fun/articles/Giving-Computers-a-Voice/RSS</wfw:commentRss>
      <category>Media</category>
      <category>Windows</category>
    </item>    
</channel>
</rss>