Answer the question
In order to leave comments, you need to log in
Why does getVoices work every other time?
I call:
window.speechSynthesis.getVoices(); // пустой массив
document.ready
and on window.onload
). Answer the question
In order to leave comments, you need to log in
Decided so far:
window.speechSynthesis.addEventListener('voiceschanged', function() {
if(isSpeechSynthesis() && isRuVoices()) {
$('.voice').toggleClass('d-none');
}
});
function isSpeechSynthesis() {
return window.speechSynthesis || false;
}
function isRuVoices() {
const arrVoices = window.speechSynthesis.getVoices();
return arrVoices.find(function(item){
return item.lang === 'ru-RU';
});
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question