diff --git a/index.html b/index.html
index e70e9c7..b2db7ee 100644
--- a/index.html
+++ b/index.html
@@ -125,55 +125,54 @@ body > main {
const langue = document.documentElement.lang;
let voix = null;
- if ('speechSynthesis' in window) {
- speechSynthesis.onvoiceschanged = function() {
- let liste_voix = speechSynthesis.getVoices().filter(voice => voice.lang.startsWith(langue));
- select_voix.innerHTML = aphone;
-
- if (!liste_voix.length) {
- bouton_synthese_vocale.style.display = 'none';
- return;
- }
-
- liste_voix.forEach((v, i) => {
- const option = document.createElement('option');
- option.value = i;
- option.innerText = v.name;
- select_voix.appendChild(option);
- if (v.voiceURI === window.localStorage.getItem('voix')) {
- select_voix.value = i;
- voix = v;
- option.selected = true;
- bouton_synthese_vocale.innerHTML = "🕪";
- }
- })
+ function charger_voix() {
+ let liste_voix = speechSynthesis.getVoices().filter(voice => voice.lang.startsWith(langue));
+ select_voix.innerHTML = aphone;
- bouton_synthese_vocale.style.display = 'block';
- bouton_synthese_vocale.addEventListener('click', () => {
- boite_synthese_vocale.showModal();
- });
- bouton_fermer.addEventListener('click', () => {
- boite_synthese_vocale.close();
- });
- bouton_annuler.addEventListener('click', () => {
- boite_synthese_vocale.close();
- });
- bouton_ok.addEventListener('click', () => {
- boite_synthese_vocale.close();
- if (select_voix.value) {
- voix = liste_voix[select_voix.value];
- window.localStorage.setItem('voix', voix.voiceURI);
- bouton_synthese_vocale.innerHTML = "🕪";
- } else {
- voix = null;
- window.localStorage.removeItem('voix');
- bouton_synthese_vocale.innerHTML = "🕨";
- }
- });
+ if (!liste_voix.length) {
+ bouton_synthese_vocale.style.display = 'none';
+ speechSynthesis.addEventListener('voiceschanged', charger_voix);
+ return;
}
- speechSynthesis.onvoiceschanged()
+ speechSynthesis.removeEventListener('voiceschanged', charger_voix);
+ liste_voix.forEach((v, i) => {
+ const option = document.createElement('option');
+ option.value = i;
+ option.innerText = v.name;
+ select_voix.appendChild(option);
+ if (v.voiceURI === window.localStorage.getItem('voix')) {
+ select_voix.value = i;
+ voix = v;
+ option.selected = true;
+ bouton_synthese_vocale.innerHTML = "🕪";
+ }
+ })
+
+ bouton_synthese_vocale.style.display = 'block';
+ bouton_synthese_vocale.addEventListener('click', () => {
+ boite_synthese_vocale.showModal();
+ });
+ bouton_fermer.addEventListener('click', () => {
+ boite_synthese_vocale.close();
+ });
+ bouton_annuler.addEventListener('click', () => {
+ boite_synthese_vocale.close();
+ });
+ bouton_ok.addEventListener('click', () => {
+ boite_synthese_vocale.close();
+ if (select_voix.value) {
+ voix = liste_voix[select_voix.value];
+ window.localStorage.setItem('voix', voix.voiceURI);
+ bouton_synthese_vocale.innerHTML = "🕪";
+ } else {
+ voix = null;
+ window.localStorage.removeItem('voix');
+ bouton_synthese_vocale.innerHTML = "🕨";
+ }
+ });
}
+ if ('speechSynthesis' in window) charger_voix();
question.addEventListener('keydown', e => {
if (e.key === 'Enter' && !e.ctrlKey && !e.shiftKey) {