let msg = new SpeechSynthesisUtterance('Hello World');
window.speechSynthesis.speak(msg);
Original source:
http://github.com/mdn/web-speech-api
Enter some text in the input below and press return to hear it. Change voices using the dropdown menu.
Original source:
http://github.com/mdn/web-speech-api
...diagnostic messages
var colors = [ 'aqua', 'azure', 'beige']; //snip
var grammar = '#JSGF V1.0; grammar colors; public = ' +
colors.join(' | ') + ' ;'
var recognition = new SpeechRecognition();
var speechRecognitionList = new SpeechGrammarList();
speechRecognitionList.addFromString(grammar, 1);
recognition.grammars = speechRecognitionList;
button.onclick = function() {
recognition.start();
console.log('Ready to receive a color command.');
}
recognition.onresult = function(event) {
var last = event.results.length - 1;
var color = event.results[last][0].transcript;
diagnostic.textContent = 'Result received: ' + color + '.';
bg.style.backgroundColor = color;
console.log('Confidence: ' +
event.results[0][0].confidence);
}