fix: implement tts_elevenlabs_token

This commit is contained in:
2026-01-28 01:34:55 -03:00
parent 8e7a71164d
commit 51ebb6c92d
+23 -6
View File
@@ -5,6 +5,10 @@ import * as https from 'https';
const ELEVENLABS_API_ENDPOINT = 'api.elevenlabs.io';
/*
TO-DO: Implement previous text
*/
interface ElevenLabsVoice {
voice_id: string;
name: string;
@@ -68,8 +72,8 @@ export class ElevenLabsTTS implements TTSModule {
}
/*
TTSModule methods
*/
TTSModule methods
*/
async getVoices(): Promise<Array<string> | undefined> {
if (this.voices) return this.voices.map((voice) => voice.name);
}
@@ -85,8 +89,21 @@ export class ElevenLabsTTS implements TTSModule {
path: `/v1/text-to-speech/${voiceData.voice_id}/stream`,
method: 'POST',
headers: {
'xi-api-key': config.tts_elevenlabs_key,
'Content-Type': 'application/json'
accept: 'application/json',
'Content-Type': 'application/json',
origin: 'https://elevenlabs.io',
'user-agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36',
'Sec-Ch-Ua': '"Not)A;Brand";v="8", "Chromium";v="138"',
'Sec-Ch-Ua-Mobile': '?0',
'Sec-Ch-Ua-Platform': '"Windows"',
'Sec-Fetch-Site': 'same-site',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Dest': 'empty',
host: 'api.us.elevenlabs.io',
...(config.tts_elevenlabs_token
? { Authorization: `Bearer ${config.tts_elevenlabs_token}` }
: { 'xi-api-key': config.tts_elevenlabs_key })
}
};
@@ -119,8 +136,8 @@ export class ElevenLabsTTS implements TTSModule {
}
/*
ElevenLabs specific methods
*/
ElevenLabs specific methods
*/
public setSettings(settings: Partial<ElevenLabsVoiceSettings>) {
this.settings = { ...this.settings, ...settings };
}