diff --git a/public/script.js b/public/script.js index dab17418d..f809c2dcd 100644 --- a/public/script.js +++ b/public/script.js @@ -1615,10 +1615,10 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject, // Set empty promise resolution functions if (typeof resolve !== 'function') { - resolve = () => {}; + resolve = () => { }; } if (typeof reject !== 'function') { - reject = () => {}; + reject = () => { }; } if (selected_group && !is_group_generating) { @@ -4080,7 +4080,7 @@ function isHordeGenerationNotAllowed() { } export function cancelTtsPlay() { - if (speechSynthesis) { + if ('speechSynthesis' in window) { speechSynthesis.cancel(); } } diff --git a/public/scripts/extensions/tts/system.js b/public/scripts/extensions/tts/system.js index e07a32843..57d322a63 100644 --- a/public/scripts/extensions/tts/system.js +++ b/public/scripts/extensions/tts/system.js @@ -29,7 +29,7 @@ class SystemTtsProvider { } get settingsHtml() { - if (!window.speechSynthesis) { + if (!('speechSynthesis' in window)) { return "Your browser or operating system doesn't support speech synthesis"; } @@ -80,7 +80,7 @@ class SystemTtsProvider { // TTS Interfaces // //#################// fetchTtsVoiceIds() { - if (!window.speechSynthesis) { + if (!('speechSynthesis' in window)) { return []; } @@ -91,6 +91,10 @@ class SystemTtsProvider { } previewTtsVoice(voiceId) { + if (!('speechSynthesis' in window)) { + throw 'Speech synthesis API is not supported'; + } + const voice = speechSynthesis.getVoices().find(x => x.voiceURI === voiceId); if (!voice) { @@ -107,11 +111,11 @@ class SystemTtsProvider { } async getVoice(voiceName) { - if (!window.speechSynthesis) { + if (!('speechSynthesis' in window)) { return { voice_id: null } } - const voices = window.speechSynthesis.getVoices(); + const voices = speechSynthesis.getVoices(); const match = voices.find(x => x.name == voiceName); if (!match) { @@ -122,7 +126,7 @@ class SystemTtsProvider { } async generateTts(text, voiceId) { - if (!window.speechSynthesis) { + if (!('speechSynthesis' in window)) { throw 'Speech synthesis API is not supported'; }