Question

I need help. I'm trying to make a personal assistant with batch, and for effect, I want my computer to speak. I've used the speaking code before, even on this computer, but for some reason, when I try to use the speak command now, it doesn't seem to work. Here's the code I usually use:

Set objVoice=CreateObject("SAPI.SpVoice")
objVoice.Speak("Insert Message Here")

I don't know what happened, but when I run the script, I get this error:

Line: 2

Char: 1

Error: The handle is invalid.

Code 89970006

Source (null)

Please help me fix this error. Thanks in advance. BY THE WAY, I do have Speech API, and my text to speech in Control Panel works. It seems to be the .vbs file.

Was it helpful?

Solution

Try This:

Set Speak = CreateObject("sapi.spvoice")

Speak.Speak "Text Goes Here"

Or, If you want to have it say something you enter you can do this,

Dim Message, Speak
Set Speak=CreateObject("sapi.spvoice")

Message=InputBox("Enter text","Speak")
Speak.Speak Message
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top