From 5eff0e5f61d405b2b167b7bd69db0c7b97d9894c Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Fri, 9 Feb 2024 16:00:39 -0800 Subject: [PATCH] feat: tts automatic playback --- .../chat/Messages/ResponseMessage.svelte | 1 + .../components/chat/Settings/Interface.svelte | 32 +------ src/lib/components/chat/Settings/Voice.svelte | 90 +++++++++++++++---- src/routes/(app)/+page.svelte | 8 ++ src/routes/(app)/c/[id]/+page.svelte | 8 ++ 5 files changed, 93 insertions(+), 46 deletions(-) diff --git a/src/lib/components/chat/Messages/ResponseMessage.svelte b/src/lib/components/chat/Messages/ResponseMessage.svelte index 0568630b..b1c0c817 100644 --- a/src/lib/components/chat/Messages/ResponseMessage.svelte +++ b/src/lib/components/chat/Messages/ResponseMessage.svelte @@ -458,6 +458,7 @@ - - -
Response AutoCopy to Clipboard
@@ -146,9 +119,12 @@
+
-
Display the username instead of "You" in the Chat
+
+ Display the username instead of "You" in the Chat +
+
+ +
+
TTS Automatic Playback
+ +
diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte index 8b16ade0..b213a5d4 100644 --- a/src/routes/(app)/+page.svelte +++ b/src/routes/(app)/+page.svelte @@ -448,6 +448,10 @@ if ($settings.responseAutoCopy) { copyToClipboard(responseMessage.content); } + + if ($settings.responseAutoPlayback) { + document.getElementById(`speak-button-${responseMessage.id}`)?.click(); + } } } } @@ -633,6 +637,10 @@ copyToClipboard(responseMessage.content); } + if ($settings.responseAutoPlayback) { + document.getElementById(`speak-button-${responseMessage.id}`)?.click(); + } + if (autoScroll) { window.scrollTo({ top: document.body.scrollHeight }); } diff --git a/src/routes/(app)/c/[id]/+page.svelte b/src/routes/(app)/c/[id]/+page.svelte index 60eb7cec..58fbc046 100644 --- a/src/routes/(app)/c/[id]/+page.svelte +++ b/src/routes/(app)/c/[id]/+page.svelte @@ -462,6 +462,10 @@ if ($settings.responseAutoCopy) { copyToClipboard(responseMessage.content); } + + if ($settings.responseAutoPlayback) { + document.getElementById(`speak-button-${responseMessage.id}`)?.click(); + } } } } @@ -647,6 +651,10 @@ copyToClipboard(responseMessage.content); } + if ($settings.responseAutoPlayback) { + document.getElementById(`speak-button-${responseMessage.id}`)?.click(); + } + if (autoScroll) { window.scrollTo({ top: document.body.scrollHeight }); }