1

I am designing an application with HTML and JS that uses Electron as the browser, (Electron allows me to have a transparent window). Everything works well, except I cannot seem to change the default voice from Microsoft David regardless of what my code says. Would anyone be able to shed some light on things I could try/what I could do?

Tried relocating where the speechsynthesis was called from, changing the array number.

speechSynthesis.addEventListener('voiceschanged', myFunction(Test));
var msg = new SpeechSynthesisUtterance("Testing");

var voices = window.speechSynthesis.getVoices();
var voice = speechSynthesis.getVoices();
                    speechSynthesis.getVoices().forEach(function(voice) {
                    console.log(voice.name, voice.default ? voice.default : '');
                    });

            msg.pitch = 1.1;
            msg.volume = 1;
            msg.rate = 0.85;
            msg.lang = 'en-US';
            msg.voice = voices[5];
            window.speechSynthesis.speak(msg);

I would expect the code to change the default voice from David to Zira. I cannot deviate away from David.

Butter
  • 31
  • 2
  • Are you sure there are 6 voices available? On my machine I only get 3. See https://greggman.github.io/fanfictionreader/ and https://github.com/greggman/fanfictionreader – gman Jul 08 '19 at 01:07
  • Yes, I am getting Microsoft James - English (Australia) Windowless.html:248 Microsoft David - English (United States) Windowless.html:248 Microsoft Mark - English (United States) Windowless.html:248 Microsoft Zira - English (United States) Windowless.html:248 Microsoft Catherine - English (Australia) Windowless.html:248 Microsoft Zira Desktop - English (United States) Windowless.html:248 Microsoft David Desktop - English (United States) true – Butter Jul 08 '19 at 05:11
  • Is this the complete code? You don't have myFunction defined within it. – Frazer Jul 08 '19 at 09:15
  • No it's not, I cannot post the complete code due to confidentiality, but myFunction is defined within the code, this code actually exists within myFunction. I have tried moving the event listener prior to myFunction too, it did not make a difference. – Butter Jul 08 '19 at 22:51

0 Answers0