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:
co-authored by
Claude Sonnet 4.6
parent
b4e45c1c22
commit
40b8b54aee
@@ -523,9 +523,7 @@ 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(() => {
|
|
||||||
window.speechSynthesis.cancel();
|
|
||||||
const letras = codigo.split('').join(' ');
|
const letras = codigo.split('').join(' ');
|
||||||
let texto = `Turno ${letras}`;
|
let texto = `Turno ${letras}`;
|
||||||
if (paciente) texto += `, ${paciente}`;
|
if (paciente) texto += `, ${paciente}`;
|
||||||
@@ -535,8 +533,8 @@ function anunciarTurno(codigo, destino, paciente) {
|
|||||||
const voz = getVozES();
|
const voz = getVozES();
|
||||||
if (voz) utt.voice = voz;
|
if (voz) utt.voice = voz;
|
||||||
utt.rate = 0.85; utt.pitch = 1.05; utt.volume = 1;
|
utt.rate = 0.85; utt.pitch = 1.05; utt.volume = 1;
|
||||||
window.speechSynthesis.speak(utt);
|
setTimeout(() => window.speechSynthesis.speak(utt), 800);
|
||||||
}, 800);
|
return utt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── 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 ── */
|
||||||
|
|||||||
Reference in New Issue
Block a user