How to change voice in Speech Synthesis?
问题 I am trying out a simple example with Speechsynthesis. <script> voices = window.speechSynthesis.getVoices() var utterance = new SpeechSynthesisUtterance("Hello World"); utterance.voice = voices[4]; utterance.lang = voices[4].lang; window.speechSynthesis.speak(utterance); </script> But this gives an error that voices is undefined. I found that getVoices() is loaded async. I saw this answer and updated my code as shown below to use callback. <script> window.speechSynthesis.onvoiceschanged =