1var synth = window.speechSynthesis; 2 3window.speak = function (text, objRef) { 4 if (synth.speaking) { 5 console.error('speechSynthesis.speaking'); 6 return; 7 } 8 if (text !== '') { 9 var utterThis = new SpeechSynthesisUtterance(text); 10 utterThis.onend = function (event) { 11 console.log('SpeechSynthesisUtterance.onend'); 12 objRef.invokeMethodAsync('OnEnd'); 13 } 14 utterThis.onerror = function (event) { 15 console.error('SpeechSynthesisUtterance.onerror'); 16 } 17 //var selectedOption = voiceSelect.selectedOptions[0].getAttribute('data-name'); 18 19 voices = synth.getVoices(); 20 for (i = 0; i < voices.length; i++) { 21 if (voices[i].lang === "en-GB") { 22 utterThis.voice = voices[i]; 23 break; 24 } 25 } 26 27 if (utterThis.voice !== "en-GB") { 28 for (i = 0; i < voices.length; i++) { 29 if (voices[i].lang.startsWith("en")) { 30 utterThis.voice = voices[i]; 31 break; 32 } 33 } 34 } 35 36 //utterThis.voice = voices[5]; 37 utterThis.pitch = 1; 38 utterThis.rate = 1; 39 synth.speak(utterThis); 40 } 41} 42 43function populateVoiceList() { 44 voices = synth.getVoices().sort(function (a, b) { 45 const aname = a.name.toUpperCase(), bname = b.name.toUpperCase(); 46 if (aname < bname) return -1; 47 else if (aname == bname) return 0; 48 else return +1; 49 }); 50 var selectedIndex = voiceSelect.selectedIndex < 0 ? 0 : voiceSelect.selectedIndex; 51 voiceSelect.innerHTML = ''; 52 for (i = 0; i < voices.length; i++) { 53 var option = document.createElement('option'); 54 option.textContent = voices[i].name + ' (' + voices[i].lang + ')'; 55 56 if (voices[i].default) { 57 option.textContent += ' -- DEFAULT'; 58 } 59 60 option.setAttribute('data-lang', voices[i].lang); 61 option.setAttribute('data-name', voices[i].name); 62 voiceSelect.appendChild(option); 63 } 64 voiceSelect.selectedIndex = selectedIndex; 65}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.