From 2318df8b748f450644ddb45a059c5806fd27fb92 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Thu, 30 Jan 2025 17:21:41 +0000 Subject: [PATCH] alltalk.js resolve V1 URL duplication in AllTalk TTS audio output Fix URL concatenation issue where base URL was being duplicated in audio file paths. Updated handling of V1 (full URL) and V2 (relative path) API response formats to prevent `http://localhost:7851http://127.0.0.1:7851` type errors. --- public/scripts/extensions/tts/alltalk.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/public/scripts/extensions/tts/alltalk.js b/public/scripts/extensions/tts/alltalk.js index 593ff3eac..53eda8eb3 100644 --- a/public/scripts/extensions/tts/alltalk.js +++ b/public/scripts/extensions/tts/alltalk.js @@ -262,13 +262,13 @@ class AllTalkTtsProvider { console.debug('AllTalkTTS: Settings loaded'); try { // Check if TTS provider is ready - this.setupEventListeners(); - this.updateLanguageDropdown(); await this.checkReady(); await this.updateSettingsFromServer(); // Fetch dynamic settings from the TTS server await this.fetchTtsVoiceObjects(); // Fetch voices only if service is ready await this.fetchRvcVoiceObjects(); // Fetch RVC voices this.updateNarratorVoicesDropdown(); + this.updateLanguageDropdown(); + this.setupEventListeners(); this.applySettingsToHTML(); updateStatus('Ready'); } catch (error) { @@ -388,7 +388,7 @@ class AllTalkTtsProvider { } async fetchRvcVoiceObjects() { - if (this.settings.server_version == 'v2') { + if (this.settings.server_version !== 'v1') { console.log('Skipping RVC voices fetch for V1 server'); return []; } @@ -1031,14 +1031,18 @@ class AllTalkTtsProvider { console.error('fetchTtsGeneration Error Response Text:', errorText); throw new Error(`HTTP ${response.status}: ${errorText}`); } + const data = await response.json(); - // Handle V1/V2 URL differences - const outputUrl = this.settings.server_version === 'v1' - ? data.output_file_url // V1 returns full URL - : `${this.settings.provider_endpoint}${data.output_file_url}`; // V2 returns relative path + // V1 returns a complete URL, V2 returns a relative path + if (this.settings.server_version === 'v1') { + // V1: Use the complete URL directly from the response + return data.output_file_url; + } else { + // V2: Combine the endpoint with the relative path + return `${this.settings.provider_endpoint}${data.output_file_url}`; + } - return outputUrl; } catch (error) { console.error('[fetchTtsGeneration] Exception caught:', error); throw error;