diff --git a/public/script.js b/public/script.js index d80bb98d8..a437e6423 100644 --- a/public/script.js +++ b/public/script.js @@ -2891,7 +2891,7 @@ export async function generateRaw(prompt, api, instructOverride) { case 'kobold': case 'koboldhorde': if (preset_settings === 'gui') { - generateData = { prompt: prompt, gui_settings: true, max_length: amount_gen, max_context_length: max_context }; + generateData = { prompt: prompt, gui_settings: true, max_length: amount_gen, max_context_length: max_context, api_server }; } else { const isHorde = api === 'koboldhorde'; const koboldSettings = koboldai_settings[koboldai_setting_names[preset_settings]]; @@ -3724,6 +3724,7 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu gui_settings: true, max_length: maxLength, max_context_length: max_context, + api_server, }; if (preset_settings != 'gui') { diff --git a/public/scripts/extensions/regex/editor.html b/public/scripts/extensions/regex/editor.html index 72c95d3d9..1789dbe98 100644 --- a/public/scripts/extensions/regex/editor.html +++ b/public/scripts/extensions/regex/editor.html @@ -1,9 +1,14 @@
-

Regex Editor +

+ Regex Editor ? +

@@ -11,6 +16,22 @@
+
+
+ + +
+
+ + +
+
+
+

- - `; - - html += ` - - Use XTTSv2 TTS Server. + + + + + + + + + + + + + + + + + + + + + + + `; return html; } + onSettingsChange() { // Used when provider settings are updated from UI this.settings.provider_endpoint = $('#xtts_tts_endpoint').val(); this.settings.language = $('#xtts_api_language').val(); + + // Update the default TTS settings based on input fields + this.settings.speed = $('#xtts_speed').val(); + this.settings.temperature = $('#xtts_temperature').val(); + this.settings.length_penalty = $('#xtts_length_penalty').val(); + this.settings.repetition_penalty = $('#xtts_repetition_penalty').val(); + this.settings.top_k = $('#xtts_top_k').val(); + this.settings.top_p = $('#xtts_top_p').val(); + this.settings.stream_chunk_size = $('#xtts_stream_chunk_size').val(); + this.settings.enable_text_splitting = $('#xtts_enable_text_splitting').is(':checked'); + this.settings.streaming = $('#xtts_tts_streaming').is(':checked'); + + // Update the UI to reflect changes + $('#xtts_tts_speed_output').text(this.settings.speed); + $('#xtts_tts_temperature_output').text(this.settings.temperature); + $('#xtts_length_penalty_output').text(this.settings.length_penalty); + $('#xtts_repetition_penalty_output').text(this.settings.repetition_penalty); + $('#xtts_top_k_output').text(this.settings.top_k); + $('#xtts_top_p_output').text(this.settings.top_p); + $('#xtts_stream_chunk_size_output').text(this.settings.stream_chunk_size); + saveTtsProviderSettings(); + this.changeTTSSettings(); } async loadSettings(settings) { @@ -121,10 +174,40 @@ class XTTSTtsProvider { } }, 2000); + // Set initial values from the settings $('#xtts_tts_endpoint').val(this.settings.provider_endpoint); - $('#xtts_tts_endpoint').on('input', () => { this.onSettingsChange(); }); $('#xtts_api_language').val(this.settings.language); + $('#xtts_speed').val(this.settings.speed); + $('#xtts_temperature').val(this.settings.temperature); + $('#xtts_length_penalty').val(this.settings.length_penalty); + $('#xtts_repetition_penalty').val(this.settings.repetition_penalty); + $('#xtts_top_k').val(this.settings.top_k); + $('#xtts_top_p').val(this.settings.top_p); + $('#xtts_enable_text_splitting').prop('checked', this.settings.enable_text_splitting); + $('#xtts_stream_chunk_size').val(this.settings.stream_chunk_size); + $('#xtts_tts_streaming').prop('checked', this.settings.streaming); + + // Update the UI to reflect changes + $('#xtts_tts_speed_output').text(this.settings.speed); + $('#xtts_tts_temperature_output').text(this.settings.temperature); + $('#xtts_length_penalty_output').text(this.settings.length_penalty); + $('#xtts_repetition_penalty_output').text(this.settings.repetition_penalty); + $('#xtts_top_k_output').text(this.settings.top_k); + $('#xtts_top_p_output').text(this.settings.top_p); + $('#xtts_stream_chunk_size_output').text(this.settings.stream_chunk_size); + + // Register input/change event listeners to update settings on user interaction + $('#xtts_tts_endpoint').on('input', () => { this.onSettingsChange(); }); $('#xtts_api_language').on('change', () => { this.onSettingsChange(); }); + $('#xtts_speed').on('input', () => { this.onSettingsChange(); }); + $('#xtts_temperature').on('input', () => { this.onSettingsChange(); }); + $('#xtts_length_penalty').on('input', () => { this.onSettingsChange(); }); + $('#xtts_repetition_penalty').on('input', () => { this.onSettingsChange(); }); + $('#xtts_top_k').on('input', () => { this.onSettingsChange(); }); + $('#xtts_top_p').on('input', () => { this.onSettingsChange(); }); + $('#xtts_enable_text_splitting').on('change', () => { this.onSettingsChange(); }); + $('#xtts_stream_chunk_size').on('input', () => { this.onSettingsChange(); }); + $('#xtts_tts_streaming').on('change', () => { this.onSettingsChange(); }); await this.checkReady(); @@ -133,7 +216,7 @@ class XTTSTtsProvider { // Perform a simple readiness check by trying to fetch voiceIds async checkReady() { - await this.fetchTtsVoiceObjects(); + await Promise.allSettled([this.fetchTtsVoiceObjects(), this.changeTTSSettings()]); } async onRefreshClick() { @@ -174,8 +257,46 @@ class XTTSTtsProvider { return responseJson; } + // Each time a parameter is changed, we change the configuration + async changeTTSSettings() { + if (!this.settings.provider_endpoint) { + return; + } + + const response = await doExtrasFetch( + `${this.settings.provider_endpoint}/set_tts_settings`, + { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Cache-Control': 'no-cache', + }, + body: JSON.stringify({ + 'temperature': this.settings.temperature, + 'speed': this.settings.speed, + 'length_penalty': this.settings.length_penalty, + 'repetition_penalty': this.settings.repetition_penalty, + 'top_p': this.settings.top_p, + 'top_k': this.settings.top_k, + 'enable_text_splitting': this.settings.enable_text_splitting, + 'stream_chunk_size': this.settings.stream_chunk_size, + }), + }, + ); + return response; + } + async fetchTtsGeneration(inputText, voiceId) { console.info(`Generating new TTS for voice_id ${voiceId}`); + + if (this.settings.streaming) { + const params = new URLSearchParams(); + params.append('text', inputText); + params.append('speaker_wav', voiceId); + params.append('language', this.settings.language); + return `${this.settings.provider_endpoint}/tts_stream/?${params.toString()}`; + } + const response = await doExtrasFetch( `${this.settings.provider_endpoint}/tts_to_audio/`, { diff --git a/public/scripts/kai-settings.js b/public/scripts/kai-settings.js index d88a6ee87..f2f295dc3 100644 --- a/public/scripts/kai-settings.js +++ b/public/scripts/kai-settings.js @@ -4,7 +4,6 @@ import { getStoppingStrings, substituteParams, api_server, - main_api, } from '../script.js'; import { @@ -142,7 +141,6 @@ export function getKoboldGenerationData(finalPrompt, settings, maxLength, maxCon sampler_seed: kai_settings.seed >= 0 ? kai_settings.seed : undefined, api_server, - main_api, }; return generate_data; } diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js index d4378a71a..84fad8c65 100644 --- a/public/scripts/power-user.js +++ b/public/scripts/power-user.js @@ -520,7 +520,7 @@ async function switchZenSliders() { $('#clickSlidersTips').hide(); $('#pro-settings-block input[type=\'number\']').hide(); //hide number inputs that are not 'seed' inputs - $(`#textgenerationwebui_api-settings :input[type='number']:not([id^='seed']), + $(`#textgenerationwebui_api-settings :input[type='number']:not([id^='seed']):not([id^='n_']), #kobold_api-settings :input[type='number']:not([id^='seed'])`).hide(); //hide original sliders $(`#textgenerationwebui_api-settings input[type='range'], @@ -1848,8 +1848,8 @@ export function renderStoryString(params) { // substitute {{macro}} params that are not defined in the story string output = substituteParams(output, params.user, params.char); - // remove leading whitespace - output = output.trimStart(); + // remove leading newlines + output = output.replace(/^\n+/, ''); // add a newline to the end of the story string if it doesn't have one if (output.length > 0 && !output.endsWith('\n')) {