refactor: replace getCustomConfig with getAppConfig in STTService, TTSService, and related files

This commit is contained in:
Danny Avila 2025-08-18 01:27:47 -04:00
parent b0256510b5
commit c82c47ab6a
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
6 changed files with 37 additions and 40 deletions

View file

@ -1,9 +1,9 @@
const axios = require('axios');
const { logger } = require('@librechat/data-schemas');
const { genAzureEndpoint } = require('@librechat/api');
const { extractEnvVariable, TTSProviders } = require('librechat-data-provider');
const { getRandomVoiceId, createChunkProcessor, splitTextIntoChunks } = require('./streamAudio');
const { getCustomConfig } = require('~/server/services/Config');
const { logger } = require('~/config');
const { getAppConfig } = require('~/server/services/Config');
/**
* Service class for handling Text-to-Speech (TTS) operations.
@ -32,11 +32,7 @@ class TTSService {
* @throws {Error} If the custom config is not found.
*/
static async getInstance() {
const customConfig = await getCustomConfig();
if (!customConfig) {
throw new Error('Custom config not found');
}
return new TTSService(customConfig);
return new TTSService();
}
/**
@ -293,10 +289,13 @@ class TTSService {
return res.status(400).send('Missing text in request body');
}
const appConfig = await getAppConfig({
role: req.user?.role,
});
try {
res.setHeader('Content-Type', 'audio/mpeg');
const provider = this.getProvider();
const ttsSchema = this.customConfig.speech.tts[provider];
const ttsSchema = appConfig?.speech?.tts?.[provider];
const voice = await this.getVoice(ttsSchema, requestVoice);
if (input.length < 4096) {