SpeechSynthesis.speak not working in chrome

I am using chrome Version 55.0.2883.87 m (64-bit) on Windows 10.

The following simple html file reproduces the problem and is extracted from my more complex application. It is supposed to say 3 words when loading the page. It works on MS Edge and Firefox, but does not work on chrome. This code worked for me on Chrome without problems a couple of weeks ago.

<html> <head> <script lang="javascript"> window.speechSynthesis.speak(new SpeechSynthesisUtterance("cat")); window.speechSynthesis.speak(new SpeechSynthesisUtterance("dog")); window.speechSynthesis.speak(new SpeechSynthesisUtterance("bark")); </script> </head> <body></body> </html> 
+7
google-chrome webspeech-api
source share
1 answer

 resultsDisplay = document.getElementById("rd"); startButton = document.getElementById("startbtn"); stopButton = document.getElementById("stopbtn"); recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition || window.mozSpeechRecognition || window.msSpeechRecognition)(); recognition.lang = "en-US"; recognition.interimResults = false; recognition.maxAlternatives = 5; recognition.onresult = function(event) { resultsDisplay.innerHTML = "You Said:" + event.results[0][0].transcript; }; function start() { recognition.start(); startButton.style.display = "none"; stopButton.style.display = "block"; } function stop() { recognition.stop(); startButton.style.display = "block"; stopButton.style.display = "none"; } 
 .resultsDisplay {width: 100%; height: 90%;} #stopbtn {display: none;} 
 <div class="resultsDisplay" id="rd"></div> <br/> <center> <button onclick="start()" id="startbtn">Start</button> <button onclick="stop()" id="stopbtn">Stop</button> </center> 

Try

 utterance = new SpeechSynthesisUtterance("cat, dog, bark"); speechSynthesis.speak(utterance); 

I made Weave in LiveWeave .

0
source share

All Articles