#988 Experimental fix for 11labs

This commit is contained in:
Cohee 2023-08-21 14:40:38 +03:00
parent 8470acda41
commit 1da5ea5280
1 changed files with 11 additions and 7 deletions

View File

@ -1,3 +1,5 @@
import { deepClone } from "../../utils.js";
export { ElevenLabsTtsProvider } export { ElevenLabsTtsProvider }
class ElevenLabsTtsProvider { class ElevenLabsTtsProvider {
@ -47,18 +49,20 @@ class ElevenLabsTtsProvider {
loadSettings(settings) { loadSettings(settings) {
// Pupulate Provider UI given input settings // Pupulate Provider UI given input settings
if (Object.keys(settings).length == 0) { if (!settings || Object.keys(settings).length == 0) {
console.info("Using default TTS Provider settings") console.info("Using default TTS Provider settings")
} }
// Only accept keys defined in defaultSettings // Only accept keys defined in defaultSettings
this.settings = this.defaultSettings this.settings = deepClone(this.defaultSettings);
for (const key in settings){ if (settings) {
if (key in this.settings){ for (const key in settings) {
this.settings[key] = settings[key] if (key in this.settings) {
} else { this.settings[key] = settings[key]
throw `Invalid setting passed to TTS Provider: ${key}` } else {
throw `Invalid setting passed to TTS Provider: ${key}`
}
} }
} }