fix: misc style / variable consistency changes
This commit is contained in:
@@ -5,8 +5,8 @@ import * as https from 'https';
|
|||||||
import * as zlib from 'zlib';
|
import * as zlib from 'zlib';
|
||||||
|
|
||||||
import TIKTOK_TTS_VOICES from './tiktok_voices.json';
|
import TIKTOK_TTS_VOICES from './tiktok_voices.json';
|
||||||
const TIKTOK_TTS_ENDPOINT =
|
const TIKTOK_API_ENDPOINT =
|
||||||
'https://api16-normal-v6.tiktokv.com/media/api/text/speech/invoke';
|
'api16-normal-v6.tiktokv.com';
|
||||||
|
|
||||||
class TikTokTTS implements TTSModule {
|
class TikTokTTS implements TTSModule {
|
||||||
public name: string = 'TikTok';
|
public name: string = 'TikTok';
|
||||||
@@ -18,18 +18,16 @@ class TikTokTTS implements TTSModule {
|
|||||||
|
|
||||||
async generate(voice: string, text: string): Promise<TTSResponse> {
|
async generate(voice: string, text: string): Promise<TTSResponse> {
|
||||||
const reqText = encodeURIComponent(text);
|
const reqText = encodeURIComponent(text);
|
||||||
const path = `/?text_speaker=${voice}&req_text=${reqText}&speaker_map_type=0&aid=1233`;
|
const path = `/media/api/text/speech/invoke/?text_speaker=${voice}&req_text=${reqText}&speaker_map_type=0&aid=1233`;
|
||||||
|
|
||||||
const endpoint = new URL(TIKTOK_TTS_ENDPOINT);
|
|
||||||
|
|
||||||
const options: https.RequestOptions = {
|
const options: https.RequestOptions = {
|
||||||
hostname: endpoint.hostname,
|
hostname: TIKTOK_API_ENDPOINT,
|
||||||
path: endpoint.pathname + path,
|
path: path,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'User-Agent':
|
'User-Agent':
|
||||||
'com.zhiliaoapp.musically/2022600030 (Linux; U; Android 7.1.2; es_ES; SM-G988N; Build/NRD90M;tt-ok/3.12.13.1)',
|
'com.zhiliaoapp.musically/2022600030 (Linux; U; Android 7.1.2; es_ES; SM-G988N; Build/NRD90M;tt-ok/3.12.13.1)',
|
||||||
Cookie: `sessionid=${config.tiktok_session_id}`,
|
Cookie: `sessionid=${config.tts_tiktok_sessionid}`,
|
||||||
'Accept-Encoding': 'gzip,deflate,compress',
|
'Accept-Encoding': 'gzip,deflate,compress',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
}
|
}
|
||||||
@@ -97,7 +95,7 @@ class TikTokTTS implements TTSModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
canBeUsed(): boolean {
|
canBeUsed(): boolean {
|
||||||
return config.tiktok_session_id != undefined;
|
return config.tts_tiktok_sessionid != undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleStatusError(code: number): string {
|
handleStatusError(code: number): string {
|
||||||
|
|||||||
+2
-3
@@ -8,13 +8,12 @@ export interface Config {
|
|||||||
|
|
||||||
tts_azure_key: string | undefined;
|
tts_azure_key: string | undefined;
|
||||||
tts_elevenlabs_key: string | undefined;
|
tts_elevenlabs_key: string | undefined;
|
||||||
|
tts_tiktok_sessionid: string | undefined;
|
||||||
|
|
||||||
steam_webapi_key: string | undefined;
|
steam_webapi_key: string | undefined;
|
||||||
|
|
||||||
aws_access_id: string | undefined;
|
aws_access_id: string | undefined;
|
||||||
aws_access_key: string | undefined;
|
aws_access_key: string | undefined;
|
||||||
|
|
||||||
tiktok_session_id: string | undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadConfig(): Config {
|
function loadConfig(): Config {
|
||||||
@@ -36,7 +35,7 @@ function loadConfig(): Config {
|
|||||||
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,
|
||||||
aws_access_key: process.env.AWS_ACCESS_KEY,
|
aws_access_key: process.env.AWS_ACCESS_KEY,
|
||||||
tiktok_session_id: process.env.TIKTOK_SESSION_ID
|
tts_tiktok_sessionid: process.env.TTS_TIKTOK_SESSIONID
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user