From 40b8b54aeed4e7db86cae3efca114110de6aba1e Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Mon, 27 Jul 2026 06:41:26 -0500 Subject: [PATCH] =?UTF-8?q?fix(display=5Fglobal):=20no=20cortar=20TTS=20cu?= =?UTF-8?q?ando=20llaman=20desde=20lugar=20simult=C3=A1neo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Elimina speechSynthesis.cancel() para que los anuncios no se interrumpan. El overlay espera a que el TTS termine (onend) antes de pasar al siguiente, con un mínimo visual de 5 segundos. Co-Authored-By: Claude Sonnet 4.6 --- modules/turnero/views/display_global.php | 38 +++++++++++++----------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/modules/turnero/views/display_global.php b/modules/turnero/views/display_global.php index 2cd244f..f1b6425 100644 --- a/modules/turnero/views/display_global.php +++ b/modules/turnero/views/display_global.php @@ -523,20 +523,18 @@ if ('speechSynthesis' in window) { function anunciarTurno(codigo, destino, paciente) { playBeep(); - if (!sonidoActivo || !('speechSynthesis' in window)) return; - setTimeout(() => { - window.speechSynthesis.cancel(); - const letras = codigo.split('').join(' '); - let texto = `Turno ${letras}`; - if (paciente) texto += `, ${paciente}`; - texto += `, pase a ${destino}`; - const utt = new SpeechSynthesisUtterance(texto); - utt.lang = 'es-CO'; - const voz = getVozES(); - if (voz) utt.voice = voz; - utt.rate = 0.85; utt.pitch = 1.05; utt.volume = 1; - window.speechSynthesis.speak(utt); - }, 800); + if (!sonidoActivo || !('speechSynthesis' in window)) return null; + const letras = codigo.split('').join(' '); + let texto = `Turno ${letras}`; + if (paciente) texto += `, ${paciente}`; + texto += `, pase a ${destino}`; + const utt = new SpeechSynthesisUtterance(texto); + utt.lang = 'es-CO'; + const voz = getVozES(); + if (voz) utt.voice = voz; + utt.rate = 0.85; utt.pitch = 1.05; utt.volume = 1; + setTimeout(() => window.speechSynthesis.speak(utt), 800); + return utt; } /* ── Fullscreen ── */ @@ -581,7 +579,7 @@ function showAnnouncement({ codigo, destino, paciente, color }) { ov.classList.add('visible'); - anunciarTurno(codigo, destino, paciente); + const utt = anunciarTurno(codigo, destino, paciente); bar.style.transition = 'none'; bar.style.width = '100%'; @@ -590,10 +588,16 @@ function showAnnouncement({ codigo, destino, paciente, color }) { bar.style.width = '0%'; })); - setTimeout(() => { + let dismissed = false; + function dismiss() { + if (dismissed) return; + dismissed = true; ov.classList.remove('visible'); setTimeout(processQueue, 370); - }, 5000); + } + // Cierra al terminar el TTS; mínimo 5s visual + if (utt) utt.addEventListener('end', () => setTimeout(dismiss, 500)); + setTimeout(dismiss, 5000); } /* ── State ── */