Cleaned persistence manager, updated ui-options connectivity

This commit is contained in:
2025-04-06 19:35:05 +00:00
parent 0ab639fd25
commit 0842cbfefc
6 changed files with 107 additions and 114 deletions
+9 -12
View File
@@ -57,28 +57,25 @@ export class OpenAITTSModule extends ApiTTSModuleBase {
return false;
}
// Check for API key
const apiKey = persistenceManager.getPreference('openai', 'api_key', '');
if (!apiKey) {
// API key is already loaded in parent initialize() method
// Just check if it's available
if (!this.apiKey) {
console.error('OpenAI TTS: API key not configured');
return false;
}
// Set API key
this.apiKey = apiKey;
// Load preferences
const preferredVoice = persistenceManager.getPreference('openai', 'voice', this.voiceOptions.voice);
const preferredVoice = persistenceManager.getPreference('tts', `${this.id}_voice`, this.voiceOptions.voice);
if (preferredVoice) {
this.voiceOptions.voice = preferredVoice;
}
const preferredModel = persistenceManager.getPreference('openai', 'model', this.voiceOptions.model);
const preferredModel = persistenceManager.getPreference('tts', `${this.id}_model`, this.voiceOptions.model);
if (preferredModel) {
this.voiceOptions.model = preferredModel;
}
const preferredSpeed = persistenceManager.getPreference('openai', 'speed', this.voiceOptions.speed);
const preferredSpeed = persistenceManager.getPreference('tts', `${this.id}_speed`, this.voiceOptions.speed);
if (typeof preferredSpeed === 'number') {
this.voiceOptions.speed = preferredSpeed;
}
@@ -206,7 +203,7 @@ export class OpenAITTSModule extends ApiTTSModuleBase {
// Save voice preference
const persistenceManager = this.getModule('persistence-manager');
if (persistenceManager) {
persistenceManager.updatePreference('tts', 'openai_voice', options.voice);
persistenceManager.updatePreference('tts', `${this.id}_voice`, options.voice);
}
}
@@ -221,7 +218,7 @@ export class OpenAITTSModule extends ApiTTSModuleBase {
// Save the model preference
const persistenceManager = this.getModule('persistence-manager');
if (persistenceManager) {
persistenceManager.updatePreference('tts', 'openai_model', options.model);
persistenceManager.updatePreference('tts', `${this.id}_model`, options.model);
}
}
@@ -234,7 +231,7 @@ export class OpenAITTSModule extends ApiTTSModuleBase {
// Save the format preference
const persistenceManager = this.getModule('persistence-manager');
if (persistenceManager) {
persistenceManager.updatePreference('tts', 'openai_format', options.response_format);
persistenceManager.updatePreference('tts', `${this.id}_format`, options.response_format);
}
}
}