update display
This commit is contained in:
parent
d2da4004c3
commit
22af275489
@ -225,9 +225,12 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
const audio = new Audio(gTtsUrl);
|
const audio = new Audio(gTtsUrl);
|
||||||
audio.onended = () => { if (videoPlayer) videoPlayer.volume = 1.0; };
|
audio.onended = () => { if (videoPlayer) videoPlayer.volume = 1.0; };
|
||||||
|
|
||||||
audio.onerror = () => {
|
let fallbackPlayed = false;
|
||||||
|
const handleFallback = (err) => {
|
||||||
|
if (fallbackPlayed) return;
|
||||||
|
fallbackPlayed = true;
|
||||||
// Fallback to built-in if external TTS fails
|
// Fallback to built-in if external TTS fails
|
||||||
console.warn("External TTS failed, falling back to built-in speech");
|
console.warn("External TTS failed, falling back to built-in speech", err);
|
||||||
if ('speechSynthesis' in window) {
|
if ('speechSynthesis' in window) {
|
||||||
const utterance = new SpeechSynthesisUtterance(text);
|
const utterance = new SpeechSynthesisUtterance(text);
|
||||||
utterance.lang = locale === 'ar' ? 'ar-SA' : 'en-US';
|
utterance.lang = locale === 'ar' ? 'ar-SA' : 'en-US';
|
||||||
@ -249,11 +252,12 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
if (videoPlayer) videoPlayer.volume = 1.0;
|
if (videoPlayer) videoPlayer.volume = 1.0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
audio.onerror = handleFallback;
|
||||||
|
|
||||||
// Attempt to play external audio
|
// Attempt to play external audio
|
||||||
const playPromise = audio.play();
|
const playPromise = audio.play();
|
||||||
if (playPromise !== undefined) {
|
if (playPromise !== undefined) {
|
||||||
playPromise.catch(audio.onerror);
|
playPromise.catch(handleFallback);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (videoPlayer) videoPlayer.volume = 1.0;
|
if (videoPlayer) videoPlayer.volume = 1.0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user