fix tts multiroom probably
This commit is contained in:
parent
1385c555f4
commit
6031b94a3b
2 changed files with 6 additions and 4 deletions
|
@ -108,7 +108,7 @@ if (config.discord.enabled) {
|
||||||
// Image upload
|
// Image upload
|
||||||
let img = new ImageUploader(app, config.images);
|
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<string, MSAgentChatRoom>();
|
let rooms = new Map<string, MSAgentChatRoom>();
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ app.register(async (app) => {
|
||||||
if (rooms.has(requestedRoom)) {
|
if (rooms.has(requestedRoom)) {
|
||||||
room = rooms.get(requestedRoom)!;
|
room = rooms.get(requestedRoom)!;
|
||||||
} else {
|
} 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);
|
rooms.set(requestedRoom, room);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -27,8 +27,9 @@ export class MSAgentChatRoom {
|
||||||
img: ImageUploader;
|
img: ImageUploader;
|
||||||
discord: DiscordLogger | null;
|
discord: DiscordLogger | null;
|
||||||
private logger: Logger;
|
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.agents = agents;
|
||||||
this.clients = [];
|
this.clients = [];
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
@ -37,6 +38,7 @@ export class MSAgentChatRoom {
|
||||||
this.img = img;
|
this.img = img;
|
||||||
this.discord = discord;
|
this.discord = discord;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
addClient(client: Client) {
|
addClient(client: Client) {
|
||||||
|
@ -106,7 +108,7 @@ export class MSAgentChatRoom {
|
||||||
};
|
};
|
||||||
if (this.tts !== null) {
|
if (this.tts !== null) {
|
||||||
try {
|
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;
|
msg.data.audio = '/api/tts/' + filename;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error(`Error synthesizing TTS: ${(e as Error).message}`);
|
this.logger.error(`Error synthesizing TTS: ${(e as Error).message}`);
|
||||||
|
|
Loading…
Reference in a new issue