feat: use refreshtoken instead of api token
This commit is contained in:
@@ -148,10 +148,7 @@ export class ElevenLabsTTS implements TTSModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
canBeUsed(): boolean {
|
canBeUsed(): boolean {
|
||||||
return (
|
return config.tts_elevenlabs_refreshtoken != undefined;
|
||||||
config.tts_elevenlabs_refreshtoken != undefined &&
|
|
||||||
config.tts_elevenlabs_key != undefined
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -176,13 +173,15 @@ export class ElevenLabsTTS implements TTSModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async fetchVoices(): Promise<void> {
|
private async fetchVoices(): Promise<void> {
|
||||||
|
if (!this.session) return;
|
||||||
|
|
||||||
const opt: https.RequestOptions = {
|
const opt: https.RequestOptions = {
|
||||||
hostname: ELEVENLABS_API_ENDPOINT,
|
hostname: ELEVENLABS_API_ENDPOINT,
|
||||||
path: '/v2/voices',
|
path: '/v2/voices',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
'xi-api-key': config.tts_elevenlabs_key,
|
Authorization: `Bearer ${this.session.idToken}`,
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -211,13 +210,15 @@ export class ElevenLabsTTS implements TTSModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async fetchModels(): Promise<void> {
|
private async fetchModels(): Promise<void> {
|
||||||
|
if (!this.session) return;
|
||||||
|
|
||||||
const opt: https.RequestOptions = {
|
const opt: https.RequestOptions = {
|
||||||
hostname: ELEVENLABS_API_ENDPOINT,
|
hostname: ELEVENLABS_API_ENDPOINT,
|
||||||
path: '/v1/models',
|
path: '/v1/models',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
'xi-api-key': config.tts_elevenlabs_key,
|
Authorization: `Bearer ${this.session.idToken}`,
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ export interface Config {
|
|||||||
tts_default_mode: string | undefined;
|
tts_default_mode: string | undefined;
|
||||||
tts_default_voice: string | undefined;
|
tts_default_voice: string | undefined;
|
||||||
|
|
||||||
tts_elevenlabs_key: string | undefined;
|
|
||||||
tts_elevenlabs_refreshtoken: string | undefined;
|
tts_elevenlabs_refreshtoken: string | undefined;
|
||||||
tts_tiktok_sessionid: string | undefined;
|
tts_tiktok_sessionid: string | undefined;
|
||||||
|
|
||||||
@@ -30,7 +29,6 @@ function loadConfig(): Config {
|
|||||||
owner_id: process.env.DISCORD_OWNER_ID,
|
owner_id: process.env.DISCORD_OWNER_ID,
|
||||||
tts_default_mode: process.env.DEFAULT_TTS_MODE,
|
tts_default_mode: process.env.DEFAULT_TTS_MODE,
|
||||||
tts_default_voice: process.env.DEFAULT_TTS_VOICE,
|
tts_default_voice: process.env.DEFAULT_TTS_VOICE,
|
||||||
tts_elevenlabs_key: process.env.TTS_ELEVENLABS_KEY,
|
|
||||||
tts_elevenlabs_refreshtoken: process.env.TTS_ELEVENLABS_REFRESHTOKEN,
|
tts_elevenlabs_refreshtoken: process.env.TTS_ELEVENLABS_REFRESHTOKEN,
|
||||||
steam_webapi_key: process.env.STEAM_WEBAPI_KEY,
|
steam_webapi_key: process.env.STEAM_WEBAPI_KEY,
|
||||||
aws_access_id: process.env.AWS_ACCESS_ID,
|
aws_access_id: process.env.AWS_ACCESS_ID,
|
||||||
|
|||||||
Reference in New Issue
Block a user