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")