<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DemiLane &#187; VB 6</title>
	<atom:link href="http://demilane.com/category/vb-6/feed/" rel="self" type="application/rss+xml" />
	<link>http://demilane.com</link>
	<description>Pages of Rogelio Calamaya</description>
	<lastBuildDate>Sun, 20 Jun 2010 19:20:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Using Microsoft Speech Object Library in VB6</title>
		<link>http://demilane.com/how-to-use-microsoft-speech-object-library/</link>
		<comments>http://demilane.com/how-to-use-microsoft-speech-object-library/#comments</comments>
		<pubDate>Fri, 27 Jun 2008 06:53:32 +0000</pubDate>
		<dc:creator>Rogelio</dc:creator>
				<category><![CDATA[VB 6]]></category>
		<category><![CDATA[basic]]></category>
		<category><![CDATA[object library]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[visual basic]]></category>

		<guid isPermaLink="false">http://lucero.demilane.com/?p=23</guid>
		<description><![CDATA[Here is a simple application in VB6 that uses Microsoft Speech Object Library, I&#8217;m bored so I&#8217;ve done some experiment and look what I&#8217;ve found. Actually, this is a part of our project in Major Elective 3, well.. umm I don&#8217;t know if this will help but anyways it&#8217;s my first step for writing my ]]></description>
			<content:encoded><![CDATA[<p>Here is a simple application in VB6 that uses Microsoft Speech Object Library, I&#8217;m bored so I&#8217;ve done some experiment and look what I&#8217;ve found. Actually, this is a part of our project in Major Elective 3, well.. umm I don&#8217;t know if this will help but anyways it&#8217;s my first step for writing my project and also for those who want to know the basic in how to use the library. So let&#8217;s begin.</p>
<p>First open a new project in VB and in the menu bar click <em>Project -&gt; References</em>. Then in that list search for Microsoft Speech Object Library and check it, then click OK. <em>[see image below] </em></p>
<p style="text-align: center;"><img class="size-full wp-image-24 aligncenter" style="margin-top: 0px; margin-bottom: 0px;" title="vbstep1" src="http://demilane.com/wp-content/uploads/2008/06/vbstep1.gif" alt="Menu bar -&gt; Project -&gt; References" width="449" height="362" /></p>
<p>Then in your form, create a TextBox control. Just drag and drop it to the form or double click the control. Then resize it, position it as you like. <em>[see image below]</em></p>
<p style="text-align: center;"><img class="size-full wp-image-25 aligncenter" style="margin-top: 0px; margin-bottom: 0px;" title="vbstep2" src="http://demilane.com/wp-content/uploads/2008/06/vbstep2.gif" alt="form -&gt; textBox" width="360" height="224" /></p>
<p>Let&#8217;s do the coding:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="asp" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">Dim</span> voice <span style="color: #330066;">As</span> <span style="color: #0000ff; font-weight: bold;">New</span> SpVoice
<span style="color: #990099; font-weight: bold;">Dim</span> toSpeech<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #330066;">As</span> <span style="color: #990099; font-weight: bold;">String</span>
&nbsp;
<span style="color: #990099; font-weight: bold;">Private</span> <span style="color: #0000ff; font-weight: bold;">Sub</span> Text1_KeyPress<span style="color: #006600; font-weight:bold;">&#40;</span>KeyAscii <span style="color: #330066;">As</span> <span style="color: #990099; font-weight: bold;">Integer</span><span style="color: #006600; font-weight:bold;">&#41;</span>
&nbsp;
<span style="color: #990099; font-weight: bold;">If</span> KeyAscii <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #800000;">32</span> <span style="color: #990099; font-weight: bold;">Then</span>
     toSpeech<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #006600; font-weight: bold;">=</span> Split<span style="color: #006600; font-weight:bold;">&#40;</span>Text1.<span style="color: #9900cc;">Text</span>, <span style="color: #cc0000;">&quot; &quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span>
     voice.<span style="color: #9900cc;">Speak</span> <span style="color: #006600; font-weight:bold;">&#40;</span>toSpeech<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #330066;">UBound</span><span style="color: #006600; font-weight:bold;">&#40;</span>toSpeech<span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span>
     <span style="color: #990099; font-weight: bold;">ElseIf</span> KeyAscii <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #800000;">13</span> <span style="color: #990099; font-weight: bold;">Then</span>
     KeyAscii <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #800000;">0</span>
<span style="color: #990099; font-weight: bold;">End</span> <span style="color: #990099; font-weight: bold;">If</span>
&nbsp;
<span style="color: #990099; font-weight: bold;">End</span> <span style="color: #0000ff; font-weight: bold;">Sub</span></pre></td></tr></table></div>

<p>Here is a brief explanation of the code. First we declare voice as new SpVoice object and toSpeech() as a dynamic array String. As you can see the array has no size, so that we can size the array while the code is running.</p>
<p>Next, in the KeyPress event of our TextBox, The KeyAscii 32 is Space key value in your keyboard and if that value is equal to the KeyAscii, the Text1.Text will split each word with &#8221; &#8220;<em>(white space)</em> delimiter. Then the voice.Speak will read the last item of the array toSpeech(). And if the KeyAscii value is equal to 13 which is Enter/Return Key, the keyAscii will set to 0 and the Enter/Return Key is disabled in your keyboard.</p>
<p>In other words, whenever the user hit Space Key the voice will read/speak the last word of the string in the Text1.txt. If the user hit Enter/Return Key, that key will disable.</p>
<p>That&#8217;s it, done. As for using the functionality of the library, I&#8217;m still experimenting.</p>
<p>Here is the file, if you want you can download it <a href="http://demilane.com/dl/textToSpeech.zip">here</a>.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://demilane.com/how-to-use-microsoft-speech-object-library/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
