I ran getVoices() of the Web Speech API with the following code in chrome, but it returned with an empty array.How can I get it?
const voice=speechSynthesis.getVoices();
console.log(voice);
<·[]// Console Results
By the way, Chrome supports speechSynthesis, and when you execute the above code on the console, it returns the array properly.
javascript google-chrome
Wait for the voiceschanged
event before running.Your voice may not be ready immediately after the page loads.
speechSynthesis.addEventListener('voiceschanged', e=>{
const voice = speechSynthesis.getVoices();
console.log(voice);
});
© 2024 OneMinuteCode. All rights reserved.