-
-
Save parzibyte/106ecae2ff6e31b8cc4d44e98abf79dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Función que pone las voces dentro del select | |
const cargarVoces = () => { | |
if (vocesDisponibles.length > 0) { | |
console.log("No se cargan las voces porque ya existen: ", vocesDisponibles); | |
return; | |
} | |
vocesDisponibles = speechSynthesis.getVoices(); | |
console.log({ vocesDisponibles }) | |
posibleIndice = vocesDisponibles.findIndex(voz => IDIOMAS_PREFERIDOS.includes(voz.lang)); | |
if (posibleIndice === -1) posibleIndice = 0; | |
vocesDisponibles.forEach((voz, indice) => { | |
const opcion = document.createElement("option"); | |
opcion.value = indice; | |
opcion.innerHTML = voz.name; | |
opcion.selected = indice === posibleIndice; | |
$voces.appendChild(opcion); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment