diff --git a/src/modules/tts-modes/elevenlabs.ts b/src/modules/tts-modes/elevenlabs.ts index a281d17..7a07da7 100644 --- a/src/modules/tts-modes/elevenlabs.ts +++ b/src/modules/tts-modes/elevenlabs.ts @@ -148,10 +148,7 @@ export class ElevenLabsTTS implements TTSModule { } canBeUsed(): boolean { - return ( - config.tts_elevenlabs_refreshtoken != undefined && - config.tts_elevenlabs_key != undefined - ); + return config.tts_elevenlabs_refreshtoken != undefined; } /* @@ -176,13 +173,15 @@ export class ElevenLabsTTS implements TTSModule { } private async fetchVoices(): Promise { + if (!this.session) return; + const opt: https.RequestOptions = { hostname: ELEVENLABS_API_ENDPOINT, path: '/v2/voices', method: 'GET', headers: { Accept: 'application/json', - 'xi-api-key': config.tts_elevenlabs_key, + Authorization: `Bearer ${this.session.idToken}`, 'Content-Type': 'application/json' } }; @@ -211,13 +210,15 @@ export class ElevenLabsTTS implements TTSModule { } private async fetchModels(): Promise { + if (!this.session) return; + const opt: https.RequestOptions = { hostname: ELEVENLABS_API_ENDPOINT, path: '/v1/models', method: 'GET', headers: { Accept: 'application/json', - 'xi-api-key': config.tts_elevenlabs_key, + Authorization: `Bearer ${this.session.idToken}`, 'Content-Type': 'application/json' } }; diff --git a/src/utils/config.ts b/src/utils/config.ts index 4e00e93..c8aff6b 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -6,7 +6,6 @@ export interface Config { tts_default_mode: string | undefined; tts_default_voice: string | undefined; - tts_elevenlabs_key: string | undefined; tts_elevenlabs_refreshtoken: string | undefined; tts_tiktok_sessionid: string | undefined; @@ -30,7 +29,6 @@ function loadConfig(): Config { owner_id: process.env.DISCORD_OWNER_ID, tts_default_mode: process.env.DEFAULT_TTS_MODE, tts_default_voice: process.env.DEFAULT_TTS_VOICE, - tts_elevenlabs_key: process.env.TTS_ELEVENLABS_KEY, tts_elevenlabs_refreshtoken: process.env.TTS_ELEVENLABS_REFRESHTOKEN, steam_webapi_key: process.env.STEAM_WEBAPI_KEY, aws_access_id: process.env.AWS_ACCESS_ID,