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.