Reputation: 5063
Currently working on an implementation to use SAPI object in javascript to render some text to speech.
I have basic code which works as:
VoiceObj = new ActiveXObject("Sapi.SpVoice");
VoiceObj.Speak("hello world");
I am now looking at a way to change which voice is getting used for the TTS. From looking through the SAPI docs online, I have managed to get an object which contains the voices available, and can select them by an index.
voices = VoiceObj.GetVoices();
VoiceObj.Voice = voices.Item(1);
console.log(VoiceObj.Voice.GetDescription());
This will correctly pulls voices back, and when logged out, will give the name of the voice. The problem comes when I try and call .Speak
after making a change to the voice. The javascript will just throw Automation server can't create object
error and no speech is heard.
Is this the correct way for changing the voice? I can not find any other methods available which would achieve this.
Upvotes: 1
Views: 2439
Reputation: 1
var voiceObj = new ActiveXObject("Sapi.SpVoice");
//voiceObj.Speak("hello world");
var voices = voiceObj.GetVoices();
var i,n=voices.Count;
var v; //VoiceObj.Voice
for(i=0; i<n; i++){
console.log("Item "+i);
var v=voices.Item(i);
console.log(v.GetDescription());
}
Upvotes: 0