Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
ce31113a
"...git@developer.sourcefind.cn:chenpangpang/open-webui.git" did not exist on "c0ca4470417b8d73f21633bf0ec295961830bfd2"
Commit
ce31113a
authored
Feb 05, 2024
by
Timothy J. Baek
Browse files
refac: web api voice
parent
efd546ff
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
43 deletions
+48
-43
src/lib/components/chat/Messages/ResponseMessage.svelte
src/lib/components/chat/Messages/ResponseMessage.svelte
+15
-5
src/lib/components/chat/Settings/Voice.svelte
src/lib/components/chat/Settings/Voice.svelte
+33
-37
src/lib/stores/index.ts
src/lib/stores/index.ts
+0
-1
No files found.
src/lib/components/chat/Messages/ResponseMessage.svelte
View file @
ce31113a
<script lang="ts">
<script lang="ts">
import dayjs from 'dayjs';
import dayjs from 'dayjs';
import { marked } from 'marked';
import { marked } from 'marked';
import { settings
, voices
} from '$lib/stores';
import { settings } from '$lib/stores';
import tippy from 'tippy.js';
import tippy from 'tippy.js';
import auto_render from 'katex/dist/contrib/auto-render.mjs';
import auto_render from 'katex/dist/contrib/auto-render.mjs';
import 'katex/dist/katex.min.css';
import 'katex/dist/katex.min.css';
...
@@ -116,10 +116,20 @@
...
@@ -116,10 +116,20 @@
speaking = null;
speaking = null;
} else {
} else {
speaking = true;
speaking = true;
const speak = new SpeechSynthesisUtterance(message.content);
const voice = $voices?.filter((v) => v.name === $settings?.speakVoice)?.at(0) ?? undefined;
let voices = [];
speak.voice = voice;
const getVoicesLoop = setInterval(async () => {
speechSynthesis.speak(speak);
voices = await speechSynthesis.getVoices();
if (voices.length > 0) {
clearInterval(getVoicesLoop);
const voice = voices?.filter((v) => v.name === $settings?.speaker)?.at(0) ?? undefined;
const speak = new SpeechSynthesisUtterance(message.content);
speak.voice = voice;
speechSynthesis.speak(speak);
}
}, 100);
}
}
};
};
...
...
src/lib/components/chat/Settings/Voice.svelte
View file @
ce31113a
<script lang="ts">
<script lang="ts">
import { createEventDispatcher, onMount } from 'svelte';
import { createEventDispatcher, onMount } from 'svelte';
import { voices } from '$lib/stores';
const dispatch = createEventDispatcher();
const dispatch = createEventDispatcher();
export let saveSettings: Function;
export let saveSettings: Function;
// Voice
// Voice
let speakVoice = '';
let engines = ['', 'openai'];
let selectedEngine = '';
let voices = [];
let speaker = '';
onMount(async () => {
onMount(async () => {
let settings = JSON.parse(localStorage.getItem('settings') ?? '{}');
let settings = JSON.parse(localStorage.getItem('settings') ?? '{}');
speak
Voic
e = settings.speak
Voic
e ?? '';
speake
r
= settings.speake
r
?? '';
const getVoicesLoop = setInterval(async () => {
const getVoicesLoop = setInterval(async () => {
const _voices = await speechSynthesis.getVoices();
voices = await speechSynthesis.getVoices();
await voices.set(_voices);
// do your loop
// do your loop
if (
_
voices.length > 0) {
if (voices.length > 0) {
clearInterval(getVoicesLoop);
clearInterval(getVoicesLoop);
}
}
}, 100);
}, 100);
...
@@ -29,24 +31,43 @@
...
@@ -29,24 +31,43 @@
class="flex flex-col h-full justify-between space-y-3 text-sm"
class="flex flex-col h-full justify-between space-y-3 text-sm"
on:submit|preventDefault={() => {
on:submit|preventDefault={() => {
saveSettings({
saveSettings({
speak
Voic
e: speak
Voic
e !== '' ? speak
Voic
e : undefined
speake
r
: speake
r
!== '' ? speake
r
: undefined
});
});
dispatch('save');
dispatch('save');
}}
}}
>
>
<div class=" space-y-3">
<div class=" space-y-3">
<div class=" space-y-3">
<div class=" py-0.5 flex w-full justify-between">
<div class=" self-center text-sm font-medium">Speech Engine</div>
<div class="flex items-center relative">
<select
class="w-fit pr-8 rounded py-2 px-2 text-xs bg-transparent outline-none text-right"
bind:value={selectedEngine}
placeholder="Select a mode"
on:change={(e) => {
console.log(e);
}}
>
<option value="">Default (Web API)</option>
<option value="openai">Open AI</option>
</select>
</div>
</div>
<hr class=" dark:border-gray-700" />
{#if selectedEngine === ''}
<div>
<div>
<div class=" mb-2.5 text-sm font-medium">Set
Default
Voice</div>
<div class=" mb-2.5 text-sm font-medium">Set Voice</div>
<div class="flex w-full">
<div class="flex w-full">
<div class="flex-1">
<div class="flex-1">
<select
<select
class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
bind:value={speak
Voic
e}
bind:value={speake
r
}
placeholder="Select a voice"
placeholder="Select a voice"
>
>
<option value="" selected>Default</option>
<option value="" selected>Default</option>
{#each
$
voices.filter((v) => v.localService === true) as voice}
{#each voices.filter((v) => v.localService === true) as voice}
<option value={voice.name} class="bg-gray-100 dark:bg-gray-700">{voice.name}</option
<option value={voice.name} class="bg-gray-100 dark:bg-gray-700">{voice.name}</option
>
>
{/each}
{/each}
...
@@ -54,32 +75,7 @@
...
@@ -54,32 +75,7 @@
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{/if}
<!--
<div>
<div class=" mb-2.5 text-sm font-medium">
Gravatar Email <span class=" text-gray-400 text-sm">(optional)</span>
</div>
<div class="flex w-full">
<div class="flex-1">
<input
class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
placeholder="Enter Your Email"
bind:value={gravatarEmail}
autocomplete="off"
type="email"
/>
</div>
</div>
<div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
Changes user profile image to match your <a
class=" text-gray-500 dark:text-gray-300 font-medium"
href="https://gravatar.com/"
target="_blank">Gravatar.</a
>
</div>
</div> -->
</div>
</div>
<div class="flex justify-end pt-3 text-sm font-medium">
<div class="flex justify-end pt-3 text-sm font-medium">
...
...
src/lib/stores/index.ts
View file @
ce31113a
...
@@ -12,7 +12,6 @@ export const chatId = writable('');
...
@@ -12,7 +12,6 @@ export const chatId = writable('');
export
const
chats
=
writable
([]);
export
const
chats
=
writable
([]);
export
const
tags
=
writable
([]);
export
const
tags
=
writable
([]);
export
const
models
=
writable
([]);
export
const
models
=
writable
([]);
export
const
voices
=
writable
([]);
export
const
modelfiles
=
writable
([]);
export
const
modelfiles
=
writable
([]);
export
const
prompts
=
writable
([]);
export
const
prompts
=
writable
([]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment