#245 Add option to TTS only the dialogues

This commit is contained in:
SillyLossy
2023-05-07 00:27:32 +03:00
parent dd9c5f30d3
commit 1a9039649b
2 changed files with 18 additions and 6 deletions

View File

@ -2607,7 +2607,7 @@ function extractImageFromMessage(getMessage) {
return { getMessage, image, title }; return { getMessage, image, title };
} }
function isMultigenEnabled() { export function isMultigenEnabled() {
return power_user.multigen && (main_api == 'textgenerationwebui' || main_api == 'kobold' || main_api == 'novel'); return power_user.multigen && (main_api == 'textgenerationwebui' || main_api == 'kobold' || main_api == 'novel');
} }

View File

@ -1,6 +1,5 @@
import { callPopup, is_send_press, saveSettingsDebounced } from '../../../script.js' import { callPopup, isMultigenEnabled, is_send_press, saveSettingsDebounced } from '../../../script.js'
import { extension_settings, getContext } from '../../extensions.js' import { extension_settings, getContext } from '../../extensions.js'
import { is_group_generating } from '../../group-chats.js'
import { getStringHash } from '../../utils.js' import { getStringHash } from '../../utils.js'
import { ElevenLabsTtsProvider } from './elevenlabs.js' import { ElevenLabsTtsProvider } from './elevenlabs.js'
import { SileroTtsProvider } from './silerotts.js' import { SileroTtsProvider } from './silerotts.js'
@ -44,8 +43,8 @@ async function moduleWorker() {
return return
} }
// Message is currently being generated // Multigen message is currently being generated
if (is_send_press || is_group_generating) { if (is_send_press && isMultigenEnabled()) {
return; return;
} }
@ -241,7 +240,9 @@ async function processTtsQueue() {
console.debug('New message found, running TTS') console.debug('New message found, running TTS')
currentTtsJob = ttsJobQueue.shift() currentTtsJob = ttsJobQueue.shift()
const text = currentTtsJob.mes.replaceAll('*', '') const text = extension_settings.tts.narrate_dialogues_only
? currentTtsJob.mes.replace(/\*[^\*]*?(\*|$)/g, '') // remove asterisks content
: currentTtsJob.mes.replaceAll('*', '') // remove just the asterisks
const char = currentTtsJob.name const char = currentTtsJob.name
try { try {
@ -280,6 +281,7 @@ function loadSettings() {
'checked', 'checked',
extension_settings.tts.enabled extension_settings.tts.enabled
) )
$('#tts_narrate_dialogues').prop('checked', extension_settings.tts.narrate_dialogues_only)
} }
const defaultSettings = { const defaultSettings = {
@ -367,6 +369,11 @@ function onEnableClick() {
} }
function onNarrateDialoguesClick() {
extension_settings.tts.narrate_dialogues_only = $('#tts_narrate_dialogues').prop('checked');
saveSettingsDebounced()
}
//##############// //##############//
// TTS Provider // // TTS Provider //
//##############// //##############//
@ -442,6 +449,10 @@ $(document).ready(function () {
<input type="checkbox" id="tts_enabled" name="tts_enabled"> <input type="checkbox" id="tts_enabled" name="tts_enabled">
Enabled Enabled
</label> </label>
<label class="checkbox_label" for="tts_narrate_dialogues">
<input type="checkbox" id="tts_narrate_dialogues">
Narrate dialogues only
</label>
</div> </div>
<label>Voice Map</label> <label>Voice Map</label>
<textarea id="tts_voice_map" type="text" class="text_pole textarea_compact" rows="4" <textarea id="tts_voice_map" type="text" class="text_pole textarea_compact" rows="4"
@ -463,6 +474,7 @@ $(document).ready(function () {
$('#extensions_settings').append(settingsHtml) $('#extensions_settings').append(settingsHtml)
$('#tts_apply').on('click', onApplyClick) $('#tts_apply').on('click', onApplyClick)
$('#tts_enabled').on('click', onEnableClick) $('#tts_enabled').on('click', onEnableClick)
$('#tts_narrate_dialogues').on('click', onNarrateDialoguesClick);
$('#tts_voices').on('click', onTtsVoicesClick) $('#tts_voices').on('click', onTtsVoicesClick)
$('#tts_provider_settings').on('input', onTtsProviderSettingsInput) $('#tts_provider_settings').on('input', onTtsProviderSettingsInput)
for (const provider in ttsProviders) { for (const provider in ttsProviders) {