mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Fixed Novel custom voices not saving
This commit is contained in:
@ -487,6 +487,11 @@ function loadSettings() {
|
|||||||
if (Object.keys(extension_settings.tts).length === 0) {
|
if (Object.keys(extension_settings.tts).length === 0) {
|
||||||
Object.assign(extension_settings.tts, defaultSettings)
|
Object.assign(extension_settings.tts, defaultSettings)
|
||||||
}
|
}
|
||||||
|
for (const key in defaultSettings) {
|
||||||
|
if (!(key in extension_settings.tts)) {
|
||||||
|
extension_settings.tts[key] = defaultSettings[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
$('#tts_provider').val(extension_settings.tts.currentProvider)
|
$('#tts_provider').val(extension_settings.tts.currentProvider)
|
||||||
$('#tts_enabled').prop(
|
$('#tts_enabled').prop(
|
||||||
'checked',
|
'checked',
|
||||||
@ -575,7 +580,7 @@ async function loadTtsProvider(provider) {
|
|||||||
if (!provider) {
|
if (!provider) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init provider references
|
// Init provider references
|
||||||
extension_settings.tts.currentProvider = provider
|
extension_settings.tts.currentProvider = provider
|
||||||
ttsProviderName = provider
|
ttsProviderName = provider
|
||||||
@ -725,7 +730,7 @@ class VoiceMapEntry {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Init voiceMapEntries for character select list.
|
* Init voiceMapEntries for character select list.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export async function initVoiceMap(){
|
export async function initVoiceMap(){
|
||||||
// Clear existing voiceMap state
|
// Clear existing voiceMap state
|
||||||
@ -751,7 +756,7 @@ export async function initVoiceMap(){
|
|||||||
|
|
||||||
// Get characters in current chat
|
// Get characters in current chat
|
||||||
const characters = getCharacters()
|
const characters = getCharacters()
|
||||||
|
|
||||||
// Get saved voicemap from provider settings, handling new and old representations
|
// Get saved voicemap from provider settings, handling new and old representations
|
||||||
let voiceMapFromSettings = {}
|
let voiceMapFromSettings = {}
|
||||||
if ("voiceMap" in extension_settings.tts[ttsProviderName]) {
|
if ("voiceMap" in extension_settings.tts[ttsProviderName]) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { getRequestHeaders, callPopup } from "../../../script.js"
|
import { getRequestHeaders, callPopup } from "../../../script.js"
|
||||||
import { getPreviewString } from "./index.js"
|
import { getPreviewString, saveTtsProviderSettings } from "./index.js"
|
||||||
import { initVoiceMap } from "./index.js"
|
import { initVoiceMap } from "./index.js"
|
||||||
|
|
||||||
export { NovelTtsProvider }
|
export { NovelTtsProvider }
|
||||||
@ -21,17 +21,19 @@ class NovelTtsProvider {
|
|||||||
|
|
||||||
get settingsHtml() {
|
get settingsHtml() {
|
||||||
let html = `
|
let html = `
|
||||||
<br>
|
<div class="novel_tts_hints">
|
||||||
<small>
|
<div>Use NovelAI's TTS engine.</div>
|
||||||
Use NovelAI's TTS engine.<br>
|
<div>
|
||||||
The default Voice IDs are only examples. Add custom voices and Novel will create a new random voice for it. Feel free to try different options!<br>
|
The default Voice IDs are only examples. Add custom voices and Novel will create a new random voice for it.
|
||||||
</small>
|
Feel free to try different options!
|
||||||
<small><i>Hint: Save an API key in the NovelAI API settings to use it here.</i></small> <br>
|
</div>
|
||||||
|
<i>Hint: Save an API key in the NovelAI API settings to use it here.</i>
|
||||||
|
</div>
|
||||||
<label for="tts-novel-custom-voices-add">Custom Voices</label>
|
<label for="tts-novel-custom-voices-add">Custom Voices</label>
|
||||||
<div style="display:flex; align-items: baseline">
|
<div class="tts_custom_voices">
|
||||||
<select id="tts-novel-custom-voices-select"><select>
|
<select id="tts-novel-custom-voices-select"><select>
|
||||||
<i id="tts-novel-custom-voices-add" class="tts-button fa-solid fa-plus fa-2x" title="Add" style="color:green"></i>
|
<i id="tts-novel-custom-voices-add" class="tts-button fa-solid fa-plus fa-xl success" title="Add"></i>
|
||||||
<i id="tts-novel-custom-voices-delete" class="tts-button fa-solid fa-xmark fa-2x" title="Delete" style="color:red"></i>
|
<i id="tts-novel-custom-voices-delete" class="tts-button fa-solid fa-xmark fa-xl failure" title="Delete"></i>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
return html;
|
return html;
|
||||||
@ -44,18 +46,20 @@ class NovelTtsProvider {
|
|||||||
this.settings.customVoices.push(voiceName)
|
this.settings.customVoices.push(voiceName)
|
||||||
this.populateCustomVoices()
|
this.populateCustomVoices()
|
||||||
initVoiceMap() // Update TTS extension voiceMap
|
initVoiceMap() // Update TTS extension voiceMap
|
||||||
|
saveTtsProviderSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete selected custom voice from provider
|
// Delete selected custom voice from provider
|
||||||
deleteCustomVoice() {
|
deleteCustomVoice() {
|
||||||
const selected = $("#tts-novel-custom-voices-select").find(':selected').val();
|
const selected = $("#tts-novel-custom-voices-select").find(':selected').val();
|
||||||
const voiceIndex = this.settings.customVoices.indexOf(selected);
|
const voiceIndex = this.settings.customVoices.indexOf(selected);
|
||||||
|
|
||||||
if (voiceIndex !== -1) {
|
if (voiceIndex !== -1) {
|
||||||
this.settings.customVoices.splice(voiceIndex, 1);
|
this.settings.customVoices.splice(voiceIndex, 1);
|
||||||
}
|
}
|
||||||
this.populateCustomVoices()
|
this.populateCustomVoices()
|
||||||
initVoiceMap() // Update TTS extension voiceMap
|
initVoiceMap() // Update TTS extension voiceMap
|
||||||
|
saveTtsProviderSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the UI dropdown list of voices in provider
|
// Create the UI dropdown list of voices in provider
|
||||||
@ -139,7 +143,7 @@ class NovelTtsProvider {
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Add in custom voices to the map
|
// Add in custom voices to the map
|
||||||
let addVoices = this.settings.customVoices.map(voice =>
|
let addVoices = this.settings.customVoices.map(voice =>
|
||||||
({ name: voice, voice_id: voice, lang: 'en-US', preview_url: false })
|
({ name: voice, voice_id: voice, lang: 'en-US', preview_url: false })
|
||||||
)
|
)
|
||||||
voices = voices.concat(addVoices)
|
voices = voices.concat(addVoices)
|
||||||
|
@ -70,7 +70,21 @@
|
|||||||
|
|
||||||
.tts_block {
|
.tts_block {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: baseline;
|
||||||
column-gap: 5px;
|
column-gap: 5px;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tts_custom_voices {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
gap: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.novel_tts_hints {
|
||||||
|
font-size: calc(0.9 * var(--mainFontSize));
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 5px;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user