Text to speech without Internet access

I frequently use Windows Visual Basic scripts to implement speech output from my programs (Windows 7).
For example, I will dynamically generate and execute a script similar to the following:


Set MyVoice = CreateObject("Sapi.SpVoice")  
MyVoice.Speak  "hello everybody"
MyVoice.Speak  "I hope you are having a nice day"

this script can be executed from a Windows command line in any number of ways:

C:> sayhello.vbs
C:> start sayhello.vbs
C:> sayhello.bat

(where sayhello.bat contains the line “start sayhello.vbs”)

I HAVE been able to run batch files successfully as the “then” part of openhab rules by using executeCommandLine, for example:

//this works as expected

However, I have NOT been able to generate speech successfully using Visual Basic scripts in openhab. Here are some of the things I’ve tried with the openhab log messages:

java.io.IOException: Cannot run program "C:\users\Joe\server\openhab2\vbsbatchfiles\sayhello.vbs": 
CreateProcess error=193, %1 is not a valid Win32 application

java.io.IOException: Cannot run program "C:\users\Joe\server\openhab2\vbsbatchfiles\start": CreateProcess error=2, The system cannot find the file specified

//the batch file gets run successfully (no openhab complaints) but I don't hear anything.

Does anyone have a suggestion for getting this to work?

Thanks in advance.
PS: I know about the TTS voice services but I want to implement speech generation that will work even when I lost Internet access.

What’s your policy on bumping messages?

When you run the script locally, do you hear anything? I don’t have much experience with OH under Windows, but could this be a permissions issue? How do you start OH, and with what credentials?

You could try something like this, in order to log anything that might be being returned…

val String ttsResult = executeCommandLine("C:\\users\\Joe\\server\\openhab2\\vbsbatchfiles\\sayhello.bat",10000)
logDebug("Rules", "test: ttsResult=[{}]",ttsResult)

I think you have to run cscript.exe and pass the VBS file as a parameter to run a VBS from OH.
VBS, as the error says, is not an executable file, it’s a script, which gets interpreted by cscript (or wscript - when you need graphic interface).
One other thing to try would be to run cmd.exe and pass csrcript and the VBS
About generating speech when offline… One idea would be to try PollyTTS. That one keeps a cache file for the generated speech and, when you “say” the same thing it uses that file, not generating a new one…

Thanks very much to both of you for your advice.
Mihai’s suggestion works perfectly: