Speak with given voice with Active TTS

You may want to speak with a special voice when using ActiveTTS. It is easy to do this with any script languages. Here is an example in perl:

 The script first lists the voices installed on the machine. Then you can set the voice index to be used with speak or speakfile by setting the property VoiceIdx.

use Win32::OLE;
$tts = Win32::OLE->new(‘TTSObj.TextToSpeech.1′) or die “oopsn”;

$n = $tts->get_VoiceCount();
for($i = 0; $i < $n; $i++)
 $tts->{VoiceIdx} = $i;
 print “VoiceIdx:”.$i.” Name:”.$tts->{VoiceName}.”n”;

#Set to the voice you wish
$tts->{VoiceIdx} = 1;
$tts->Speak(“Hello world”, 0);

$tts->SpeakToFile(“Hello world”, “1.mp3″, 0);