Added support for openai api tts.

This commit is contained in:
2025-04-05 14:40:56 +00:00
parent b8e2e6e238
commit e8eb93ae1b
11 changed files with 2063 additions and 989 deletions
+3 -11
View File
@@ -29,7 +29,6 @@ export class KokoroHandler extends TTSHandler {
this.iframe = null;
this.currentAudio = null;
this.currentVoice = null;
this.preloadCache = new Map();
this.pendingGenerations = new Map();
this.generationCounter = 0;
@@ -501,18 +500,11 @@ export class KokoroHandler extends TTSHandler {
}
try {
// Check if already in cache
const cacheKey = `${this.currentVoice?.id || 'af_heart'}-${this.options.rate}-${text}`;
if (this.preloadCache.has(cacheKey)) {
return this.preloadCache.get(cacheKey);
}
// Generate speech
// No longer check the local cache as we're using TTSFactory's centralized cache
// Generate speech directly
const result = await this.generateSpeech(text);
// Store in cache
this.preloadCache.set(cacheKey, result);
// Return result for centralized caching in TTSFactory
return result;
} catch (error) {
console.error('Kokoro TTS: Error preloading speech:', error);