diff --git a/public/scripts/extensions/tts/coqui.js b/public/scripts/extensions/tts/coqui.js index 27e261f9c..a05291d25 100644 --- a/public/scripts/extensions/tts/coqui.js +++ b/public/scripts/extensions/tts/coqui.js @@ -5,6 +5,8 @@ TODO: */ import { doExtrasFetch, extension_settings, getApiUrl, getContext, modules, ModuleWorkerWrapper } from "../../extensions.js" +import { callPopup } from "../../../script.js" +import { onTtsProviderSettingsInput } from "./index.js" export { CoquiTtsProvider } @@ -12,7 +14,7 @@ const DEBUG_PREFIX = " "; const UPDATE_INTERVAL = 1000; let inApiCall = false; -let charactersList = []; // Updated with module worker +let voiceIdList = []; // Updated with module worker let coquiApiModels = {}; // Initialized only once let coquiApiModelsFull = {}; // Initialized only once let coquiLocalModels = []; // Initialized only once @@ -52,33 +54,7 @@ function resetModelSettings() { $("#coqui_api_model_settings_language").val("none"); $("#coqui_api_model_settings_speaker").val("none"); } - -function updateCharactersList() { - let currentcharacters = new Set(); - for (const i of getContext().characters) { - currentcharacters.add(i.name); - } - - currentcharacters = Array.from(currentcharacters) - - if (JSON.stringify(charactersList) !== JSON.stringify(currentcharacters)) { - charactersList = currentcharacters - - $('#coqui_character_select') - .find('option') - .remove() - .end() - .append('') - .val('none') - - for (const charName of charactersList) { - $("#coqui_character_select").append(new Option(charName, charName)); - } - - console.debug(DEBUG_PREFIX, "Updated character list to:", charactersList); - } -} - + class CoquiTtsProvider { //#############################// // Extension UI and Settings // @@ -88,6 +64,7 @@ class CoquiTtsProvider { defaultSettings = { voiceMap: "", + voiceIds: [], voiceMapDict: {} } @@ -96,13 +73,15 @@ class CoquiTtsProvider {
- - - - - +
+ + +
- - - - - +
+ + + + + + + + +
` return html } @@ -42,6 +46,7 @@ class ElevenLabsTtsProvider { this.settings.stability = $('#elevenlabs_tts_stability').val() this.settings.similarity_boost = $('#elevenlabs_tts_similarity_boost').val() this.settings.multilingual = $('#elevenlabs_tts_multilingual').prop('checked') + onTtsProviderSettingsInput() } @@ -66,6 +71,8 @@ class ElevenLabsTtsProvider { $('#elevenlabs_tts_similarity_boost').val(this.settings.similarity_boost) $('#elevenlabs_tts_api_key').val(this.settings.apiKey) $('#tts_auto_generation').prop('checked', this.settings.multilingual) + $('#eleven_labs_connect').on('click',this.onConnectClick) + $('#elevenlabs_tts_settings').on('input',this.onSettingsChange) this.checkReady() console.info("Settings loaded") @@ -77,6 +84,9 @@ class ElevenLabsTtsProvider { } async onApplyClick() { + } + + async onConnectClick() { // Update on Apply click return await this.updateApiKey().catch( (error) => { throw error @@ -93,6 +103,7 @@ class ElevenLabsTtsProvider { }) this.settings.apiKey = this.settings.apiKey console.debug(`Saved new API_KEY: ${this.settings.apiKey}`) + this.onSettingsChange() } //#################// diff --git a/public/scripts/extensions/tts/index.js b/public/scripts/extensions/tts/index.js index 9f18262b8..458c49b30 100644 --- a/public/scripts/extensions/tts/index.js +++ b/public/scripts/extensions/tts/index.js @@ -515,7 +515,7 @@ function setTtsStatus(status, success) { } } -function onApplyClick() { +function onRefreshClick() { Promise.all([ ttsProvider.onApplyClick(), // updateVoiceMap() @@ -598,11 +598,7 @@ function onTtsProviderChange() { } // Ensure that TTS provider settings are saved to extension settings. -function onTtsProviderSettingsInput() { - ttsProvider.onSettingsChange() - - // Persist changes to SillyTavern tts extension settings - +export function onTtsProviderSettingsInput() { extension_settings.tts[ttsProviderName] = ttsProvider.settings saveSettingsDebounced() console.info(`Saved settings ${ttsProviderName} ${JSON.stringify(ttsProvider.settings)}`) @@ -807,10 +803,11 @@ $(document).ready(function () {
-
- Select TTS Provider
- +
@@ -849,14 +845,13 @@ $(document).ready(function () {
` $('#extensions_settings').append(settingsHtml) - $('#tts_apply').on('click', onApplyClick) + $('#tts_refresh').on('click', onRefreshClick) $('#tts_enabled').on('click', onEnableClick) $('#tts_narrate_dialogues').on('click', onNarrateDialoguesClick); $('#tts_narrate_quoted').on('click', onNarrateQuotedClick); $('#tts_narrate_translated_only').on('click', onNarrateTranslatedOnlyClick); $('#tts_auto_generation').on('click', onAutoGenerationClick); $('#tts_voices').on('click', onTtsVoicesClick) - $('#tts_provider_settings').on('input', onTtsProviderSettingsInput) for (const provider in ttsProviders) { $('#tts_provider').append($("`) }) + this.onSettingsChange() } loadSettings(settings) { diff --git a/public/scripts/extensions/tts/silerotts.js b/public/scripts/extensions/tts/silerotts.js index 3628fa2ee..0f2db6de8 100644 --- a/public/scripts/extensions/tts/silerotts.js +++ b/public/scripts/extensions/tts/silerotts.js @@ -1,4 +1,5 @@ import { doExtrasFetch, getApiUrl, modules } from "../../extensions.js" +import { onTtsProviderSettingsInput } from "./index.js" export { SileroTtsProvider } @@ -30,6 +31,7 @@ class SileroTtsProvider { onSettingsChange() { // Used when provider settings are updated from UI this.settings.provider_endpoint = $('#silero_tts_endpoint').val() + onTtsProviderSettingsInput() } loadSettings(settings) { @@ -61,6 +63,7 @@ class SileroTtsProvider { }, 2000); $('#silero_tts_endpoint').val(this.settings.provider_endpoint) + $('#silero_tts_endpoint').on("input", this.onSettingsChange) this.checkReady() diff --git a/public/scripts/extensions/tts/style.css b/public/scripts/extensions/tts/style.css index a2f0d8057..5df2b0fc7 100644 --- a/public/scripts/extensions/tts/style.css +++ b/public/scripts/extensions/tts/style.css @@ -66,4 +66,11 @@ .tts-button:hover { opacity: 1; +} + +.tts_block { + display: flex; + align-items: center; + column-gap: 5px; + flex-wrap: wrap; } \ No newline at end of file diff --git a/public/scripts/extensions/tts/system.js b/public/scripts/extensions/tts/system.js index b97fdcd2d..102b0bf1b 100644 --- a/public/scripts/extensions/tts/system.js +++ b/public/scripts/extensions/tts/system.js @@ -1,7 +1,7 @@ import { isMobile } from "../../RossAscends-mods.js"; import { getPreviewString } from "./index.js"; import { talkingAnimation } from './index.js'; - +import { onTtsProviderSettingsInput } from "./index.js" export { SystemTtsProvider } /** @@ -107,7 +107,7 @@ class SystemTtsProvider { this.settings.pitch = Number($('#system_tts_pitch').val()); $('#system_tts_pitch_output').text(this.settings.pitch); $('#system_tts_rate_output').text(this.settings.rate); - console.log('Save changes'); + onTtsProviderSettingsInput() } loadSettings(settings) { @@ -144,6 +144,11 @@ class SystemTtsProvider { $('#system_tts_rate').val(this.settings.rate || this.defaultSettings.rate); $('#system_tts_pitch').val(this.settings.pitch || this.defaultSettings.pitch); + + // Trigger updates + $('#system_tts_rate').on("input", this.onSettingsChange) + $('#system_tts_rate').on("input", this.onSettingsChange) + $('#system_tts_pitch_output').text(this.settings.pitch); $('#system_tts_rate_output').text(this.settings.rate); console.info("Settings loaded");