Question:
how to make your pc talk in batch programming?
pokeman
2010-03-20 12:29:51 UTC
I know how to make it talk in vbs, but what about batch (cmd) I cant use vbs because of the program im trying to make. or is there a vbs to bat converter
Six answers:
2010-03-20 12:42:27 UTC
Well, considering that making your pc speak in VBS requires the use of the SAPI.spVoice object of the WSH, it is not possible to do it in batch.



Edit: If you just want to make this execute via VBS from the command prompt, you would use CScript instead of WScript.

You can pass an argument to your script via CScript using the WScript.Arguments object in your script.



Your command would look like:



C:\Filepath > CScript filename.vbs "This is what i want to say"



Other than that, I will say again, there is no way to access the speach program with a batch file alone.
?
2010-03-21 06:45:15 UTC
First modify your VB program so that it can take a command line argument. This argument will be a text string which the VB program will convert to speech.



You then call your VB program with its command line argument in your batch file



MyProg "What you want to say"





Here is an example of how to use a command line argument in VB. Place the following in the form load event and have a label on the form



Dim str As String

str = ""

If My.Application.CommandLineArgs.Count > 0 Then

str = My.Application.CommandLineArgs.Item(0)

End If

Me.Label1.Text = str



To test this within the IDE you go to the program properties and click on the Debug tab and you will see a command line argument box that you can enter a delimited (use quotes) string into.

Or you have to compile and deploy the program and run the program with a command line argument. You have to do this to use the program with a batch file anyway...
2010-03-21 01:39:16 UTC
I think I get you. In vbs, you use the print command (forgive me if im wrong-my vbs knowledge is minimal). I have done a fair bit of batch coding. A good batch (in case you are un-aware) always starts off with:

@echo off

cls



@ echo off means do not display anything unless I tell you to.

cls means clear screen.



To make it show text on the screen, type:

echo (text to be displayed)

As soon as you press enter, it will stop displaying.



Another useful command to know is the REM command (remark).

This means do not execute the following: and is used in the same way as echo tio not display or run. Or did you know that already?

Enjoy your batch coding.



Also, as far as im aware, there is no such thing as a vbs to bat converter, but I know, and have used, bat to exe converter. Just make sure you back up the batch file before converting!





Good luck.

Shane
piner
2016-09-09 11:15:32 UTC
OK what type of programming are you considering doing... BTW Dreamweaver, photoshop and Sony Vegas don't seem to be programming gear... Are you speakme Desktop application growth, Web Application Development or whatever else?
2010-03-24 10:34:24 UTC
The code below is posted at: http://pastebin.com/xfHCx0U0



How about you have the batch file output vbscript code to another file and run that:



@echo off

:start

set /p text=What should I say:

echo dim mouth>"speaker.vbs"

echo set mouth=createobject("sapi.spvoice")>>"speaker.vbs"

echo mouth.speak "%text%">>"speaker.vbs"

wscript.exe speaker.vbs

pause >nul

goto start
Mikey Green
2014-08-31 21:49:31 UTC
@echo off

title Text to Speech Conversion

color 0a



cls

echo What do you want the computer to convert into speech?

echo.

set /p text=



rem Making the temp file

:num

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

pause

del temp%num%.vbs

goto input


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...