diff --git a/public/scripts/extensions/tts/index.js b/public/scripts/extensions/tts/index.js index 97e133900..2180159e2 100644 --- a/public/scripts/extensions/tts/index.js +++ b/public/scripts/extensions/tts/index.js @@ -1,5 +1,6 @@ -import { callPopup, saveSettingsDebounced } from '../../../script.js' +import { callPopup, is_send_press, saveSettingsDebounced } from '../../../script.js' import { extension_settings, getContext } from '../../extensions.js' +import { is_group_generating } from '../../group-chats.js' import { getStringHash } from '../../utils.js' import { ElevenLabsTtsProvider } from './elevenlabs.js' import { SileroTtsProvider } from './silerotts.js' @@ -43,6 +44,11 @@ async function moduleWorker() { return } + // Message is currently being generated + if (is_send_press || is_group_generating) { + return; + } + // Chat/character/group changed if ( (context.groupId && lastGroupId !== context.groupId) || @@ -115,7 +121,7 @@ async function playAudioData(audioBlob) { window['tts_preview'] = function (id) { const audio = document.getElementById(id) - if (!audio.hidden) { + if (!$(audio).data('disabled')) { audio.play() } else { @@ -131,7 +137,7 @@ async function onTtsVoicesClick() { for (const voice of voiceIds) { popupText += `
${voice.lang || ''} ${voice.name}
` - popupText += `` + popupText += `` } } catch { popupText = 'Could not load voices list. Check your API key.' diff --git a/public/scripts/extensions/tts/system.js b/public/scripts/extensions/tts/system.js index 9acef12b3..e07a32843 100644 --- a/public/scripts/extensions/tts/system.js +++ b/public/scripts/extensions/tts/system.js @@ -87,7 +87,7 @@ class SystemTtsProvider { return speechSynthesis .getVoices() .sort((a, b) => a.lang.localeCompare(b.lang) || a.name.localeCompare(b.name)) - .map(x => ({ name: x.name, voice_id: x.voiceURI, preview_url: '', lang: x.lang })); + .map(x => ({ name: x.name, voice_id: x.voiceURI, preview_url: false, lang: x.lang })); } previewTtsVoice(voiceId) {