Make your windows XP talk!  by SCRIPTmaster
IMG.jpg
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

Next

 
Remove these adsRemove these ads by Signing Up

Step 1: The first step...

IMG.jpg
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
mc_dude says: Feb 16, 2010. 5:56 PM

delete the XXXXX and add your name to make it look legit!
--------------------------------------------------------
 

msgbox ("Made by XXXXX!")

do

set wshshell=wscript.createobject ("wscript.shell")

strInput = InputBox("Type Bellow, To Hear It Spoken!", "text to talk")

If strInput = False Then
WScript.quit
Else
If Len(StrInput) = 0 Then
WScript.Echo "You did not enter anything. Try again"
Else

Dim userInput
Set Sapi = Wscript.CreateObject("SAPI.SpVoice")
Sapi.speak strInput

End If
End If

loop
-------------------------------
save it AS     talkit.vbs

mc_dude says: Feb 16, 2010. 5:59 PM

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    =)

will421 says: Apr 15, 2011. 11:38 AM
I've been licking okay, but nothing happened!
Is there something wrong with my monitor?
Do you have to have a proprietary tongue?
Do I have to upgrade to Windows 7?
will421 says: Oct 28, 2011. 7:32 PM
Okay, I have upgraded to Windows 7, but it still doesn't work.
Can some one help me? I must know where I fix this problem where licking okay doesn't do anything!
will421 says: Sep 6, 2011. 5:39 PM
I'm using this in a spelling test program for my teacher.
:D
Super_Nerd says: Aug 2, 2011. 8:00 AM
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
davidprosser says: Aug 7, 2009. 2:36 PM
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:

Dim userInput

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

Sapi.speak "Whatever you want to say"
davidprosser says: Aug 7, 2009. 2:41 PM
In fact I've improved on it - It will now delete itself once it has said the message - try out this code:

Dim userInput

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

Sapi.speak "Boo! I bet I really freaked you out! But don't worry, it's

about time a computer like myself could speak! Goodbye!"

Dim objFSO
'Create a File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Delete the currently executing script
objFSO.DeleteFile WScript.ScriptFullName
Set objFSO = Nothing
Super_Nerd says: Aug 2, 2011. 7:58 AM
You don't need the userinput variable.
Super_Nerd says: Feb 15, 2011. 1:04 PM
I made this at school and turned my volume up and made it say...

Mamby Pamby Land tastes like cheese oh my I forgot to get brocolli for the cheese.

TTS.png
Super_Nerd says: Feb 2, 2011. 5:32 PM
Hey, I put this into a program that reads the time. Try this link.
will421 says: Dec 6, 2010. 3:36 PM
I made a nice little script out of this one:
Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set Sapi = Wscript.CreateObject("SAPI.SpVoice")
WScript.Sleep(1000)
Sapi.speak "Hello."
WScript.Sleep(500)
Sapi.speak "My name is Sapi."
WScript.Sleep(700)
Sapi.speak "How are you?"
WScript.Sleep(1000)
Sapi.speak "I'm good too."
WScript.Sleep(400)
Sapi.speak "Have a nice day!"
WScript.Sleep(400)
Sapi.speak "Oh, and by the way, this script was made by will 421 also known as DabatchSquad, Dabatch, and will 4210"
WScript.Sleep(500)
Sapi.speak "I will write down the usernames for you in notepad. Here..."
WScript.Sleep(400)
WshShell.run "notepad"
WshShell.appActivate "Notepad"
WScript.Sleep(500)
WshShell.SendKeys "will421"
WScript.Sleep(500)
WshShell.SendKeys "{ENTER}DabatchSquad"
WScript.Sleep(500)
WshShell.SendKeys "{ENTER}Dabatch"
WScript.Sleep(500)
WshShell.SendKeys "{ENTER}will4210"
Sapi.speak "There. Goodbye!"
DTass says: Jan 31, 2009. 4:54 PM
Do I Write the stuff in parenthesis
GeekBeam says: Feb 10, 2010. 6:32 PM
yes
fatboy106 says: Mar 20, 2009. 12:15 PM
mine just comes up: windows script host line:4 char:1 error:expected statement code:800a0400
GeekBeam says: Feb 10, 2010. 6:32 PM
are you doing it on one line if so use the way he said up there except don't include the space in between
sushantparab says: Oct 1, 2009. 1:53 AM
great
firesketch says: Sep 6, 2009. 3:28 PM
Fantastic images, well done. I need to work on my illustration :/
alexman695 says: Jul 6, 2009. 2:49 AM
cool
L0rd0fferret says: Jun 15, 2009. 7:54 PM
how do you change to othervoice i have all three
cheesefetty says: May 31, 2009. 6:58 PM
you can also go to control panel, then go to speech then VIOLA!!
hg341 says: Apr 25, 2009. 8:44 PM
nice i now know a bit of .vbs
slu6alka says: Mar 12, 2009. 8:48 AM
Ha this is awesome:) Do you know how to make it speak in other language?
Bert99 says: Feb 24, 2009. 4:10 PM
I showed it to a bunch of teachers at my school and they loved it!
knoxarama says: Jan 31, 2009. 9:56 AM
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.
knoxarama says: Jan 31, 2009. 9:24 AM
this is weird! and it works!
ReCreate says: Jan 26, 2009. 10:26 AM
"self destruct sequence initiated"...funny that part made me laugh
kttecatt says: Jan 9, 2009. 6:53 PM
I know this will probably sound like a stupid question, but, I am not very computer savvy. When you say, " just double click on the script file and the program will run were you will enter yousentence and the pc will read it!", what exactly does that mean? What is a script file? Thanks, =.=
SCRIPTmaster (author) says: Jan 10, 2009. 3:16 AM
@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 ;)
blugyblug says: Nov 24, 2008. 12:14 AM
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.
wenpherd says: Nov 23, 2008. 2:30 PM
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
SCRIPTmaster (author) says: Nov 23, 2008. 11:15 PM
hmm... i will try to do that for the next instructable maybe... ;)
wenpherd says: Nov 23, 2008. 2:23 PM
this remind me of wargames it cool movie
stephen2803 says: Nov 18, 2008. 1:04 PM
lol, this is realy good!thank you, do some more!
QwertyuioLP says: Nov 12, 2008. 12:06 AM
I've got a new code for this:

Dim userInput

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

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

Sapi.speak userInput
x=msgbox("Message here!!",vbBeep,"title here")

hope you like
TATcreator says: Nov 13, 2008. 1:59 PM
How is it supposed to work? We don't specialize in vbscripting, only batch.
QwertyuioLP says: Nov 17, 2008. 12:11 AM
All it does is speaks and then a pop up, pops up(bet u don't see that every day!)
SCRIPTmaster (author) says: Nov 14, 2008. 3:58 AM
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! ;)
will421 says: Sep 6, 2011. 5:42 PM
will421 says: Dec 6, 2010. 3:21 PM
Can you do stuff in a console that looks like its from wargames in VBS?
No.
Can you do stuff in a console that looks like its from wargames in Batch?
Yes.
munchman says: Nov 14, 2008. 12:28 AM
umm, that is vbscript
will421 says: Dec 6, 2010. 3:19 PM
Exactly.
lolcat360 says: Aug 17, 2008. 3:59 PM
it doesnt work :(
Knuten says: Aug 9, 2008. 5:58 AM
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!!!
SCRIPTmaster (author) says: Aug 11, 2008. 7:49 AM
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!
jelly829 says: Jul 26, 2008. 4:35 PM
Can someone make one that automatically speaks the thing i type in notepad when i click on the vbs? thanks
place name here- says: Aug 9, 2008. 9:36 PM
change this

Dim userInput

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

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

Sapi.speak userInput

to this

Dim userInput

userInput = ("self distruct seqwence of hard drive initiated")

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

Sapi.speak userinput
SCRIPTmaster (author) says: Aug 11, 2008. 7:45 AM
lol
jelly829 says: Aug 10, 2008. 1:16 AM
awesome =]
SCRIPTmaster (author) says: Aug 11, 2008. 7:45 AM
thanks
SCRIPTmaster (author) says: Jul 27, 2008. 12:01 AM
nice idea, i will try making one...
jelly829 says: Jul 27, 2008. 1:17 AM
thanks =]

hope you finish it asap so i can use it at school x]
littlegandhi1199 says: Jul 22, 2008. 6:28 PM
i am having a bucket of fun!
SCRIPTmaster (author) says: Jul 22, 2008. 10:25 PM
well thats the a main thing behind writing this script although it could be used for many more useful purposes.Also You can show it to some friends and many of them would be amazed ;)
SCRIPTmaster (author) says: Jul 20, 2008. 4:52 AM
hey thanks, i will take your comment into consideration, and expect cooler scripts in the future ;)
xACIDITYx says: Jul 22, 2008. 7:09 AM
You know that there is a Reply button at the bottom of his comment, so if you hit that he will be notified of your reply.
SCRIPTmaster (author) says: Jul 22, 2008. 8:31 AM
ah ok thx for the info! i am new here...
xACIDITYx says: Jul 22, 2008. 9:57 AM
No Problem
plane phanatic says: Jul 20, 2008. 4:00 AM
Great job! This could use a few more photos, but it is still excellent! I look forward to trying this on my computer. 5/5 stars
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!