From cb0752b9c7d7fd39cb18f8418beadf1fa45067b7 Mon Sep 17 00:00:00 2001 From: Elijah R Date: Sun, 14 Jul 2024 22:46:58 -0400 Subject: [PATCH] make chat bubbles not dependant on TTS --- webapp/src/ts/client.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/webapp/src/ts/client.ts b/webapp/src/ts/client.ts index 7da732d..73bbcdc 100644 --- a/webapp/src/ts/client.ts +++ b/webapp/src/ts/client.ts @@ -335,6 +335,10 @@ export class MSAgentClient { if (user?.muted) return; this.events.emit('chat', user, chatMsg.data.message); + + user?.agent.speak(chatMsg.data.message); + let msgId = ++user!.msgId; + if (chatMsg.data.audio !== undefined) { let audio = new Audio(this.url + chatMsg.data.audio); if (this.playingAudio.has(user!.username)) { @@ -344,8 +348,6 @@ export class MSAgentClient { this.playingAudio.set(user!.username, audio); - let msgId = ++user!.msgId; - audio.addEventListener('ended', () => { // give a bit of time before the wordballoon disappears setTimeout(() => { @@ -356,8 +358,13 @@ export class MSAgentClient { }, 1000); }); - user?.agent.speak(chatMsg.data.message); audio.play(); + } else { + setTimeout(() => { + if (user!.msgId === msgId) { + user!.agent.stopSpeaking(); + } + }, 5000); } break; }