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
This commit is contained in:
Jasonnor 2023-09-02 15:23:18 +08:00
parent 4e366a8e9e
commit f91e1dfd86
1 changed files with 6 additions and 3 deletions

View File

@ -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 {
<div class='tts_voicemap_block_char flex-container flexGap5'>
<span id='tts_voicemap_char_${sanitizedName}'>${this.name}</span>
<select id='tts_voicemap_char_${sanitizedName}_voice'>
<option>${DEFAULT_VOICE_MARKER}</option>
<option>disabled</option>
</select>
</div>
@ -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)