This instructable shows you how to write a simple vb script that allows you to use the microsoft SAPI
(Speech application Programming Interface).

quick version history of the SAPI in windows:
SAPI 1.0 - 1995
SAPI 2.0 - 1996
SAPI 3.0 - 1997
SAPI 4.0 - 1998
SAPI 5.0 - 2000
SAPI 5.1 - 2001
SAPI 5.2 - 2004
SAPI 5.3 - With Windows Vista

Windows XP and Windows Server 2003 come with Microsoft Sam but you can also download Microsoft Mary and Microsoft Mike. To find which ones you have installed you can run this Vbs script:

Set objVoice = CreateObject("SAPI.SpVoice")

For Each strVoice in objVoice.GetVoices

Wscript.Echo strVoice.GetDescription


Step 1: The First Step...

Open up notepad, and write the following vbscript in it:

Dim userInput

userInput = InputBox("Type below anything to hear you PC speak it!")

Set Sapi = Wscript.CreateObject("SAPI.SpVoice")

Sapi.speak userInput

==> the second line allows the showing of the input box in which the user will enter his sentence that is to be read by the pc
==> the first line declares the variable userInput
==> the third line declares the SAPI and creates its object
==> and the last line tells the SAPI what to readwhich is in this case the variable userInput

Step 2: Save You Work...

now after entering the script you have to save it in the form of vbs file
click save and write in the place were you name you file:

the name that you want.vbs

*remark: i mean by "the name that you want" the naming that you are free to put for your file

after you save, just double click on the script file and the program will run were you will enter yousentence and the pc will read it!

good luck
hope you like this instructable
please do make a comment, thanks ;)
<p>Here is another text and instructions. This will repeat unless you get rid of 'do' and 'loop'.</p><p>Code Below and Above Dotted Lines</p><p>-------------------------------------------------------------------------------------------------------------</p><p>Set speech=CreateObject(&quot;sapi.spvoice&quot;)</p><p>Dim speaks, speech</p><p>do</p><p>&quot;Anything here minus quotations and spaces&quot;=(&quot;What the computer says.&quot;)</p><p>speech.Speak &quot;Anything here minus quotations and spaces&quot;</p><p>loop</p><p>----------------------------------------------------------------------------------------------------------</p><p>(For hidden files (http://www.bleepingcomputer.com/tutorials/show-hidden-files-in-windows-7/) (Works for more than windows 7)</p><p>Then go to Users/Your_Username/App_Data/Roaming/Microsoft/Windows/Start_Menu/Programs/Start_Up. Then drag the program (Saved the same way in the instructable) to that folder. Whenever you start your file, the program will run.</p><p>If you have do loop, to end it, got to task manager, process, and end wscript.exe</p><p>Thank You</p>
If you get rid of the input box and put the script in the startup folder you can scare coworkers and friends pretty good. I've got a similar how-to on my site with the appropriate changes in the code to do that. <a href="http://www.infotechtnt.com/talking-computers" rel="nofollow">www.infotechtnt.com/talking-computers</a>
I know this will probably sound like a stupid question, but, I am not very computer savvy. When you say, &quot; just double click on the script file and the program will run were you will enter yousentence and the pc will read it!&quot;, what exactly does that mean? What is a script file? Thanks, =<sup>.</sup>=<br/>
@kttecatt, after you save the file youfilename.vbs in notepad, a blue and white icon will appear where you have saved the file, just double click on it to start the program :) good luck ;)
Thanks so much!
<p>delete the XXXXX and add your name to make it look legit!<br /> --------------------------------------------------------<br /> &nbsp;</p> <p>msgbox (&quot;Made by XXXXX!&quot;)</p> <p>do</p> <p>set wshshell=wscript.createobject (&quot;wscript.shell&quot;)</p> <p>strInput = InputBox(&quot;Type Bellow, To Hear It Spoken!&quot;, &quot;text to talk&quot;)</p> <p>If strInput = False Then<br /> WScript.quit<br /> Else<br /> If Len(StrInput) = 0 Then<br /> WScript.Echo &quot;You did not enter anything. Try again&quot;<br /> Else</p> <p>Dim userInput<br /> Set Sapi = Wscript.CreateObject(&quot;SAPI.SpVoice&quot;) <br /> Sapi.speak strInput</p> <p>End If<br /> End If</p> <p>loop<br /> -------------------------------<br /> save it AS&nbsp;&nbsp;&nbsp;&nbsp; talkit.vbs</p>
<p><strong>the loop is not a bad loop (by the way) if you push cancel and the x button it will close it...... and if you type nothing and lick ok it will propt you to actually type sommething than let you try again. made completly by me&nbsp;&nbsp;&nbsp;&nbsp;=)</strong></p>
I've been licking okay, but nothing happened!<br>Is there something wrong with my monitor?<br>Do you have to have a proprietary tongue?<br>Do I have to upgrade to Windows 7?<br>
Okay, I have upgraded to Windows 7, but it still doesn't work.<br>Can some one help me? I must know where I fix this problem where licking okay doesn't do anything!
I've got a new code for this:<br/><br/>Dim userInput<br/><br/>userInput = InputBox(&quot;Type below anything to hear you PC speak it!&quot;)<br/><br/>Set Sapi = Wscript.CreateObject(&quot;SAPI.SpVoice&quot;)<br/><br/>Sapi.speak userInput<br/>x=msgbox(&quot;Message here!!&quot;,vbBeep,&quot;title here&quot;)<br/><br/>hope you like<br/>
How is it supposed to work? We don't specialize in vbscripting, only batch.
what fo you mean? everything is mentioned in the tutorial! btw, batch is becomin gmore and more outdated, what you can do in batch can be done in vbscript! ;)
Also: <a href="http://lmgtfy.com/?q=Autohotkey&l=1">http://lmgtfy.com/?q=Autohotkey&amp;l=1</a>
Can you do stuff in a console that looks like its from wargames in VBS?<br>No.<br>Can you do stuff in a console that looks like its from wargames in Batch?<br>Yes.
umm, that is vbscript
All it does is speaks and then a pop up, pops up(bet u don't see that every day!)
I'm using this in a spelling test program for my teacher.<br>:D
Is there a way to make it listen from Speech recognition? The only way I've done it is make it open the SR program and create an Input box
If you want to make it speak when you click on the file, and have no box come up (like a mysterious voice) then use this code:<br/><br/>Dim userInput<br/><br/>Set Sapi = Wscript.CreateObject(&quot;SAPI.SpVoice&quot;) <br/><br/>Sapi.speak &quot;Whatever you want to say&quot;<br/>
In fact I've improved on it - It will now delete itself once it has said the message - try out this code:<br/><br/>Dim userInput<br/><br/>Set Sapi = Wscript.CreateObject(&quot;SAPI.SpVoice&quot;) <br/><br/>Sapi.speak &quot;Boo! I bet I really freaked you out! But don't worry, it's <br/><br/>about time a computer like myself could speak! Goodbye!&quot;<br/><br/> Dim objFSO<br/> 'Create a File System Object<br/> Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)<br/> 'Delete the currently executing script<br/> objFSO.DeleteFile WScript.ScriptFullName<br/> Set objFSO = Nothing<br/>
You don't need the userinput variable.
I made this at school and turned my volume up and made it say... <br> <br>Mamby Pamby Land tastes like cheese oh my I forgot to get brocolli for the cheese. <br> <br>
Hey, I put this into a program that reads the time. Try <a href="https://www.instructables.com/id/Make-a-vbs-script-to-read-the-time/">this</a> link.
I made a nice little script out of this one:<br>Set WshShell = Wscript.CreateObject(&quot;Wscript.Shell&quot;)<br>Set Sapi = Wscript.CreateObject(&quot;SAPI.SpVoice&quot;)<br>WScript.Sleep(1000)<br>Sapi.speak &quot;Hello.&quot;<br>WScript.Sleep(500)<br>Sapi.speak &quot;My name is Sapi.&quot;<br>WScript.Sleep(700)<br>Sapi.speak &quot;How are you?&quot;<br>WScript.Sleep(1000)<br>Sapi.speak &quot;I'm good too.&quot;<br>WScript.Sleep(400)<br>Sapi.speak &quot;Have a nice day!&quot;<br>WScript.Sleep(400)<br>Sapi.speak &quot;Oh, and by the way, this script was made by will 421 also known as DabatchSquad, Dabatch, and will 4210&quot;<br>WScript.Sleep(500)<br>Sapi.speak &quot;I will write down the usernames for you in notepad. Here...&quot;<br>WScript.Sleep(400)<br>WshShell.run &quot;notepad&quot;<br>WshShell.appActivate &quot;Notepad&quot;<br>WScript.Sleep(500)<br>WshShell.SendKeys &quot;will421&quot; <br>WScript.Sleep(500)<br>WshShell.SendKeys &quot;{ENTER}DabatchSquad&quot; <br>WScript.Sleep(500)<br>WshShell.SendKeys &quot;{ENTER}Dabatch&quot;<br>WScript.Sleep(500)<br>WshShell.SendKeys &quot;{ENTER}will4210&quot;<br>Sapi.speak &quot;There. Goodbye!&quot;
Do I Write the stuff in parenthesis
yes<br />
mine just comes up: windows script host line:4 char:1 error:expected statement code:800a0400
are you doing it on one line if so use the way he said up there except don't include the space in between<br />
Fantastic images, well done. I need to work on my illustration :/
how do you change to othervoice i have all three
you can also go to control panel, then go to speech then VIOLA!!
nice i now know a bit of .vbs
Ha this is awesome:) Do you know how to make it speak in other language?
I showed it to a bunch of teachers at my school and they loved it!
this works well. all you really have to do is copy/paste anyway. but i have something to add. when the box pops up, put ------------------ between all of your words. its makes the computer stop between words, otherwise it goes really fast.<br/>
this is weird! and it works!
"self destruct sequence initiated"...funny that part made me laugh
Another way is Control Panel --> (category view)--> sounds, speech and audio devices --> (normal view)-->Speech --> At the top click the tab that says "text to speech" Now select a voice, some of them sound really weird. And type inside the box and click preview.
how do you chang the voice, and can you make it so it responds when you talk to it i think you should try it
hmm... i will try to do that for the next instructable maybe... ;)
this remind me of wargames it cool movie
lol, this is realy good!thank you, do some more!
it doesnt work :(
Excellent! And I want to use it in my audio editing. I tried your first script and it said I have "Sam". I presume that's the male voice I hear. I'll also try to download the Mike & Mary voices... I presume from somewhere at Microsoft? Do you know where other voices, accents or languages can be downloaded? Thanks for the fun Instructable!!!
thanks, and good luck in your audio editing :) , the voices can be downloaded easily with their documentation from the Microsoft website, i haven't tried them but they usually work and are easy to install, once they are set as your default SAPI voice on your windows they can work with this script just as the default one provided by windows which is sam. i have even more interesting Scripts to show you in my coming instructables!
Can someone make one that automatically speaks the thing i type in notepad when i click on the vbs? thanks
change this<br/><br/>Dim userInput<br/><br/>userInput = InputBox(&quot;Type below anything to hear you PC speak it!&quot;)<br/><br/>Set Sapi = Wscript.CreateObject(&quot;SAPI.SpVoice&quot;)<br/><br/>Sapi.speak userInput<br/><br/>to this<br/><br/>Dim userInput<br/><br/>userInput = (&quot;self distruct seqwence of hard drive initiated&quot;)<br/><br/>Set Sapi = Wscript.CreateObject(&quot;SAPI.SpVoice&quot;)<br/><br/>Sapi.speak userinput<br/>

About This Instructable



More by SCRIPTmaster:Make your windows read files writen in notepad! How to automatically shutdown your windows vista computer... Program your PC to turn off automatically by asigning which time you want it to do that 
Add instructable to: