let dutchVoice;
function talk() {
var msg = new SpeechSynthesisUtterance();
msg.text = "Een tekst laten uitspreken door de webbrowser, lijkt veel vriendelijker.";
msg.lang = "nl-NL";
msg.voice = dutchVoice;
window.speechSynthesis.speak(msg);
}
function checkDutchVoices() {
if (dutchVoice) {
return;
}
const voices = window.speechSynthesis.getVoices();
let ned = [];
for (let voice of voices) {
if (voice.lang === 'nl-NL') {
ned.push(voice);
}
//console.log(voice);
}
if (ned.length > 0) {
dutchVoice = ned[ned.length-1];
talk();
}
}
window.speechSynthesis.onvoiceschanged = checkDutchVoices;
Demo in JSFiddle. Voer uit met Microsoft Edge.
Geen opmerkingen:
Een reactie posten