Compare commits
4 Commits
d9c623ac5c
...
123ed75b60
| Author | SHA1 | Date | |
|---|---|---|---|
| 123ed75b60 | |||
| 51ebb6c92d | |||
| 8e7a71164d | |||
| 224d1339e9 |
@@ -8,6 +8,7 @@ services:
|
||||
DISCORD_TOKEN:
|
||||
TTS_TIKTOK_SESSIONID:
|
||||
TTS_ELEVENLABS_KEY:
|
||||
TTS_ELEVENLABS_TOKEN:
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./db.sqlite:/app/db.sqlite
|
||||
@@ -9,6 +9,8 @@ import { DataTypes } from 'sequelize';
|
||||
import { config } from '../../utils/config';
|
||||
import { DatabaseManager } from '../../modules/db';
|
||||
|
||||
import * as fs from 'fs';
|
||||
|
||||
const URL_REGEX = /(?:https?|ftp):\/\/[\n\S]+/g;
|
||||
const DISCORD_REGEX = /<(?::\w+:|@!*&*|#)[0-9]+>/g; // from: https://www.reddit.com/r/discordapp/comments/iibxms/if_anyone_needs_regex_to_match_an_emote_mention/
|
||||
|
||||
@@ -74,13 +76,24 @@ class TTSListener implements Command {
|
||||
if (msgFiltered.length === 0) return;
|
||||
|
||||
const audio = await ttsModule.generate(voiceName, msgFiltered);
|
||||
if (!audio) {
|
||||
this.log.error("TTS generation didn't return anything");
|
||||
return;
|
||||
}
|
||||
|
||||
if (audio?.data) {
|
||||
if (audio.data) {
|
||||
const stream =
|
||||
AudioStreamManager.get.getOrCreateStream(voiceConnection);
|
||||
const queue = stream.getQueue('TTS');
|
||||
queue.enqueue(Readable.from(audio.data));
|
||||
}
|
||||
|
||||
if (audio.error) {
|
||||
this.log.error(
|
||||
'Error occurred while generating message: (%s)',
|
||||
audio.error
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
this.log.error('Error occurred while processing TTS message (%s)', err);
|
||||
}
|
||||
|
||||
@@ -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,9 +89,21 @@ export class ElevenLabsTTS implements TTSModule {
|
||||
path: `/v1/text-to-speech/${voiceData.voice_id}/stream`,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'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 })
|
||||
}
|
||||
};
|
||||
|
||||
@@ -120,8 +136,8 @@ export class ElevenLabsTTS implements TTSModule {
|
||||
}
|
||||
|
||||
/*
|
||||
ElevenLabs specific methods
|
||||
*/
|
||||
ElevenLabs specific methods
|
||||
*/
|
||||
public setSettings(settings: Partial<ElevenLabsVoiceSettings>) {
|
||||
this.settings = { ...this.settings, ...settings };
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ export interface Config {
|
||||
tts_default_voice: string | undefined;
|
||||
|
||||
tts_elevenlabs_key: string | undefined;
|
||||
tts_elevenlabs_token: string | undefined;
|
||||
tts_tiktok_sessionid: string | undefined;
|
||||
|
||||
steam_webapi_key: string | undefined;
|
||||
@@ -30,6 +31,7 @@ function loadConfig(): Config {
|
||||
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_token: process.env.TTS_ELEVENLABS_TOKEN,
|
||||
steam_webapi_key: process.env.STEAM_WEBAPI_KEY,
|
||||
aws_access_id: process.env.AWS_ACCESS_ID,
|
||||
aws_access_key: process.env.AWS_ACCESS_KEY,
|
||||
|
||||
Reference in New Issue
Block a user