From d2f0a2fa6071c1a9faca762e8cea1d987940a99d Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Mon, 18 Mar 2024 00:31:16 +0200 Subject: [PATCH] Add option to replace blocks in TTS --- public/scripts/extensions/tts/index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/public/scripts/extensions/tts/index.js b/public/scripts/extensions/tts/index.js index 74273f2a7..e5a62915a 100644 --- a/public/scripts/extensions/tts/index.js +++ b/public/scripts/extensions/tts/index.js @@ -529,6 +529,10 @@ async function processTtsQueue() { text = text.replace(/```.*?```/gs, '').trim(); } + if (extension_settings.tts.skip_tags) { + text = text.replace(/<.*?>.*?<\/.*?>/g, '').trim(); + } + if (!extension_settings.tts.pass_asterisks) { text = extension_settings.tts.narrate_dialogues_only ? text.replace(/\*[^*]*?(\*|$)/g, '').trim() // remove asterisks content @@ -617,6 +621,7 @@ function loadSettings() { $('#tts_narrate_user').prop('checked', extension_settings.tts.narrate_user); $('#tts_pass_asterisks').prop('checked', extension_settings.tts.pass_asterisks); $('#tts_skip_codeblocks').prop('checked', extension_settings.tts.skip_codeblocks); + $('#tts_skip_tags').prop('checked', extension_settings.tts.skip_tags); $('body').toggleClass('tts', extension_settings.tts.enabled); } @@ -695,6 +700,11 @@ function onSkipCodeblocksClick() { saveSettingsDebounced(); } +function onSkipTagsClick() { + extension_settings.tts.skip_tags = !!$('#tts_skip_tags').prop('checked'); + saveSettingsDebounced(); +} + function onPassAsterisksClick() { extension_settings.tts.pass_asterisks = !!$('#tts_pass_asterisks').prop('checked'); saveSettingsDebounced(); @@ -1018,6 +1028,10 @@ $(document).ready(function () { Skip codeblocks +