window.speechSynthesis.getVoices(); // пустой массив
document.ready
ставил и на window.onload
).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';
});
}