feat: speech recognition auto send toggle

This commit is contained in:
Timothy J. Baek 2023-11-11 13:20:42 -08:00
parent 2a4beae5d9
commit 526fcb02c3
2 changed files with 34 additions and 3 deletions

View file

@ -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 ?? '';
}
</script>
@ -501,7 +508,7 @@
<button
class="p-1 px-3 text-xs flex rounded transition"
on:click={() => {
togglerequestFormat();
toggleRequestFormat();
}}
>
{#if requestFormat === ''}
@ -740,6 +747,27 @@
}}
>
<div class=" space-y-3">
<div>
<div class=" py-1 flex w-full justify-between">
<div class=" self-center text-sm font-medium">Speech Auto-Send</div>
<button
class="p-1 px-3 text-xs flex rounded transition"
on:click={() => {
toggleSpeechAutoSend();
}}
type="button"
>
{#if speechAutoSend === true}
<span class="ml-2 self-center">On</span>
{:else}
<span class="ml-2 self-center">Off</span>
{/if}
</button>
</div>
</div>
<hr class=" dark:border-gray-700" />
<div>
<div class=" mb-2.5 text-sm font-medium">
Gravatar Email <span class=" text-gray-400 text-sm">(optional)</span>

View file

@ -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