Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created April 24, 2019 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/106ecae2ff6e31b8cc4d44e98abf79dc to your computer and use it in GitHub Desktop.
Save parzibyte/106ecae2ff6e31b8cc4d44e98abf79dc to your computer and use it in GitHub Desktop.
// 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