From 526fcb02c38ae6b77f65373b6b5d6a52b03426a5 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sat, 11 Nov 2023 13:20:42 -0800 Subject: [PATCH] feat: speech recognition auto send toggle --- src/lib/components/chat/SettingsModal.svelte | 34 ++++++++++++++++++-- src/routes/+page.svelte | 3 ++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/lib/components/chat/SettingsModal.svelte b/src/lib/components/chat/SettingsModal.svelte index 10363df2..e0404267 100644 --- a/src/lib/components/chat/SettingsModal.svelte +++ b/src/lib/components/chat/SettingsModal.svelte @@ -31,6 +31,7 @@ let pullProgress = null; // Addons + let speechAutoSend = false; let gravatarEmail = ''; let OPENAI_API_KEY = ''; @@ -89,7 +90,7 @@ document.documentElement.classList.add(theme); }; - const togglerequestFormat = async () => { + const toggleRequestFormat = async () => { if (requestFormat === '') { requestFormat = 'json'; } else { @@ -99,6 +100,11 @@ saveSettings({ requestFormat: requestFormat !== '' ? requestFormat : undefined }); }; + const toggleSpeechAutoSend = async () => { + speechAutoSend = !speechAutoSend; + saveSettings({ speechAutoSend: speechAutoSend }); + }; + const pullModelHandler = async () => { const res = await fetch(`${API_BASE_URL}/pull`, { method: 'POST', @@ -218,8 +224,9 @@ top_k = settings.top_k ?? 40; top_p = settings.top_p ?? 0.9; - OPENAI_API_KEY = settings.OPENAI_API_KEY ?? ''; + speechAutoSend = settings.speechAutoSend ?? false; gravatarEmail = settings.gravatarEmail ?? ''; + OPENAI_API_KEY = settings.OPENAI_API_KEY ?? ''; } @@ -501,7 +508,7 @@ + + + +
Gravatar Email (optional) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 30ca753f..98362453 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -235,6 +235,9 @@ // Restart recognition after it ends console.log('recognition ended'); speechRecognitionListening = false; + if (prompt !== '' && settings?.speechAutoSend === true) { + submitPrompt(prompt); + } }; // Event triggered when an error occurs