diff --git a/public/scripts/extensions/tts/index.js b/public/scripts/extensions/tts/index.js index 9ae47750b..eb3a25da1 100644 --- a/public/scripts/extensions/tts/index.js +++ b/public/scripts/extensions/tts/index.js @@ -482,6 +482,12 @@ async function processTtsQueue() { console.debug('New message found, running TTS'); currentTtsJob = ttsJobQueue.shift(); let text = extension_settings.tts.narrate_translated_only ? (currentTtsJob?.extra?.display_text || currentTtsJob.mes) : currentTtsJob.mes; + + if (extension_settings.tts.skip_codeblocks) { + text = text.replace(/^\s{4}.*$/gm, '').trim(); + text = text.replace(/```.*?```/gs, '').trim(); + } + text = extension_settings.tts.narrate_dialogues_only ? text.replace(/\*[^*]*?(\*|$)/g, '').trim() // remove asterisks content : text.replaceAll('*', '').trim(); // remove just the asterisks @@ -639,6 +645,11 @@ function onNarrateTranslatedOnlyClick() { saveSettingsDebounced(); } +function onSkipCodeblocksClick() { + extension_settings.tts.skip_codeblocks = !!$('#tts_skip_codeblocks').prop('checked'); + saveSettingsDebounced(); +} + //##############// // TTS Provider // //##############// @@ -952,6 +963,10 @@ $(document).ready(function () { Narrate only the translated text +