Posted by member 5575 on 2006-04-10 13:42:50 link

I'm not sure how current litespeak is - it may be trying to use the MS SAPI4 components, and chances are you've got SAPI5 installed on your PC, unless it's fairly antique. If all you want to do is basic text-to-speech you can do it with a simple vbscript, then call it like so:

!execute [wscript $personaldir$Scripts\speak.vbs "I'm sorry Dave, I'm afraid I can't do that."]

The script looks like this (save it to a file named speak.vbs):

'---
' Declaring variable to hold SAPI object.
'---

Dim spkr, mesg

On Error Resume Next ' skip to next line on error

'---
' Creating SAPI object using spvoice.
'---

Set spkr = WSCript.CreateObject("SAPI.SpVoice")

If err.number 0 Then
MsgBox "You do not have Microsoft Speech installed."
WScript.Quit
Else
' everything's ok
End If

On Error GoTo 0 ' reset error handling
Err.clear ' in case we have more code, we clear the current error

'--- Voice and language selection:
'--- American English = 409
'--- British English = 809

'--- By *not* selecting a name here, we use the default voice specifed in the
'--- user's 'Speech' control panel applet.

Set spkr.voice = spkr.GetVoices("Language=409").Item(0)

'--- If you want to change the voice, then uncomment one of the following lines.

'Set spkr.voice = spkr.GetVoices("Name=Microsoft sam" , "Language=409").Item(0)
'Set spkr.voice = spkr.GetVoices("Name=Microsoft mike", "Language=409").Item(0)
'Set spkr.voice = spkr.GetVoices("Name=Microsoft mary", "Language=409").Item(0)

If WScript.Arguments.count > 0 Then
mesg = WScript.Arguments.item(0)
Else
mesg = ""
End If

'--- You can set other parameters and properties like voice pitch, speed etc.

spkr.Volume = 75 ' 0 100
spkr.Rate = 1. '-10 +10
If (Len(mesg) = 0) Then
mesg = "You didn't give me anything to SAY, you doofus."
spkr.Rate = 2.
End If

'--- Using speak function of SpVoice to speak a string.

spkr.Speak(mesg)

'--- Destroy voice object.

Set spkr = nothing

Wscript.Quit