From 51ebb6c92dfcb9284e15321bf4ea455dea2bc57b Mon Sep 17 00:00:00 2001 From: neru Date: Wed, 28 Jan 2026 01:34:55 -0300 Subject: [PATCH] fix: implement tts_elevenlabs_token --- src/modules/tts-modes/elevenlabs.ts | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/modules/tts-modes/elevenlabs.ts b/src/modules/tts-modes/elevenlabs.ts index 817d17e..bc90c9b 100644 --- a/src/modules/tts-modes/elevenlabs.ts +++ b/src/modules/tts-modes/elevenlabs.ts @@ -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 | 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) { this.settings = { ...this.settings, ...settings }; }