From 6031b94a3b0f43f270e5de191f7fa2b2285a1c33 Mon Sep 17 00:00:00 2001 From: Elijah R Date: Mon, 25 Nov 2024 19:30:38 -0500 Subject: [PATCH] fix tts multiroom probably --- server/src/index.ts | 4 ++-- server/src/room.ts | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/server/src/index.ts b/server/src/index.ts index 366faa9..05f7922 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -108,7 +108,7 @@ if (config.discord.enabled) { // Image upload let img = new ImageUploader(app, config.images); -let primaryRoom = new MSAgentChatRoom(config.chat, rootLogger.child({module: "Room#Default"}), config.agents, db, img, tts, discord); +let primaryRoom = new MSAgentChatRoom("default", config.chat, rootLogger.child({module: "Room#Default"}), config.agents, db, img, tts, discord); let rooms = new Map(); @@ -153,7 +153,7 @@ app.register(async (app) => { if (rooms.has(requestedRoom)) { room = rooms.get(requestedRoom)!; } else { - room = new MSAgentChatRoom(config.chat, rootLogger.child({module: `Room#${requestedRoom}`}), config.agents, db, img, tts, null); + room = new MSAgentChatRoom(requestedRoom, config.chat, rootLogger.child({module: `Room#${requestedRoom}`}), config.agents, db, img, tts, null); rooms.set(requestedRoom, room); } } else { diff --git a/server/src/room.ts b/server/src/room.ts index a01c2f8..b7704ab 100644 --- a/server/src/room.ts +++ b/server/src/room.ts @@ -27,8 +27,9 @@ export class MSAgentChatRoom { img: ImageUploader; discord: DiscordLogger | null; private logger: Logger; + private id: string; - constructor(config: ChatConfig, logger: Logger, agents: AgentConfig[], db: Database, img: ImageUploader, tts: TTSClient | null, discord: DiscordLogger | null) { + constructor(id: string, config: ChatConfig, logger: Logger, agents: AgentConfig[], db: Database, img: ImageUploader, tts: TTSClient | null, discord: DiscordLogger | null) { this.agents = agents; this.clients = []; this.config = config; @@ -37,6 +38,7 @@ export class MSAgentChatRoom { this.img = img; this.discord = discord; this.logger = logger; + this.id = id; } addClient(client: Client) { @@ -106,7 +108,7 @@ export class MSAgentChatRoom { }; if (this.tts !== null) { try { - let filename = await this.tts.synthesizeToFile(message, (++this.msgId).toString(10)); + let filename = await this.tts.synthesizeToFile(message, `${this.id}-${++this.msgId}`); msg.data.audio = '/api/tts/' + filename; } catch (e) { this.logger.error(`Error synthesizing TTS: ${(e as Error).message}`);