As I promised earlier, I have made this instructable. This is part of a set of instructables I am making that focuses around one of the original features in my Mega_Menu V 2.4 batch program. I have one other, previously made instructable on my address book program which you can find here

This program has one major function only, making your computer "speak" whatever you write in the program. This is accomplished by creating a separate (temporary) VBs file that makes SAPI speak whatever you write. This file is deleted afterwards. 

Onto the code:

Note: I made a mistake, don't use underscores, use hyphens. I have corrected this.

Step 1:

@echo off
title Text to Speech Conversion
color 0a

rem The user decides what to convert here
echo What do you want the computer to convert into speech?
set /p text=

rem Making the temp file
set num=%random%
if exist temp%num%.vbs goto num
echo ' > "temp%num%.vbs"
echo set speech = Wscript.CreateObject("SAPI.spVoice") >> "temp%num%.vbs"
echo speech.speak "%text%" >> "temp%num%.vbs"
start temp%num%.vbs
del temp%num%.vbs
goto input

If you do not want the screen to close for no reason, I suggest you follow the tip given and don't use spaces; use hyphens (-) instead.

Step 2:

That's it. I don't know why I added this last step, but all the cool-kids are doing it nowadays. Have fun?

P.S It said I needed more photos, so I gave Instructables a cheetah.
<p>which coding language is used here. please tell me how to use this code so that it may convert text to speech</p>
Can we change the language.. I need Korean!!
<p>Do something like:</p><p>set speech = Wscript.CreateObject(&quot;SAPI.spVoice&quot;)</p><p>speech.speak &quot;Some--Text--Here&quot; </p><p>set speech = Wscript.CreateObject(&quot;SAPI.spVoice&quot;) </p><p>speech.speak &quot;Are--We--Clear&quot;</p><p>And save as .vbs</p><p>Intead of adding the lines into .bat</p><p>call the .vbs from .bat</p><p>Note:Additional Information</p><p>Voice1 starts in sequence line while Voice2 and Text2 starts at the same time by adding the start command.</p><p>@echo off</p><p>Voice1 </p><p>start Voice2</p><p>start Text1</p><p>I hope it Helps</p>
<p><a href="https://www.instructables.com/member/mediageneric." rel="nofollow">mediageneric.</a> ,</p><p>I really don't know what is your reluctance to help me .</p><p>What I really, really, really, want to know is</p><p>given this *.vbs :</p><p>set speech = Wscript.CreateObject(&quot;SAPI.spVoice&quot;)</p><p>speech.speak &quot;hello&quot;</p><p>How can I get it to 'instead' , to read &quot;hello&quot; in from a *.txt file ?</p><p>I have Googled all over the internet , stackexchange , etc.. </p><p>They are all 'how to read into a variable ' or something other than what I need .</p><p>Pls, What is the syntax for input into the 'speech.speak' command ? :</p><p>speech.speak C:\hello.txt </p><p>If you don't know , please say so .</p><p>Then I'll look else where .</p><p>Thanks</p>
<p>Hi <a href="https://www.instructables.com/member/mediageneric." rel="nofollow">mediageneric.</a> ,</p><p>How can I get your tts script to accept input from a .txt file ?</p><p>Thanks</p>
<p>Hello &amp; Thanks ,</p><p>Pls , how can I get code to speak a *.txt file ? </p><p>Thanks</p>
<p>Can I add additional text that will open a file on my computer when you run this script? For instance the script says welcome to chr kiosk and then open the program file....</p>
<p>how to create delay For Ex: if we enter &quot;23 45&quot; and it is speaking without some gap to here clearly<br>how to make it delay for word to word</p>
Awesome PP, just changed your code so that it takes multiple lines of input. Best thing is since the &quot;SAPI.spVoice&quot; pauses just after it finishes, at the end of each line there is a slight pause.<br> <br> <em>@echo off<br> title Text to Speech Conversion<br> color 0a<br> <br> rem The user decides what to convert here<br> :start<br> cls<br> echo What do you want the computer to convert into speech?<br> echo.<br> <br> rem Making the temp file<br> :num<br> set num=%random%<br> if exist temp%num%.vbs goto num<br> echo ' &gt; &quot;temp%num%.vbs&quot;<br> echo set speech = Wscript.CreateObject(&quot;SAPI.spVoice&quot;) &gt;&gt; &quot;temp%num%.vbs&quot;<br> <br> rem Taking Input<br> :input<br> set text=<br> set /p text=<br> if not &quot;%text%&quot;==&quot;&quot; (<br> echo speech.speak &quot;%text%&quot; &gt;&gt; &quot;temp%num%.vbs&quot;<br> goto :input<br> )<br> <br> start temp%num%.vbs<br> Pause Echo Speaking . . .<br> del temp%num%.vbs<br> goto start</em><br> <br> Just wondering do you know of any other auto-voicing programs installed by default in a windows computor?
Found error: 3rd Last line - <br> Pause |Echo Speaking . . .
<p>Remove &quot;|Echo Speaking . . .&quot;</p><p>I think that will work</p>
Thanks for your help, and no. There are no pre-installed auto-voicing programs on Windows that I know of, but I'm sure there's some free or open-source programs for download.
<p>This is so funny to play around with.</p>
<p>I'm trying to add this to a batch file that acts sorta like a siri for desktop, and when i put it in this script it tells me: Can not find script file &quot;C:\Users\...\Desktop\temp20004.vbs&quot; What does this mean.</p><p>*Please note that this script did work by itself in its own program.</p>
<p>Depends on how you're calling on it through the batch file. I find the best way is to use either Wscript of Cscript within batch files. The only difference between them is that Wscript makes it's own output windows and Cscript outputs it directly to the batch window.</p><p>So, where you're calling on the script, either use</p><p>cscript //Nologo &quot;C:\Users\...\Desktop\temp20004.vbs&quot;</p><p>or </p><p>wscript //Nologo &quot;C:\Users\...\Desktop\temp20004.vbs&quot;</p>
<p>thanks for this. I added voice welcoming to my program. </p><p>http://www.mediafire.com/download/1uey3fmglej5a96/Davids_Hacking_System_-_Version_0.1.6.exe</p>
<p>I love this! Thank you!</p>
Awesome...great work......Actually I m expert in java programming as well as ASP.NET/C# <br>but batch file programming is going out of my box....... <br>Perfect.....really impressive.........ur logical reasoning n knowledge...both are perfect..
This was really nice one, Can I set the different voice samples using this script
The language and accent that it speaks in is on your end of the bargain. To access what voices you can change it to, go to Control Panel/Speech Recognition/ and on the left it should say &quot;text to speech&quot;. There it should open a properties box where you can change the voice, speed and other details. To download more voices, see <a href="http://www.microsoft.com/en-us/download/details.aspx?id=10121" rel="nofollow">here</a>.
In the line <strong><em>echo speech.speak &quot;%text%&quot; &gt;&gt; &quot;temp%num%.vbs&quot; </em></strong>replace <strong><em>&quot;%text%&quot; </em></strong>with what you want it to say.
WOW dude this is beast... you should do a tutorial!
Thank you, and a tutorial of how I did it or what each line does?
Hoe you did it!
Might add it to the back of this one soon.
what is the batch command for reading from a text file called &quot;weather.txt&quot; and it is in c:/scripts/weather&quot; so the path is &quot;c:/scripts/weather/weather.txt&quot;?
There is no specific command for narrating anything with batch, but you can make one. Luckily for you, someone has thought about your predicament and made an instructable about how to make a VBscript narrate a file's contents. Because I don't know exactly how it works (VBs isn't my forte), I'll leave it to you to do your own research. Here's a <a href="https://www.instructables.com/id/Make-your-windows-read-files-writen-in-notepad/" rel="nofollow">link</a> to the instructable by SCRIPTmaster.<br> <br> If I knew how the script worked, I could help you out a lot more. Sorry.
cool batch
i use space bar and it works fine for me lol <br>
Yeah, I added something into the code that stops it, but I forgot to take out the warning.
Next instructable will be about a batch program to open, explore and browse your folders. It'll be out within the week.

About This Instructable




Bio: I enjoy anything to do with computers. I have made some interesting scripts, and I am constantly improving my skill set. One day I hope ... More »
More by Prof. Pickle:How to Create your own Commands with Batch Start a batch file completely hidden Tips on how to find errors in code (focused on DOS) 
Add instructable to: