Preload the web speech API before calling

So, I noticed that after the first time you talk with help speechSynthesis.speak, it will significantly speed up the presentation of results. So my goal was to speed it up by pre-initializing the synthesis, so when we call speakIt(), we don’t have to wait for it. He did not speed up; any suggestions on why it is not accelerating and how do I fix it?

Full Script:

var speech = new SpeechSynthesisUtterance("test");
var voices = window.speechSynthesis.getVoices();
speech.default = false;
speech.voice = voices.filter(function(voice) { return voice.name == 'Google  UK English Male'; })[0];
speech.lang = 'en-GB';

function speakIt(word){
        speech.text = word;
        window.speechSynthesis.speak(speech);
}

chrome.tts.speakit seems a little faster, but of course it isn’t, but that’s not the point - it should still work. Until someone finds the answer, I will switch to using Chrome.

+4
source share
1

. . , getVoices() . , . . Codepen.

var speech = new Speech();

if (speech.supported()) {
  speech.speak('hello, speech is working fine');
}

Codepen : http://codepen.io/anon/pen/qNwOAO

0

All Articles