From f91e1dfd86b0b2d9af86629a36dac60a34ef6da5 Mon Sep 17 00:00:00 2001 From: Jasonnor Date: Sat, 2 Sep 2023 15:23:18 +0800 Subject: [PATCH 1/2] TTS: Set character default voice from `disabled` to `default` (#1077) ## Features and improvements - TTS Extension - Set character default voice from `disabled` to `DEFAULT_VOICE_MARKER` - Add `DEFAULT_VOICE_MARKER` option for all characters - Set default `DEFAULT_VOICE_MARKER` voice as `disabled` ## Related issues - #1077 --- public/scripts/extensions/tts/index.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/public/scripts/extensions/tts/index.js b/public/scripts/extensions/tts/index.js index 77c9f7373..51931aac1 100644 --- a/public/scripts/extensions/tts/index.js +++ b/public/scripts/extensions/tts/index.js @@ -462,7 +462,7 @@ async function processTtsQueue() { return; } - const voiceMapEntry = voiceMap[char] || voiceMap[DEFAULT_VOICE_MARKER] + const voiceMapEntry = voiceMap[char] === DEFAULT_VOICE_MARKER ? voiceMap[DEFAULT_VOICE_MARKER] : voiceMap[char] if (!voiceMapEntry) { throw `${char} not in voicemap. Configure character in extension settings voice map` @@ -708,7 +708,7 @@ class VoiceMapEntry { name voiceId selectElement - constructor (name, voiceId='disabled') { + constructor (name, voiceId=DEFAULT_VOICE_MARKER) { this.name = name this.voiceId = voiceId this.selectElement = null @@ -720,6 +720,7 @@ class VoiceMapEntry {
${this.name}
@@ -804,8 +805,10 @@ export async function initVoiceMap(){ let voiceId if (character in voiceMapFromSettings){ voiceId = voiceMapFromSettings[character] - } else { + } else if (character === DEFAULT_VOICE_MARKER) { voiceId = 'disabled' + } else { + voiceId = '[Default Voice]' } const voiceMapEntry = new VoiceMapEntry(character, voiceId) voiceMapEntry.addUI(voiceIdsFromProvider) From 6d2caf94bf5392c9c5b3015fee78929d898081cb Mon Sep 17 00:00:00 2001 From: Jasonnor Date: Sun, 3 Sep 2023 23:38:34 +0800 Subject: [PATCH 2/2] TTS: Avoid default voice selector display itself --- public/scripts/extensions/tts/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/public/scripts/extensions/tts/index.js b/public/scripts/extensions/tts/index.js index 51931aac1..35ef174f6 100644 --- a/public/scripts/extensions/tts/index.js +++ b/public/scripts/extensions/tts/index.js @@ -716,12 +716,14 @@ class VoiceMapEntry { addUI(voiceIds){ let sanitizedName = sanitizeId(this.name) + let defaultOption = this.name === DEFAULT_VOICE_MARKER ? + '' : + `` let template = `
${this.name}
` @@ -808,7 +810,7 @@ export async function initVoiceMap(){ } else if (character === DEFAULT_VOICE_MARKER) { voiceId = 'disabled' } else { - voiceId = '[Default Voice]' + voiceId = DEFAULT_VOICE_MARKER } const voiceMapEntry = new VoiceMapEntry(character, voiceId) voiceMapEntry.addUI(voiceIdsFromProvider)