Merge branch 'staging' into chore/lintAndDocumentLogprobs
| @@ -4503,7 +4503,7 @@ | ||
| 4503 | 4503 | </div> |
| 4504 | 4504 | </div> |
| 4505 | 4505 | <div name="AutoCompleteToggle" class="inline-drawer wide100p flexFlowColumn"> |
| 4506 | 4506 | <div class="inline-drawer-toggle inline-drawer-header userSettingsInnerExpandable" title="Options for the various autocompelteautocomplete input boxes."> |
| 4507 | 4507 | <b><span data-i18n="AutoComplete Settings">AutoComplete Settings</span></b> |
| 4508 | 4508 | <div class="fa-solid fa-circle-chevron-down inline-drawer-icon down"></div> |
| 4509 | 4509 | </div> |
| @@ -5233,19 +5233,19 @@ | ||
| 5233 | 5233 | <span class="ch_name flex1"></span> |
| 5234 | 5234 | <div class="avatar-buttons"> |
| 5235 | 5235 | <button class="menu_button bind_user_name" title="Bind user name to that avatar" data-i18n="[title]Bind user name to that avatar"> |
| 5236 | 5236 | <i class="fa-fw fa-solid fa-user-edit fa-sm"></i> |
| 5237 | 5237 | </button> |
| 5238 | 5238 | <button class="menu_button set_persona_image" title="Change persona image" data-i18n="[title]Change persona image"> |
| 5239 | 5239 | <i class="fa-fw fa-solid fa-image fa-sm"></i> |
| 5240 | 5240 | </button> |
| 5241 | 5241 | <button class="menu_button set_default_persona" title="Select this as default persona for the new chats." data-i18n="[title]Select this as default persona for the new chats."> |
| 5242 | 5242 | <i class="fa-fw fa-solid fa-crown fa-sm"></i> |
| 5243 | 5243 | </button> |
| 5244 | 5244 | <button class="menu_button duplicate_persona" title="Duplicate persona" data-i18n="[title]Duplicate persona"> |
| 5245 | 5245 | <i class="fa-fw fa-solid fa-clone fa-sm"></i> |
| 5246 | 5246 | </button> |
| 5247 | 5247 | <button class="menu_button delete_avatar" title="Delete persona" data-i18n="[title]Delete persona"> |
| 5248 | 5248 | <i class="fa-fw fa-solid fa-trash-alt fa-sm"></i> |
| 5249 | 5249 | </button> |
| 5250 | 5250 | </div> |
| 5251 | 5251 | </div> |
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | import { doExtrasFetch } from '../../extensions.js'; |
| 2 | +import { debounce } from '../../utils.js'; | |
| 2 | 3 | import { saveTtsProviderSettings } from './index.js'; |
| 3 | 4 | |
| 4 | 5 | export { AllTalkTtsProvider }; |
| @@ -13,12 +14,17 @@ class AllTalkTtsProvider { | ||
| 13 | 14 | // Initialize with default settings if they are not already set |
| 14 | 15 | this.settings = { |
| 15 | 16 | provider_endpoint: this.settings.provider_endpoint || 'http://localhost:7851', |
| 17 | + server_version: this.settings.server_version || 'v2', | |
| 16 | 18 | language: this.settings.language || 'en', |
| 17 | 19 | voiceMap: this.settings.voiceMap || {}, |
| 18 | 20 | at_generation_method: this.settings.at_generation_method || 'standard_generation', |
| 19 | 21 | narrator_enabled: this.settings.narrator_enabled || 'false', |
| 20 | 22 | at_narrator_text_not_inside: this.settings.at_narrator_text_not_inside || 'narrator', |
| 21 | 23 | narrator_voice_gen: this.settings.narrator_voice_gen || 'female_01.wavPlease set a voice', |
| 24 | + rvc_character_voice: this.settings.rvc_character_voice || 'Disabled', | |
| 25 | + rvc_character_pitch: this.settings.rvc_character_pitch || '0', | |
| 26 | + rvc_narrator_voice: this.settings.rvc_narrator_voice || 'Disabled', | |
| 27 | + rvc_narrator_pitch: this.settings.rvc_narrator_pitch || '0', | |
| 22 | 28 | finetuned_model: this.settings.finetuned_model || 'false', |
| 23 | 29 | }; |
| 24 | 30 | // Separate property for dynamically updated settings from the server |
| @@ -26,9 +32,11 @@ class AllTalkTtsProvider { | ||
| 26 | 32 | modelsAvailable: [], |
| 27 | 33 | currentModel: '', |
| 28 | 34 | deepspeed_available: false, |
| 29 | 35 | deepSpeedEnableddeepspeed_enabled: false, |
| 30 | 36 | lowVramEnabledlowvram_capable: false, |
| 37 | + lowvram_enabled: false, | |
| 31 | 38 | }; |
| 39 | + this.rvcVoices = []; // Initialize rvcVoices as an empty array | |
| 32 | 40 | } |
| 33 | 41 | ready = false; |
| 34 | 42 | voices = []; |
| @@ -56,113 +64,162 @@ class AllTalkTtsProvider { | ||
| 56 | 64 | }; |
| 57 | 65 | |
| 58 | 66 | get settingsHtml() { |
| 59 | - let html = '<div class="at-settings-separator">AllTalk Settings</div>'; | |
| 67 | + // HTML template literals can trigger ESLint quotes warnings when quotes are used in HTML attributes. | |
| 60 | - | |
| 68 | + // Disabling quotes rule for this one line as it's a false positive with HTML template literals. | |
| 61 | - html += `<div class="at-settings-row"> | |
| 69 | + // eslint-disable-next-line quotes | |
| 62 | - | |
| 70 | + let html = `<div class="at-settings-separator">AllTalk V2 Settings</div>`; | |
| 63 | - <div class="at-settings-option"> | |
| 71 | + | |
| 64 | - <label for="at_generation_method">AllTalk TTS Generation Method</label> | |
| 72 | + html += `<div class='at-settings-row'> | |
| 65 | - <select id="at_generation_method"> | |
| 73 | + <div class='at-settings-option'> | |
| 66 | - <option value="standard_generation">Standard Audio Generation (AT Narrator - Optional)</option> | |
| 74 | + <label for='at_generation_method'>AllTalk TTS Generation Method</label> | |
| 67 | - <option value="streaming_enabled">Streaming Audio Generation (AT Narrator - Disabled)</option> | |
| 75 | + <select id='at_generation_method'> | |
| 76 | + <option value='standard_generation'>Standard Audio Generation (AT Narrator - Optional)</option> | |
| 77 | + <option value='streaming_enabled'>Streaming Audio Generation (AT Narrator - Disabled)</option> | |
| 68 | 78 | </select> |
| 69 | 79 | </div> |
| 70 | 80 | </div>`; |
| 71 | 81 | |
| 72 | 82 | html += `<div class="'at-settings-row"'> |
| 73 | - | |
| 83 | + <div class='at-settings-option'> | |
| 74 | - <div class="at-settings-option"> | |
| 84 | + <label for='at_narrator_enabled'>AT Narrator</label> | |
| 75 | - <label for="at_narrator_enabled">AT Narrator</label> | |
| 85 | + <select id='at_narrator_enabled'> | |
| 76 | - <select id="at_narrator_enabled"> | |
| 86 | + <option value='true'>Enabled</option> | |
| 77 | 87 | <option value="true"'silent'>Enabled (Silenced)</option> |
| 78 | 88 | <option value="'false"'>Disabled</option> |
| 79 | 89 | </select> |
| 80 | 90 | </div> |
| 81 | 91 | |
| 82 | 92 | <div class="'at-settings-option"'> |
| 83 | 93 | <label for="'at_narrator_text_not_inside"'>Text Not Inside * or " is</label> |
| 84 | 94 | <select id="'at_narrator_text_not_inside"'> |
| 85 | 95 | <option value="narrator"'character'>NarratorCharacter</option> |
| 86 | 96 | <option value="character"'narrator'>CharacterNarrator</option> |
| 97 | + <option value='silent'>Silent</option> | |
| 87 | 98 | </select> |
| 88 | 99 | </div> |
| 89 | - | |
| 90 | 100 | </div>`; |
| 91 | 101 | |
| 92 | 102 | html += `<div class="'at-settings-row"'> |
| 93 | 103 | <div class="'at-settings-option"'> |
| 94 | 104 | <label for="'narrator_voice"'>Narrator Voice</label> |
| 95 | 105 | <select id="'narrator_voice"'>`; |
| 96 | 106 | if (this.voices) { |
| 97 | 107 | for (let voice of this.voices) { |
| 98 | 108 | html += `<option value="'${voice.voice_id}"'>${voice.name}</option>`; |
| 99 | 109 | } |
| 100 | 110 | } |
| 101 | 111 | html += `</select> |
| 102 | 112 | </div> |
| 103 | 113 | <div class="'at-settings-option"'> |
| 104 | 114 | <label for="'language_options"'>Language</label> |
| 105 | 115 | <select id="'language_options"'>`; |
| 106 | 116 | for (let language in this.languageLabels) { |
| 107 | 117 | html += `<option value="'${this.languageLabels[language]}"' ${this.languageLabels[language] === this.settings?.language ? 'selected="selected"' : ''}>${language}</option>`; |
| 108 | 118 | } |
| 109 | 119 | html += `</select> |
| 110 | 120 | </div> |
| 111 | 121 | </div>`; |
| 112 | 122 | |
| 123 | + html += `<div class='at-settings-row'> | |
| 124 | + <div class='at-settings-option'> | |
| 125 | + <label for='rvc_character_voice'>RVC Character</label> | |
| 126 | + <select id='rvc_character_voice'>`; | |
| 127 | + if (this.rvcVoices) { | |
| 128 | + for (let rvccharvoice of this.rvcVoices) { | |
| 129 | + html += `<option value='${rvccharvoice.voice_id}'>${rvccharvoice.name}</option>`; | |
| 130 | + } | |
| 131 | + } | |
| 132 | + html += `</select> | |
| 133 | + </div> | |
| 134 | + <div class='at-settings-option'> | |
| 135 | + <label for='rvc_narrator_voice'>RVC Narrator</label> | |
| 136 | + <select id='rvc_narrator_voice'>`; | |
| 137 | + if (this.rvcVoices) { | |
| 138 | + for (let rvcnarrvoice of this.rvcVoices) { | |
| 139 | + html += `<option value='${rvcnarrvoice.voice_id}'>${rvcnarrvoice.name}</option>`; | |
| 140 | + } | |
| 141 | + } | |
| 142 | + html += `</select> | |
| 143 | + </div> | |
| 144 | +</div>`; | |
| 113 | 145 | |
| 114 | 146 | html += `<div class="'at-model-endpointsettings-row"'> |
| 115 | 147 | <div class="'at-modelsettings-option"'> |
| 116 | 148 | <label for="switch_model"'rvc_character_pitch'>SwitchRVC ModelCharacter Pitch</label> |
| 117 | 149 | <select id="switch_model"'rvc_character_pitch'>`; |
| 118 | - <option value="api_tts">API TTS</option> | |
| 150 | + for (let i = -24; i <= 24; i++) { | |
| 119 | - <option value="api_local">API Local</option> | |
| 151 | + const selected = i === 0 ? 'selected="selected"' : ''; | |
| 120 | - <option value="xttsv2_local">XTTSv2 Local</option> | |
| 152 | + html += `<option value='${i}' ${selected}>${i}</option>`; | |
| 121 | - </select> | |
| 153 | + } | |
| 154 | + html += `</select> | |
| 122 | 155 | </div> |
| 156 | + <div class='at-settings-option'> | |
| 157 | + <label for='rvc_narrator_pitch'>RVC Narrator Pitch</label> | |
| 158 | + <select id='rvc_narrator_pitch'>`; | |
| 159 | + for (let i = -24; i <= 24; i++) { | |
| 160 | + const selected = i === 0 ? 'selected="selected"' : ''; | |
| 161 | + html += `<option value='${i}' ${selected}>${i}</option>`; | |
| 162 | + } | |
| 163 | + html += `</select> | |
| 123 | 164 | </div> |
| 165 | + </div>`; | |
| 124 | 166 | |
| 125 | 167 | html += `<div class="'at-model-endpoint-row"'> |
| 168 | + <div class='at-model-option'> | |
| 169 | + <label for='switch_model'>Switch Model</label> | |
| 170 | + <select id='switch_model'> | |
| 171 | + <!-- Options will be dynamically populated --> | |
| 172 | + </select> | |
| 173 | + </div> | |
| 126 | 174 | |
| 127 | 175 | <div class="'at-endpoint-option"'> |
| 128 | 176 | <label for="'at_server"'>AllTalk Endpoint:</label> |
| 129 | 177 | <input id="'at_server"' type="'text"' class="'text_pole"' maxlength="'80"' value="'${this.settings.provider_endpoint}"'/> |
| 130 | - <i><b>Important:</b> Must match IP address & port in AllTalk settings.</i> | |
| 131 | 178 | </div> |
| 132 | 179 | </div>`; |
| 133 | 180 | |
| 181 | + html += `<div class='at-settings-row'> | |
| 182 | + <div class='at-settings-option'> | |
| 183 | + <label for='server_version'>AllTalk Server Version</label> | |
| 184 | + <select id='server_version'> | |
| 185 | + <option value='v1'>AllTalk V1</option> | |
| 186 | + <option value='v2'>AllTalk V2</option> | |
| 187 | + </select> | |
| 188 | + </div> | |
| 189 | + </div>`; | |
| 134 | 190 | |
| 135 | 191 | html += `<div class="'at-model-endpoint-row"'> |
| 136 | 192 | <div class="'at-settings-option"'> |
| 137 | 193 | <label for="'low_vram"'>Low VRAM</label> |
| 138 | 194 | <input id="'low_vram"' type="'checkbox"'/> |
| 139 | 195 | </div> |
| 140 | 196 | <div class="'at-settings-option"'> |
| 141 | 197 | <label for="'deepspeed"'>DeepSpeed</label> |
| 142 | 198 | <input id="'deepspeed"' type="'checkbox"'/> |
| 143 | 199 | </div> |
| 144 | 200 | <div class="'at-settings-option status-option"'> |
| 145 | 201 | <span>Status: <span id="'status_info"'>Ready</span></span> |
| 146 | 202 | </div> |
| 147 | 203 | <div class="'at-settings-option empty-option"'> |
| 148 | 204 | <!-- This div remains empty for spacing --> |
| 149 | 205 | </div> |
| 150 | 206 | </div>`; |
| 151 | 207 | |
| 152 | - | |
| 208 | + html += `<div class='at-website-row'> | |
| 153 | 209 | html += `<div class="'at-website-row"option'> |
| 154 | - <div class="at-website-option"> | |
| 210 | + <span>AllTalk V2<a target='_blank' href='${this.settings.provider_endpoint}'>Config & Docs</a>.</span> | |
| 155 | - <span>AllTalk <a target="_blank" href="${this.settings.provider_endpoint}">Config & Docs</a>.</span> | |
| 156 | 211 | </div> |
| 157 | 212 | |
| 158 | 213 | <div class="'at-website-option"'> |
| 159 | 214 | <span>AllTalk <a target="'_blank"' href="'https://github.com/erew123/alltalk_tts/"'>Website</a>.</span> |
| 160 | 215 | </div> |
| 161 | 216 | </div>`; |
| 162 | 217 | |
| 163 | 218 | html += `<div class="'at-website-row"'> |
| 164 | 219 | <div class="'at-website-option"'> |
| 165 | -<span><strong>Text-generation-webui</strong> users - Uncheck <strong>Enable TTS</strong> in Text-generation-webui.</span> | |
| 220 | +<span>- If you <strong>change your TTS engine</strong> in AllTalk, you will need to <strong>Reload</strong> (button above) and re-select your voices.</span><br><br> | |
| 221 | +<span>- Assuming the server is <strong>Status: Ready</strong>, most problems will be resolved by hitting Reload and selecting voices that match the loaded TTS engine.</span><br><br> | |
| 222 | +<span>- <strong>Text-generation-webui</strong> users - Uncheck <strong>Enable TTS</strong> in the TGWUI interface, or you will hear 2x voices and file names being generated.</span> | |
| 166 | 223 | </div> |
| 167 | 224 | </div>`; |
| 168 | 225 | |
| @@ -193,25 +250,25 @@ class AllTalkTtsProvider { | ||
| 193 | 250 | // Update UI elements to reflect the loaded settings |
| 194 | 251 | $('#at_server').val(this.settings.provider_endpoint); |
| 195 | 252 | $('#language_options').val(this.settings.language); |
| 196 | - //$('#voicemap').val(this.settings.voiceMap); | |
| 197 | 253 | $('#at_generation_method').val(this.settings.at_generation_method); |
| 198 | 254 | $('#at_narrator_enabled').val(this.settings.narrator_enabled); |
| 199 | 255 | $('#at_narrator_text_not_inside').val(this.settings.at_narrator_text_not_inside); |
| 200 | 256 | $('#narrator_voice').val(this.settings.narrator_voice_gen); |
| 257 | + $('#rvc_character_voice').val(this.settings.rvc_character_voice); | |
| 258 | + $('#rvc_narrator_voice').val(this.settings.rvc_narrator_voice); | |
| 259 | + $('#rvc_character_pitch').val(this.settings.rvc_character_pitch); | |
| 260 | + $('#rvc_narrator_pitch').val(this.settings.rvc_narrator_pitch); | |
| 201 | 261 | |
| 202 | 262 | console.debug('AllTalkTTS: Settings loaded'); |
| 203 | - await this.initEndpoint(); | |
| 204 | - } | |
| 205 | - | |
| 206 | - async initEndpoint() { | |
| 207 | 263 | try { |
| 208 | 264 | // Check if TTS provider is ready |
| 209 | - this.setupEventListeners(); | |
| 210 | - this.updateLanguageDropdown(); | |
| 211 | 265 | await this.checkReady(); |
| 212 | 266 | await this.updateSettingsFromServer(); // Fetch dynamic settings from the TTS server |
| 213 | 267 | await this.fetchTtsVoiceObjects(); // Fetch voices only if service is ready |
| 268 | + await this.fetchRvcVoiceObjects(); // Fetch RVC voices | |
| 214 | 269 | this.updateNarratorVoicesDropdown(); |
| 270 | + this.updateLanguageDropdown(); | |
| 271 | + this.setupEventListeners(); | |
| 215 | 272 | this.applySettingsToHTML(); |
| 216 | 273 | updateStatus('Ready'); |
| 217 | 274 | } catch (error) { |
| @@ -220,8 +277,8 @@ class AllTalkTtsProvider { | ||
| 220 | 277 | } |
| 221 | 278 | } |
| 222 | 279 | |
| 280 | + | |
| 223 | 281 | applySettingsToHTML() { |
| 224 | - // Apply loaded settings or use defaults | |
| 225 | 282 | const narratorVoiceSelect = document.getElementById('narrator_voice'); |
| 226 | 283 | const atNarratorSelect = document.getElementById('at_narrator_enabled'); |
| 227 | 284 | const textNotInsideSelect = document.getElementById('at_narrator_text_not_inside'); |
| @@ -229,30 +286,26 @@ class AllTalkTtsProvider { | ||
| 229 | 286 | this.settings.narrator_voice = this.settings.narrator_voice_gen; |
| 230 | 287 | // Apply settings to Narrator Voice dropdown |
| 231 | 288 | if (narratorVoiceSelect && this.settings.narrator_voice) { |
| 232 | 289 | narratorVoiceSelect.value = this.settings.narrator_voice.replace('.wav', ''); // Remove the parentheses |
| 233 | 290 | } |
| 234 | 291 | // Apply settings to AT Narrator Enabled dropdown |
| 235 | 292 | if (atNarratorSelect) { |
| 236 | - // Sync the state with the checkbox in index.js | |
| 293 | + const ttsPassAsterisksCheckbox = document.getElementById('tts_pass_asterisks'); | |
| 237 | 294 | const ttsPassAsterisksCheckboxttsNarrateQuotedCheckbox = document.getElementById('tts_pass_asteriskstts_narrate_quoted'); // Access the checkbox from index.js |
| 238 | 295 | const ttsNarrateQuotedCheckboxttsNarrateDialoguesCheckbox = document.getElementById('tts_narrate_quotedtts_narrate_dialogues'); // Access the checkbox from index.js |
| 239 | - const ttsNarrateDialoguesCheckbox = document.getElementById('tts_narrate_dialogues'); // Access the checkbox from index.js | |
| 240 | - // Sync the state with the checkbox in index.js | |
| 241 | 296 | if (this.settings.narrator_enabled) { |
| 242 | 297 | ttsPassAsterisksCheckbox.checked = false; |
| 243 | 298 | $('#tts_pass_asterisks').click(); // Simulate a click event |
| 244 | 299 | $('#tts_pass_asterisks').trigger('change'); |
| 245 | 300 | } |
| 246 | 301 | if (!this.settings.narrator_enabled) { |
| 247 | 302 | ttsPassAsterisksCheckbox.checked = true; |
| 248 | 303 | $('#tts_pass_asterisks').click(); // Simulate a click event |
| 249 | 304 | $('#tts_pass_asterisks').trigger('change'); |
| 250 | 305 | } |
| 251 | - // Uncheck and set tts_narrate_quoted to false if narrator is enabled | |
| 306 | + if (this.settings.narrator_enabled) { | |
| 252 | - if (this.settings.narrator_enabledd) { | |
| 253 | 307 | ttsNarrateQuotedCheckbox.checked = true; |
| 254 | 308 | ttsNarrateDialoguesCheckbox.checked = true; |
| 255 | - // Trigger click events instead of change events | |
| 256 | 309 | $('#tts_narrate_quoted').click(); |
| 257 | 310 | $('#tts_narrate_quoted').trigger('change'); |
| 258 | 311 | $('#tts_narrate_dialogues').click(); |
| @@ -261,42 +314,30 @@ class AllTalkTtsProvider { | ||
| 261 | 314 | atNarratorSelect.value = this.settings.narrator_enabled.toString(); |
| 262 | 315 | this.settings.narrator_enabled = this.settings.narrator_enabled.toString(); |
| 263 | 316 | } |
| 264 | - // Apply settings to the Language dropdown | |
| 265 | 317 | const languageSelect = document.getElementById('language_options'); |
| 266 | 318 | if (languageSelect && this.settings.language) { |
| 267 | 319 | languageSelect.value = this.settings.language; |
| 268 | 320 | } |
| 269 | - // Apply settings to Text Not Inside dropdown | |
| 270 | 321 | if (textNotInsideSelect && this.settings.text_not_inside) { |
| 271 | 322 | textNotInsideSelect.value = this.settings.text_not_inside; |
| 272 | 323 | this.settings.at_narrator_text_not_inside = this.settings.text_not_inside; |
| 273 | 324 | } |
| 274 | - // Apply settings to Generation Method dropdown | |
| 275 | 325 | if (generationMethodSelect && this.settings.at_generation_method) { |
| 276 | 326 | generationMethodSelect.value = this.settings.at_generation_method; |
| 277 | 327 | } |
| 278 | - // Additional logic to disable/enable dropdowns based on the selected generation method | |
| 279 | 328 | const isStreamingEnabled = this.settings.at_generation_method === 'streaming_enabled'; |
| 280 | 329 | if (isStreamingEnabled) { |
| 281 | - // Disable certain dropdowns when streaming is enabled | |
| 282 | 330 | if (atNarratorSelect) atNarratorSelect.disabled = true; |
| 283 | 331 | if (textNotInsideSelect) textNotInsideSelect.disabled = true; |
| 284 | 332 | if (narratorVoiceSelect) narratorVoiceSelect.disabled = true; |
| 285 | 333 | } else { |
| 286 | - // Enable dropdowns for standard generation | |
| 287 | 334 | if (atNarratorSelect) atNarratorSelect.disabled = false; |
| 288 | 335 | if (textNotInsideSelect) textNotInsideSelect.disabled = !this.settings.narrator_enabled; |
| 289 | 336 | if (narratorVoiceSelect) narratorVoiceSelect.disabled = !this.settings.narrator_enabled; |
| 290 | 337 | } |
| 291 | - const modelSelect = document.getElementById('switch_model'); | |
| 292 | - if (this.settings.finetuned_model === 'true') { | |
| 293 | - const ftOption = document.createElement('option'); | |
| 294 | - ftOption.value = 'XTTSv2 FT'; | |
| 295 | - ftOption.textContent = 'XTTSv2 FT'; | |
| 296 | - modelSelect.appendChild(ftOption); | |
| 297 | - } | |
| 298 | 338 | } |
| 299 | 339 | |
| 340 | + | |
| 300 | 341 | //##############################// |
| 301 | 342 | // Check AT Server is Available // |
| 302 | 343 | //##############################// |
| @@ -320,7 +361,6 @@ class AllTalkTtsProvider { | ||
| 320 | 361 | } catch (error) { |
| 321 | 362 | console.error('Error checking TTS service readiness:', error); |
| 322 | 363 | this.ready = false; // Ensure ready flag is set to false in case of error |
| 323 | - throw error; // Rethrow the error for further handling | |
| 324 | 364 | } |
| 325 | 365 | } |
| 326 | 366 | |
| @@ -336,10 +376,9 @@ class AllTalkTtsProvider { | ||
| 336 | 376 | } |
| 337 | 377 | const data = await response.json(); |
| 338 | 378 | const voices = data.voices.map(filename => { |
| 339 | - const voiceName = filename.replace('.wav', ''); | |
| 340 | 379 | return { |
| 341 | 380 | name: voiceNamefilename, |
| 342 | 381 | voice_id: voiceNamefilename, |
| 343 | 382 | preview_url: null, // Preview URL will be dynamically generated |
| 344 | 383 | lang: 'en', // Default language |
| 345 | 384 | }; |
| @@ -348,33 +387,138 @@ class AllTalkTtsProvider { | ||
| 348 | 387 | return voices; // Also return this list |
| 349 | 388 | } |
| 350 | 389 | |
| 390 | + async fetchRvcVoiceObjects() { | |
| 391 | + if (this.settings.server_version !== 'v2') { | |
| 392 | + console.log('Skipping RVC voices fetch for V1 server'); | |
| 393 | + return []; | |
| 394 | + } | |
| 395 | + | |
| 396 | + console.log('Fetching RVC Voices'); | |
| 397 | + try { | |
| 398 | + const response = await fetch(`${this.settings.provider_endpoint}/api/rvcvoices`); | |
| 399 | + if (!response.ok) { | |
| 400 | + const errorText = await response.text(); | |
| 401 | + console.error('Error text:', errorText); | |
| 402 | + throw new Error(`HTTP ${response.status}: ${errorText}`); | |
| 403 | + } | |
| 404 | + | |
| 405 | + const data = await response.json(); | |
| 406 | + if (!data || !data.rvcvoices) { | |
| 407 | + console.error('Invalid data format:', data); | |
| 408 | + throw new Error('Invalid data format received from /api/rvcvoices'); | |
| 409 | + } | |
| 410 | + | |
| 411 | + const voices = data.rvcvoices.map(filename => { | |
| 412 | + return { | |
| 413 | + name: filename, | |
| 414 | + voice_id: filename, | |
| 415 | + }; | |
| 416 | + }); | |
| 417 | + | |
| 418 | + console.log('RVC voices:', voices); | |
| 419 | + this.rvcVoices = voices; // Assign to the class property | |
| 420 | + this.updateRvcVoiceDropdowns(); // Update UI after fetching voices | |
| 421 | + return voices; // Also return this list | |
| 422 | + } catch (error) { | |
| 423 | + console.error('Error fetching RVC voices:', error); | |
| 424 | + this.rvcVoices = [{ name: 'Disabled', voice_id: 'Disabled' }]; // Set default on error | |
| 425 | + throw error; | |
| 426 | + } finally { | |
| 427 | + // Ensure dropdowns are updated even if there was an error | |
| 428 | + this.updateRvcVoiceDropdowns(); | |
| 429 | + } | |
| 430 | + } | |
| 431 | + | |
| 351 | 432 | //##########################################// |
| 352 | 433 | // Get Current AT Server Config & Update ST // |
| 353 | 434 | //##########################################// |
| 354 | 435 | |
| 355 | 436 | async updateSettingsFromServer() { |
| 356 | 437 | try { |
| 357 | - // Fetch current settings | |
| 358 | 438 | const response = await fetch(`${this.settings.provider_endpoint}/api/currentsettings`); |
| 359 | 439 | if (!response.ok) { |
| 360 | 440 | throw new Error(`Failed to fetch current settings: ${response.statusText}`); |
| 361 | 441 | } |
| 362 | 442 | const currentSettings = await response.json(); |
| 363 | - // Update internal settings | |
| 443 | + currentSettings.models_available.sort((a, b) => a.name.localeCompare(b.name)); | |
| 444 | + | |
| 445 | + this.settings.enginesAvailable = currentSettings.engines_available; | |
| 446 | + this.settings.currentEngineLoaded = currentSettings.current_engine_loaded; | |
| 364 | 447 | this.settings.modelsAvailable = currentSettings.models_available; |
| 365 | 448 | this.settings.currentModel = currentSettings.current_model_loaded; |
| 449 | + this.settings.deepspeed_capable = currentSettings.deepspeed_capable; | |
| 366 | 450 | this.settings.deepspeed_available = currentSettings.deepspeed_available; |
| 367 | 451 | this.settings.deepSpeedEnableddeepspeed_enabled = currentSettings.deepspeed_statusdeepspeed_enabled; |
| 368 | 452 | this.settings.lowVramEnabledlowvram_capable = currentSettings.low_vram_statuslowvram_capable; |
| 369 | 453 | this.settings.finetuned_modellowvram_enabled = currentSettings.finetuned_modellowvram_enabled; |
| 370 | - // Update HTML elements | |
| 454 | + | |
| 455 | + await this.fetchRvcVoiceObjects(); // Fetch RVC voices | |
| 456 | + | |
| 371 | 457 | this.updateModelDropdown(); |
| 372 | 458 | this.updateCheckboxes(); |
| 459 | + this.updateRvcVoiceDropdowns(); // Update the RVC voice dropdowns | |
| 373 | 460 | } catch (error) { |
| 374 | 461 | console.error(`Error updating settings from server: ${error}`); |
| 375 | 462 | } |
| 376 | 463 | } |
| 377 | 464 | |
| 465 | + updateRvcVoiceDropdowns() { | |
| 466 | + // Handle all RVC-related elements | |
| 467 | + const rvcElements = document.querySelectorAll('.rvc-setting'); | |
| 468 | + const isV2 = this.settings.server_version === 'v2'; | |
| 469 | + | |
| 470 | + rvcElements.forEach(element => { | |
| 471 | + element.style.display = isV2 ? 'block' : 'none'; | |
| 472 | + }); | |
| 473 | + | |
| 474 | + // Update and disable/enable character voice dropdown | |
| 475 | + const rvcCharacterVoiceSelect = document.getElementById('rvc_character_voice'); | |
| 476 | + if (rvcCharacterVoiceSelect) { | |
| 477 | + rvcCharacterVoiceSelect.disabled = !isV2; | |
| 478 | + if (this.rvcVoices) { | |
| 479 | + rvcCharacterVoiceSelect.innerHTML = ''; | |
| 480 | + for (let voice of this.rvcVoices) { | |
| 481 | + const option = document.createElement('option'); | |
| 482 | + option.value = voice.voice_id; | |
| 483 | + option.textContent = voice.name; | |
| 484 | + if (voice.voice_id === this.settings.rvc_character_voice) { | |
| 485 | + option.selected = true; | |
| 486 | + } | |
| 487 | + rvcCharacterVoiceSelect.appendChild(option); | |
| 488 | + } | |
| 489 | + } | |
| 490 | + } | |
| 491 | + | |
| 492 | + // Update and disable/enable narrator voice dropdown | |
| 493 | + const rvcNarratorVoiceSelect = document.getElementById('rvc_narrator_voice'); | |
| 494 | + if (rvcNarratorVoiceSelect) { | |
| 495 | + rvcNarratorVoiceSelect.disabled = !isV2; | |
| 496 | + if (this.rvcVoices) { | |
| 497 | + rvcNarratorVoiceSelect.innerHTML = ''; | |
| 498 | + for (let voice of this.rvcVoices) { | |
| 499 | + const option = document.createElement('option'); | |
| 500 | + option.value = voice.voice_id; | |
| 501 | + option.textContent = voice.name; | |
| 502 | + if (voice.voice_id === this.settings.rvc_narrator_voice) { | |
| 503 | + option.selected = true; | |
| 504 | + } | |
| 505 | + rvcNarratorVoiceSelect.appendChild(option); | |
| 506 | + } | |
| 507 | + } | |
| 508 | + } | |
| 509 | + | |
| 510 | + // Update pitch inputs | |
| 511 | + const characterPitch = document.getElementById('rvc_character_pitch'); | |
| 512 | + if (characterPitch) { | |
| 513 | + characterPitch.disabled = !isV2; | |
| 514 | + } | |
| 515 | + | |
| 516 | + const narratorPitch = document.getElementById('rvc_narrator_pitch'); | |
| 517 | + if (narratorPitch) { | |
| 518 | + narratorPitch.disabled = !isV2; | |
| 519 | + } | |
| 520 | + } | |
| 521 | + | |
| 378 | 522 | //###################################################// |
| 379 | 523 | // Get Current AT Server Config & Update ST (Models) // |
| 380 | 524 | //###################################################// |
| @@ -385,9 +529,9 @@ class AllTalkTtsProvider { | ||
| 385 | 529 | modelSelect.innerHTML = ''; // Clear existing options |
| 386 | 530 | this.settings.modelsAvailable.forEach(model => { |
| 387 | 531 | const option = document.createElement('option'); |
| 388 | 532 | option.value = model.model_namename; |
| 389 | 533 | option.textContent = model.model_namename; // Use model_name instead ofmodel name directly |
| 390 | 534 | option.selected = model.model_namename === this.settings.currentModel; |
| 391 | 535 | modelSelect.appendChild(option); |
| 392 | 536 | }); |
| 393 | 537 | } |
| @@ -400,13 +544,36 @@ class AllTalkTtsProvider { | ||
| 400 | 544 | updateCheckboxes() { |
| 401 | 545 | const deepspeedCheckbox = document.getElementById('deepspeed'); |
| 402 | 546 | const lowVramCheckbox = document.getElementById('low_vram'); |
| 403 | - if (lowVramCheckbox) lowVramCheckbox.checked = this.settings.lowVramEnabled; | |
| 547 | + | |
| 548 | + // Handle DeepSpeed checkbox | |
| 404 | 549 | if (deepspeedCheckbox) { |
| 405 | - deepspeedCheckbox.checked = this.settings.deepSpeedEnabled; | |
| 550 | + if (this.settings.deepspeed_capable) { | |
| 406 | - deepspeedCheckbox.disabled = !this.settings.deepspeed_available; // Disable checkbox if deepspeed is not available | |
| 551 | + // If TTS engine is capable of using DeepSpeed | |
| 552 | + deepspeedCheckbox.disabled = !this.settings.deepspeed_available; | |
| 553 | + this.settings.deepspeed_enabled = this.settings.deepspeed_available && this.settings.deepspeed_enabled; | |
| 554 | + } else { | |
| 555 | + // If TTS engine is NOT capable of using DeepSpeed | |
| 556 | + deepspeedCheckbox.disabled = true; | |
| 557 | + this.settings.deepspeed_enabled = false; | |
| 558 | + } | |
| 559 | + deepspeedCheckbox.checked = this.settings.deepspeed_enabled; | |
| 560 | + } | |
| 561 | + | |
| 562 | + // Handle Low VRAM checkbox | |
| 563 | + if (lowVramCheckbox) { | |
| 564 | + if (this.settings.lowvram_capable) { | |
| 565 | + // If TTS engine is capable of low VRAM | |
| 566 | + lowVramCheckbox.disabled = false; | |
| 567 | + } else { | |
| 568 | + // If TTS engine is NOT capable of low VRAM | |
| 569 | + lowVramCheckbox.disabled = true; | |
| 570 | + this.settings.lowvram_enabled = false; | |
| 571 | + } | |
| 572 | + lowVramCheckbox.checked = this.settings.lowvram_enabled; | |
| 407 | 573 | } |
| 408 | 574 | } |
| 409 | 575 | |
| 576 | + | |
| 410 | 577 | //###############################################################// |
| 411 | 578 | // Get Current AT Server Config & Update ST (AT Narrator Voices) // |
| 412 | 579 | //###############################################################// |
| @@ -433,8 +600,8 @@ class AllTalkTtsProvider { | ||
| 433 | 600 | updateLanguageDropdown() { |
| 434 | 601 | const languageSelect = document.getElementById('language_options'); |
| 435 | 602 | if (languageSelect) { |
| 436 | 603 | // Ensure default language is set (??? whatever that means) |
| 437 | 604 | // this.settings.language = this.settings.language || 'en'; |
| 438 | 605 | |
| 439 | 606 | languageSelect.innerHTML = ''; |
| 440 | 607 | for (let language in this.languageLabels) { |
| @@ -454,16 +621,11 @@ class AllTalkTtsProvider { | ||
| 454 | 621 | //########################################// |
| 455 | 622 | |
| 456 | 623 | setupEventListeners() { |
| 457 | - | |
| 458 | - let debounceTimeout; | |
| 459 | - const debounceDelay = 500; // Milliseconds | |
| 460 | - | |
| 461 | 624 | // Define the event handler function |
| 462 | 625 | const onModelSelectChange = async (event) => { |
| 463 | 626 | console.log('Model select change event triggered'); // Debugging statement |
| 464 | 627 | const selectedModel = event.target.value; |
| 465 | 628 | console.log(`Selected model: ${selectedModel}`); // Debugging statement |
| 466 | - // Set status to Processing | |
| 467 | 629 | updateStatus('Processing'); |
| 468 | 630 | try { |
| 469 | 631 | const response = await fetch(`${this.settings.provider_endpoint}/api/reload?tts_method=${encodeURIComponent(selectedModel)}`, { |
| @@ -473,39 +635,72 @@ class AllTalkTtsProvider { | ||
| 473 | 635 | throw new Error(`HTTP Error: ${response.status}`); |
| 474 | 636 | } |
| 475 | 637 | const data = await response.json(); |
| 476 | 638 | console.log('POST response data:', data); // Debugging statement |
| 477 | - // Set status to Ready if successful | |
| 478 | 639 | updateStatus('Ready'); |
| 479 | 640 | } catch (error) { |
| 480 | 641 | console.error('POST request error:', error); // Debugging statement |
| 481 | - // Set status to Error in case of failure | |
| 482 | 642 | updateStatus('Error'); |
| 483 | 643 | } |
| 484 | - | |
| 485 | - // Handle response or error | |
| 486 | - }; | |
| 487 | - | |
| 488 | - const debouncedModelSelectChange = (event) => { | |
| 489 | - clearTimeout(debounceTimeout); | |
| 490 | - debounceTimeout = setTimeout(() => { | |
| 491 | - onModelSelectChange(event); | |
| 492 | - }, debounceDelay); | |
| 493 | 644 | }; |
| 494 | 645 | |
| 495 | 646 | // Switch Model Listener with debounce |
| 496 | 647 | const modelSelect = document.getElementById('switch_model'); |
| 497 | 648 | if (modelSelect) { |
| 498 | - // Remove the event listener if it was previously added | |
| 649 | + const debouncedModelSelectChange = debounce(onModelSelectChange, 1400); | |
| 499 | - // Add the debounced event listener | |
| 650 | + modelSelect.addEventListener('change', debouncedModelSelectChange); | |
| 500 | - $(modelSelect).off('change').on('change', debouncedModelSelectChange); | |
| 651 | + } | |
| 652 | + | |
| 653 | + // AllTalk Server version change listener | |
| 654 | + const serverVersionSelect = document.getElementById('server_version'); | |
| 655 | + if (serverVersionSelect) { | |
| 656 | + serverVersionSelect.addEventListener('change', async (event) => { | |
| 657 | + this.settings.server_version = event.target.value; | |
| 658 | + if (event.target.value === 'v2') { | |
| 659 | + await this.fetchRvcVoiceObjects(); | |
| 660 | + } | |
| 661 | + this.updateRvcVoiceDropdowns(); | |
| 662 | + this.onSettingsChange(); | |
| 663 | + }); | |
| 664 | + } | |
| 665 | + | |
| 666 | + // RVC Voice and Pitch listeners | |
| 667 | + const rvcCharacterVoiceSelect = document.getElementById('rvc_character_voice'); | |
| 668 | + if (rvcCharacterVoiceSelect) { | |
| 669 | + rvcCharacterVoiceSelect.addEventListener('change', (event) => { | |
| 670 | + this.settings.rvccharacter_voice_gen = event.target.value; | |
| 671 | + this.onSettingsChange(); | |
| 672 | + }); | |
| 673 | + } | |
| 674 | + | |
| 675 | + const rvcNarratorVoiceSelect = document.getElementById('rvc_narrator_voice'); | |
| 676 | + if (rvcNarratorVoiceSelect) { | |
| 677 | + rvcNarratorVoiceSelect.addEventListener('change', (event) => { | |
| 678 | + this.settings.rvcnarrator_voice_gen = event.target.value; | |
| 679 | + this.onSettingsChange(); | |
| 680 | + }); | |
| 681 | + } | |
| 682 | + | |
| 683 | + const rvcCharacterPitchSelect = document.getElementById('rvc_character_pitch'); | |
| 684 | + if (rvcCharacterPitchSelect) { | |
| 685 | + rvcCharacterPitchSelect.addEventListener('change', (event) => { | |
| 686 | + this.settings.rvc_character_pitch = event.target.value; | |
| 687 | + this.onSettingsChange(); | |
| 688 | + }); | |
| 689 | + } | |
| 690 | + | |
| 691 | + const rvcNarratorPitchSelect = document.getElementById('rvc_narrator_pitch'); | |
| 692 | + if (rvcNarratorPitchSelect) { | |
| 693 | + rvcNarratorPitchSelect.addEventListener('change', (event) => { | |
| 694 | + this.settings.rvc_narrator_pitch = event.target.value; | |
| 695 | + this.onSettingsChange(); | |
| 696 | + }); | |
| 501 | 697 | } |
| 502 | 698 | |
| 503 | 699 | // DeepSpeed Listener |
| 504 | 700 | const deepspeedCheckbox = document.getElementById('deepspeed'); |
| 505 | 701 | if (deepspeedCheckbox) { |
| 506 | 702 | $(deepspeedCheckbox).off('change').on('change',const handleDeepSpeedChange = async (event) => { |
| 507 | 703 | const deepSpeedValue = event.target.checked ? 'True' : 'False'; |
| 508 | - // Set status to Processing | |
| 509 | 704 | updateStatus('Processing'); |
| 510 | 705 | try { |
| 511 | 706 | const response = await fetch(`${this.settings.provider_endpoint}/api/deepspeed?new_deepspeed_value=${deepSpeedValue}`, { |
| @@ -515,23 +710,23 @@ class AllTalkTtsProvider { | ||
| 515 | 710 | throw new Error(`HTTP Error: ${response.status}`); |
| 516 | 711 | } |
| 517 | 712 | const data = await response.json(); |
| 518 | 713 | console.log('POST response data:', data); // Debugging statement |
| 519 | - // Set status to Ready if successful | |
| 520 | 714 | updateStatus('Ready'); |
| 521 | 715 | } catch (error) { |
| 522 | 716 | console.error('POST request error:', error); // Debugging statement |
| 523 | - // Set status to Error in case of failure | |
| 524 | 717 | updateStatus('Error'); |
| 525 | 718 | } |
| 526 | 719 | }); |
| 720 | + | |
| 721 | + const debouncedHandleDeepSpeedChange = debounce(handleDeepSpeedChange, 300); | |
| 722 | + deepspeedCheckbox.addEventListener('change', debouncedHandleDeepSpeedChange); | |
| 527 | 723 | } |
| 528 | 724 | |
| 529 | 725 | // Low VRAM Listener |
| 530 | 726 | const lowVramCheckbox = document.getElementById('low_vram'); |
| 531 | 727 | if (lowVramCheckbox) { |
| 532 | 728 | $(lowVramCheckbox).off('change').on('change',const handleLowVramChange = async (event) => { |
| 533 | 729 | const lowVramValue = event.target.checked ? 'True' : 'False'; |
| 534 | - // Set status to Processing | |
| 535 | 730 | updateStatus('Processing'); |
| 536 | 731 | try { |
| 537 | 732 | const response = await fetch(`${this.settings.provider_endpoint}/api/lowvramsetting?new_low_vram_value=${lowVramValue}`, { |
| @@ -541,113 +736,112 @@ class AllTalkTtsProvider { | ||
| 541 | 736 | throw new Error(`HTTP Error: ${response.status}`); |
| 542 | 737 | } |
| 543 | 738 | const data = await response.json(); |
| 544 | 739 | console.log('POST response data:', data); // Debugging statement |
| 545 | - // Set status to Ready if successful | |
| 546 | 740 | updateStatus('Ready'); |
| 547 | 741 | } catch (error) { |
| 548 | 742 | console.error('POST request error:', error); // Debugging statement |
| 549 | - // Set status to Error in case of failure | |
| 550 | 743 | updateStatus('Error'); |
| 551 | 744 | } |
| 552 | 745 | }); |
| 746 | + | |
| 747 | + const debouncedHandleLowVramChange = debounce(handleLowVramChange, 300); | |
| 748 | + lowVramCheckbox.addEventListener('change', debouncedHandleLowVramChange); | |
| 553 | 749 | } |
| 554 | 750 | |
| 555 | - // Narrator Voice Dropdown Listener | |
| 751 | + // Other listeners without debounce since they don't need it | |
| 556 | 752 | const narratorVoiceSelect = document.getElementById('narrator_voice'); |
| 557 | 753 | if (narratorVoiceSelect) { |
| 558 | 754 | $(narratorVoiceSelect).off('change').onaddEventListener('change', (event) => { |
| 559 | 755 | this.settings.narrator_voice_gen = `${event.target.value}.wav`; |
| 560 | 756 | this.onSettingsChange(); // Save the settings after change |
| 561 | 757 | }); |
| 562 | 758 | } |
| 563 | 759 | |
| 564 | 760 | const textNotInsideSelect = document.getElementById('at_narrator_text_not_inside'); |
| 565 | 761 | if (textNotInsideSelect) { |
| 566 | 762 | $(textNotInsideSelect).off('change').onaddEventListener('change', (event) => { |
| 567 | 763 | this.settings.text_not_inside = event.target.value; |
| 568 | 764 | this.onSettingsChange(); // Save the settings after change |
| 569 | 765 | }); |
| 570 | 766 | } |
| 571 | 767 | |
| 572 | 768 | // AT Narrator Dropdown Listener |
| 573 | 769 | const atNarratorSelect = document.getElementById('at_narrator_enabled'); |
| 574 | 770 | const ttsPassAsterisksCheckbox = document.getElementById('tts_pass_asterisks'); // Access the checkbox from index.js |
| 575 | 771 | const ttsNarrateQuotedCheckbox = document.getElementById('tts_narrate_quoted'); // Access the checkbox from index.js |
| 576 | 772 | const ttsNarrateDialoguesCheckbox = document.getElementById('tts_narrate_dialogues'); // Access the checkbox from index.js |
| 577 | 773 | |
| 578 | 774 | if (atNarratorSelect && textNotInsideSelect && narratorVoiceSelect) { |
| 579 | 775 | $(atNarratorSelect).off('change').onaddEventListener('change', (event) => { |
| 580 | 776 | const isNarratorEnablednarratorOption = event.target.value === 'true'; |
| 581 | 777 | this.settings.narrator_enabled = isNarratorEnablednarratorOption; // Update the setting here |
| 582 | - textNotInsideSelect.disabled = !isNarratorEnabled; | |
| 778 | + | |
| 583 | - narratorVoiceSelect.disabled = !isNarratorEnabled; | |
| 779 | + const isNarratorDisabled = narratorOption === 'false'; | |
| 584 | - | |
| 780 | + textNotInsideSelect.disabled = isNarratorDisabled; | |
| 585 | - // Sync the state with the checkbox in index.js | |
| 781 | + narratorVoiceSelect.disabled = isNarratorDisabled; | |
| 586 | - if (isNarratorEnabled) { | |
| 782 | + | |
| 783 | + if (narratorOption === 'true') { | |
| 587 | 784 | ttsPassAsterisksCheckbox.checked = false; |
| 588 | 785 | $('#tts_pass_asterisks').click(); // Simulate a click event |
| 589 | 786 | $('#tts_pass_asterisks').trigger('change'); |
| 590 | - } | |
| 591 | - if (!isNarratorEnabled) { | |
| 592 | - ttsPassAsterisksCheckbox.checked = true; | |
| 593 | - $('#tts_pass_asterisks').click(); // Simulate a click event | |
| 594 | - $('#tts_pass_asterisks').trigger('change'); | |
| 595 | - } | |
| 596 | - // Uncheck and set tts_narrate_quoted to false if narrator is enabled | |
| 597 | - if (isNarratorEnabled) { | |
| 598 | 787 | ttsNarrateQuotedCheckbox.checked = true; |
| 599 | 788 | ttsNarrateDialoguesCheckbox.checked = true; |
| 600 | - // Trigger click events instead of change events | |
| 601 | 789 | $('#tts_narrate_quoted').click(); |
| 602 | 790 | $('#tts_narrate_quoted').trigger('change'); |
| 603 | 791 | $('#tts_narrate_dialogues').click(); |
| 604 | 792 | $('#tts_narrate_dialogues').trigger('change'); |
| 793 | + } else if (narratorOption === 'silent') { | |
| 794 | + ttsPassAsterisksCheckbox.checked = false; | |
| 795 | + $('#tts_pass_asterisks').click(); | |
| 796 | + $('#tts_pass_asterisks').trigger('change'); | |
| 797 | + } else { | |
| 798 | + ttsPassAsterisksCheckbox.checked = true; | |
| 799 | + $('#tts_pass_asterisks').click(); | |
| 800 | + $('#tts_pass_asterisks').trigger('change'); | |
| 605 | 801 | } |
| 606 | - this.onSettingsChange(); // Save the settings after change | |
| 802 | + | |
| 803 | + this.onSettingsChange(); | |
| 607 | 804 | }); |
| 608 | 805 | } |
| 609 | 806 | |
| 610 | - | |
| 611 | 807 | // Event Listener for AT Generation Method Dropdown |
| 612 | 808 | const atGenerationMethodSelect = document.getElementById('at_generation_method'); |
| 613 | - const atNarratorEnabledSelect = document.getElementById('at_narrator_enabled'); | |
| 614 | 809 | if (atGenerationMethodSelect) { |
| 615 | 810 | $(atGenerationMethodSelect).off('change').onaddEventListener('change', (event) => { |
| 616 | 811 | const selectedMethod = event.target.value; |
| 617 | 812 | |
| 618 | 813 | if (selectedMethod === 'streaming_enabled') { |
| 619 | 814 | // Disable and unselect AT Narrator |
| 620 | 815 | atNarratorEnabledSelectatNarratorSelect.disabled = true; |
| 621 | 816 | atNarratorEnabledSelectatNarratorSelect.value = 'false'; |
| 622 | 817 | textNotInsideSelect.disabled = true; |
| 623 | 818 | narratorVoiceSelect.disabled = true; |
| 624 | 819 | } else if (selectedMethod === 'standard_generation') { |
| 625 | 820 | // Enable AT Narrator |
| 626 | 821 | atNarratorEnabledSelectatNarratorSelect.disabled = false; |
| 627 | 822 | } |
| 628 | 823 | this.settings.at_generation_method = selectedMethod; // Update the setting here |
| 629 | 824 | this.onSettingsChange(); // Save the settings after change |
| 630 | 825 | }); |
| 631 | 826 | } |
| 632 | 827 | |
| 633 | 828 | // Listener for Language Dropdown Listener |
| 634 | 829 | const languageSelect = document.getElementById('language_options'); |
| 635 | 830 | if (languageSelect) { |
| 636 | 831 | $(languageSelect).off('change').onaddEventListener('change', (event) => { |
| 637 | 832 | this.settings.language = event.target.value; |
| 638 | 833 | this.onSettingsChange(); // Save the settings after change |
| 639 | 834 | }); |
| 640 | 835 | } |
| 641 | 836 | |
| 642 | 837 | // Listener for AllTalk Endpoint Input Listener |
| 643 | 838 | const atServerInput = document.getElementById('at_server'); |
| 644 | 839 | if (atServerInput) { |
| 645 | 840 | $(atServerInput).off('input').onaddEventListener('input', (event) => { |
| 646 | 841 | this.settings.provider_endpoint = event.target.value; |
| 647 | 842 | this.onSettingsChange(); // Save the settings after change |
| 648 | 843 | }); |
| 649 | 844 | } |
| 650 | - | |
| 651 | 845 | } |
| 652 | 846 | |
| 653 | 847 | //#############################// |
| @@ -662,6 +856,10 @@ class AllTalkTtsProvider { | ||
| 662 | 856 | this.settings.at_generation_method = $('#at_generation_method').val(); |
| 663 | 857 | this.settings.narrator_enabled = $('#at_narrator_enabled').val(); |
| 664 | 858 | this.settings.at_narrator_text_not_inside = $('#at_narrator_text_not_inside').val(); |
| 859 | + this.settings.rvc_character_voice = $('#rvc_character_voice').val(); | |
| 860 | + this.settings.rvc_narrator_voice = $('#rvc_narrator_voice').val(); | |
| 861 | + this.settings.rvc_character_pitch = $('#rvc_character_pitch').val(); | |
| 862 | + this.settings.rvc_narrator_pitch = $('#rvc_narrator_pitch').val(); | |
| 665 | 863 | this.settings.narrator_voice_gen = $('#narrator_voice').val(); |
| 666 | 864 | // Save the updated settings |
| 667 | 865 | saveTtsProviderSettings(); |
| @@ -672,8 +870,16 @@ class AllTalkTtsProvider { | ||
| 672 | 870 | //#########################// |
| 673 | 871 | |
| 674 | 872 | async onRefreshClick() { |
| 675 | - await this.initEndpoint(); | |
| 873 | + try { | |
| 676 | - // Additional actions as needed | |
| 874 | + updateStatus('Processing'); // Set status to Processing while refreshing | |
| 875 | + await this.checkReady(); // Check if the TTS provider is ready | |
| 876 | + await this.loadSettings(this.settings); // Reload the settings | |
| 877 | + await this.checkReady(); // Check if the TTS provider is ready | |
| 878 | + updateStatus(this.ready ? 'Ready' : 'Offline'); // Update the status based on readiness | |
| 879 | + } catch (error) { | |
| 880 | + console.error('Error during refresh:', error); | |
| 881 | + updateStatus('Error'); // Set status to Error in case of failure | |
| 882 | + } | |
| 677 | 883 | } |
| 678 | 884 | |
| 679 | 885 | //##################// |
| @@ -684,7 +890,14 @@ class AllTalkTtsProvider { | ||
| 684 | 890 | try { |
| 685 | 891 | // Prepare data for POST request |
| 686 | 892 | const postData = new URLSearchParams(); |
| 687 | 893 | postData.append('voice', `${voiceName}.wav`); |
| 894 | + | |
| 895 | + // Add RVC parameters for V2 if applicable | |
| 896 | + if (this.settings.server_version === 'v2' && this.settings.rvc_character_voice !== 'Disabled') { | |
| 897 | + postData.append('rvccharacter_voice_gen', this.settings.rvc_character_voice); | |
| 898 | + postData.append('rvccharacter_pitch', this.settings.rvc_character_pitch || '0'); | |
| 899 | + } | |
| 900 | + | |
| 688 | 901 | // Making the POST request |
| 689 | 902 | const response = await fetch(`${this.settings.provider_endpoint}/api/previewvoice/`, { |
| 690 | 903 | method: 'POST', |
| @@ -693,24 +906,28 @@ class AllTalkTtsProvider { | ||
| 693 | 906 | }, |
| 694 | 907 | body: postData, |
| 695 | 908 | }); |
| 909 | + | |
| 696 | 910 | if (!response.ok) { |
| 697 | 911 | const errorText = await response.text(); |
| 698 | 912 | console.error('[previewTtsVoice] Error Response Text:', errorText); |
| 699 | 913 | throw new Error(`HTTP ${response.status}: ${errorText}`); |
| 700 | 914 | } |
| 701 | - // Assuming the server returns a URL to the .wav file | |
| 915 | + | |
| 702 | 916 | const data = await response.json(); |
| 703 | 917 | if (data.output_file_url) { |
| 704 | - // Use an audio element to play the .wav file | |
| 918 | + // Handle V1/V2 URL differences | |
| 705 | - const audioElement = new Audio(data.output_file_url); | |
| 919 | + const fullUrl = this.settings.server_version === 'v1' | |
| 920 | + ? data.output_file_url | |
| 921 | + : `${this.settings.provider_endpoint}${data.output_file_url}`; | |
| 922 | + | |
| 923 | + const audioElement = new Audio(fullUrl); | |
| 706 | 924 | audioElement.play().catch(e => console.error('Error playing audio:', e)); |
| 707 | 925 | } else { |
| 708 | 926 | console.warn('[previewTtsVoice] No output file URL received in the response'); |
| 709 | 927 | throw new Error('No output file URL received in the response'); |
| 710 | 928 | } |
| 711 | - | |
| 712 | 929 | } catch (error) { |
| 713 | 930 | console.error('[previewTtsVoice] Exception caught during preview generation:', error); |
| 714 | 931 | throw error; |
| 715 | 932 | } |
| 716 | 933 | } |
| @@ -744,7 +961,7 @@ class AllTalkTtsProvider { | ||
| 744 | 961 | try { |
| 745 | 962 | if (this.settings.at_generation_method === 'streaming_enabled') { |
| 746 | 963 | // Construct the streaming URL |
| 747 | 964 | const streamingUrl = `${this.settings.provider_endpoint}/api/tts-generate-streaming?text=${encodeURIComponent(inputText)}&voice=${encodeURIComponent(voiceId)}.wav&language=${encodeURIComponent(this.settings.language)}&output_file=stream_output.wav`; |
| 748 | 965 | console.log('Streaming URL:', streamingUrl); |
| 749 | 966 | |
| 750 | 967 | // Return the streaming URL directly |
| @@ -770,20 +987,31 @@ class AllTalkTtsProvider { | ||
| 770 | 987 | //####################// |
| 771 | 988 | |
| 772 | 989 | async fetchTtsGeneration(inputText, voiceId) { |
| 773 | - // Prepare the request payload | |
| 774 | 990 | const requestBody = new URLSearchParams({ |
| 775 | 991 | 'text_input': inputText, |
| 776 | 992 | 'text_filtering': 'standard', |
| 777 | 993 | 'character_voice_gen': voiceId + '.wav', |
| 778 | 994 | 'narrator_enabled': this.settings.narrator_enabled, |
| 779 | 995 | 'narrator_voice_gen': this.settings.narrator_voice_gen + '.wav', |
| 780 | 996 | 'text_not_inside': this.settings.at_narrator_text_not_inside, |
| 781 | 997 | 'language': this.settings.language, |
| 782 | 998 | 'output_file_name': 'st_output', |
| 783 | 999 | 'output_file_timestamp': 'true', |
| 784 | 1000 | 'autoplay': 'false', |
| 785 | 1001 | 'autoplay_volume': '0.8', |
| 786 | 1002 | }).toString(); |
| 1003 | + | |
| 1004 | + // Add RVC parameters only for V2 | |
| 1005 | + if (this.settings.server_version === 'v2') { | |
| 1006 | + if (this.settings.rvc_character_voice !== 'Disabled') { | |
| 1007 | + requestBody.append('rvccharacter_voice_gen', this.settings.rvc_character_voice); | |
| 1008 | + requestBody.append('rvccharacter_pitch', this.settings.rvc_character_pitch || '0'); | |
| 1009 | + } | |
| 1010 | + if (this.settings.rvc_narrator_voice !== 'Disabled') { | |
| 1011 | + requestBody.append('rvcnarrator_voice_gen', this.settings.rvc_narrator_voice); | |
| 1012 | + requestBody.append('rvcnarrator_pitch', this.settings.rvc_narrator_pitch || '0'); | |
| 1013 | + } | |
| 1014 | + } | |
| 787 | 1015 | |
| 788 | 1016 | try { |
| 789 | 1017 | const response = await doExtrasFetch( |
| @@ -800,16 +1028,20 @@ class AllTalkTtsProvider { | ||
| 800 | 1028 | |
| 801 | 1029 | if (!response.ok) { |
| 802 | 1030 | const errorText = await response.text(); |
| 803 | 1031 | console.error('[fetchTtsGeneration] Error Response Text:', errorText); |
| 804 | - // toastr.error(response.statusText, 'TTS Generation Failed'); | |
| 805 | 1032 | throw new Error(`HTTP ${response.status}: ${errorText}`); |
| 806 | 1033 | } |
| 807 | 1034 | const data = await response.json(); |
| 808 | - const outputUrl = data.output_file_url; | |
| 1035 | + | |
| 809 | - return outputUrl; // Return only the output_file_url | |
| 1036 | + // Handle V1/V2 URL differences | |
| 1037 | + const outputUrl = this.settings.server_version === 'v1' | |
| 1038 | + ? data.output_file_url // V1 returns full URL | |
| 1039 | + : `${this.settings.provider_endpoint}${data.output_file_url}`; // V2 returns relative path | |
| 1040 | + | |
| 1041 | + return outputUrl; | |
| 810 | 1042 | } catch (error) { |
| 811 | 1043 | console.error('[fetchTtsGeneration] Exception caught:', error); |
| 812 | - throw error; // Rethrow the error for further handling | |
| 1044 | + throw error; | |
| 813 | 1045 | } |
| 814 | 1046 | } |
| 815 | 1047 | } |
| @@ -364,7 +364,7 @@ function onToggleLogprobsPanel() { | ||
| 364 | 364 | function createSwipe(messageId, prompt) { |
| 365 | 365 | // need to call `cleanUpMessage` on our new prompt, because we were working |
| 366 | 366 | // with raw model output and our new prompt is missing trimming/macro replacements |
| 367 | 367 | const cleanedPrompt = cleanUpMessage(prompt, false, false, true); |
| 368 | 368 | |
| 369 | 369 | const msg = chat[messageId]; |
| 370 | 370 | const newSwipeInfo = { |
| @@ -3164,7 +3164,7 @@ grammarly-extension { | ||
| 3164 | 3164 | .avatar-container .avatar-buttons { |
| 3165 | 3165 | display: flex; |
| 3166 | 3166 | flex-direction: row; |
| 3167 | 3167 | gap: 5px3px; |
| 3168 | 3168 | opacity: 0.3; |
| 3169 | 3169 | transition: opacity 0.25s ease-in-out; |
| 3170 | 3170 | } |