Simple text-to-speech script for Windows

The script I posted a few days ago works on my TabletPC, but I'm not sure why.  Jayman Dalal is a test engineer who suggested the following, much better script.
 
Open Notepad and save the following to a file named "Dospeak.js":
 
function DoSpeak(phrase) {
 
    var Speech_SPCAT_VOICES = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\Voices";
    var vt=WScript.CreateObject("SAPI.SpVoice", "voice_");
    var category = new ActiveXObject("Sapi.SpObjectTokenCategory");
   
    category.SetId(Speech_SPCAT_VOICES);
    var Token = category.EnumerateTokens("Name=Microsoft Sam").Item(0);
   
    vt.voice = Token;
    vt.Speak(phrase,1);
   
    while(speaking == true)
    {
        WScript.Sleep(100);
    }
 
}
 
 
function voice_EndStream(StreamNumber, StreamPosition)
{
    speaking=false
}
 
var speaking=true
DoSpeak("This is a long test of TTS")
 
This should work on any machine running Windows XP or higher.
 
Thanks Jayman!
 
P.S. here's an even simpler script, suggested by our developer David Wood:
 

function DoSpeak(phrase) {

 

    var vt=WScript.CreateObject("SAPI.SpVoice", "voice_");

 

    vt.Speak(phrase,1);

 

    while(speaking == true)

 

    {

        WScript.Sleep(100);

    }

 

}

 

function voice_EndStream(StreamNumber, StreamPosition)

 

{

    speaking=false

}

var speaking=true

 

DoSpeak("This is a long test of TTS")

 

Published 20 September 04 04:50 by sprague

Comments

# Mikael Söderström said on September 20, 2004 1:28 PM:
Doesn´t work for me. :-(
Maybe there are som mysterious signs in your post... 8)
Can you try to mail the code that you use to vimpyboy@msn.com?

Regards,
Mikael Söderström
New Comments to this post are disabled

Search

This Blog

Syndication

Page view tracker