fix(display_global): no cortar TTS cuando llaman desde lugar simultáneo

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 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-27 06:41:26 -05:00
co-authored by Claude Sonnet 4.6
parent b4e45c1c22
commit 40b8b54aee
+21 -17
View File
@@ -523,20 +523,18 @@ if ('speechSynthesis' in window) {
function anunciarTurno(codigo, destino, paciente) { function anunciarTurno(codigo, destino, paciente) {
playBeep(); playBeep();
if (!sonidoActivo || !('speechSynthesis' in window)) return; if (!sonidoActivo || !('speechSynthesis' in window)) return null;
setTimeout(() => { const letras = codigo.split('').join(' ');
window.speechSynthesis.cancel(); let texto = `Turno ${letras}`;
const letras = codigo.split('').join(' '); if (paciente) texto += `, ${paciente}`;
let texto = `Turno ${letras}`; texto += `, pase a ${destino}`;
if (paciente) texto += `, ${paciente}`; const utt = new SpeechSynthesisUtterance(texto);
texto += `, pase a ${destino}`; utt.lang = 'es-CO';
const utt = new SpeechSynthesisUtterance(texto); const voz = getVozES();
utt.lang = 'es-CO'; if (voz) utt.voice = voz;
const voz = getVozES(); utt.rate = 0.85; utt.pitch = 1.05; utt.volume = 1;
if (voz) utt.voice = voz; setTimeout(() => window.speechSynthesis.speak(utt), 800);
utt.rate = 0.85; utt.pitch = 1.05; utt.volume = 1; return utt;
window.speechSynthesis.speak(utt);
}, 800);
} }
/* ── Fullscreen ── */ /* ── Fullscreen ── */
@@ -581,7 +579,7 @@ function showAnnouncement({ codigo, destino, paciente, color }) {
ov.classList.add('visible'); ov.classList.add('visible');
anunciarTurno(codigo, destino, paciente); const utt = anunciarTurno(codigo, destino, paciente);
bar.style.transition = 'none'; bar.style.transition = 'none';
bar.style.width = '100%'; bar.style.width = '100%';
@@ -590,10 +588,16 @@ function showAnnouncement({ codigo, destino, paciente, color }) {
bar.style.width = '0%'; bar.style.width = '0%';
})); }));
setTimeout(() => { let dismissed = false;
function dismiss() {
if (dismissed) return;
dismissed = true;
ov.classList.remove('visible'); ov.classList.remove('visible');
setTimeout(processQueue, 370); 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 ── */ /* ── State ── */