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) {
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 ── */