forked from open-webui/open-webui
Merge pull request #563 from yeahdongcn/main
Add default voice setting and apply to chat
This commit is contained in:
commit
755cadb522
3 changed files with 49 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
<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 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,6 +117,8 @@
|
||||||
} else {
|
} else {
|
||||||
speaking = true;
|
speaking = true;
|
||||||
const speak = new SpeechSynthesisUtterance(message.content);
|
const speak = new SpeechSynthesisUtterance(message.content);
|
||||||
|
const voice = $voices?.filter((v) => v.name === $settings?.speakVoice)?.at(0) ?? undefined;
|
||||||
|
speak.voice = voice;
|
||||||
speechSynthesis.speak(speak);
|
speechSynthesis.speak(speak);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
import { createNewChat, deleteAllChats, getAllChats, getChatList } from '$lib/apis/chats';
|
import { createNewChat, deleteAllChats, getAllChats, getChatList } from '$lib/apis/chats';
|
||||||
import { WEB_UI_VERSION, WEBUI_API_BASE_URL } from '$lib/constants';
|
import { WEB_UI_VERSION, WEBUI_API_BASE_URL } from '$lib/constants';
|
||||||
|
|
||||||
import { config, models, settings, user, chats } from '$lib/stores';
|
import { config, models, voices, settings, user, chats } from '$lib/stores';
|
||||||
import { splitStream, getGravatarURL, getImportOrigin, convertOpenAIChats } from '$lib/utils';
|
import { splitStream, getGravatarURL, getImportOrigin, convertOpenAIChats } from '$lib/utils';
|
||||||
|
|
||||||
import Advanced from './Settings/Advanced.svelte';
|
import Advanced from './Settings/Advanced.svelte';
|
||||||
|
@ -112,6 +112,9 @@
|
||||||
let gravatarEmail = '';
|
let gravatarEmail = '';
|
||||||
let titleAutoGenerateModel = '';
|
let titleAutoGenerateModel = '';
|
||||||
|
|
||||||
|
// Voice
|
||||||
|
let speakVoice = '';
|
||||||
|
|
||||||
// Chats
|
// Chats
|
||||||
let saveChatHistory = true;
|
let saveChatHistory = true;
|
||||||
let importFiles;
|
let importFiles;
|
||||||
|
@ -614,6 +617,18 @@
|
||||||
titleAutoGenerateModel = settings.titleAutoGenerateModel ?? '';
|
titleAutoGenerateModel = settings.titleAutoGenerateModel ?? '';
|
||||||
gravatarEmail = settings.gravatarEmail ?? '';
|
gravatarEmail = settings.gravatarEmail ?? '';
|
||||||
|
|
||||||
|
speakVoice = settings.speakVoice ?? '';
|
||||||
|
|
||||||
|
const getVoicesLoop = setInterval(async () => {
|
||||||
|
const _voices = await speechSynthesis.getVoices();
|
||||||
|
await voices.set(_voices);
|
||||||
|
|
||||||
|
// do your loop
|
||||||
|
if (_voices.length > 0) {
|
||||||
|
clearInterval(getVoicesLoop);
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
|
||||||
saveChatHistory = settings.saveChatHistory ?? true;
|
saveChatHistory = settings.saveChatHistory ?? true;
|
||||||
|
|
||||||
authEnabled = settings.authHeader !== undefined ? true : false;
|
authEnabled = settings.authHeader !== undefined ? true : false;
|
||||||
|
@ -1602,6 +1617,9 @@
|
||||||
<form
|
<form
|
||||||
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({
|
||||||
|
speakVoice: speakVoice !== '' ? speakVoice : undefined
|
||||||
|
});
|
||||||
show = false;
|
show = false;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@ -1720,7 +1738,31 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- <hr class=" dark:border-gray-700" />
|
<hr class=" dark:border-gray-700" />
|
||||||
|
|
||||||
|
<div class=" space-y-3">
|
||||||
|
<div>
|
||||||
|
<div class=" mb-2.5 text-sm font-medium">Set Default Voice</div>
|
||||||
|
<div class="flex w-full">
|
||||||
|
<div class="flex-1">
|
||||||
|
<select
|
||||||
|
class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
|
||||||
|
bind:value={speakVoice}
|
||||||
|
placeholder="Select a voice"
|
||||||
|
>
|
||||||
|
<option value="" selected>Default</option>
|
||||||
|
{#each $voices.filter((v) => v.localService === true) as voice}
|
||||||
|
<option value={voice.name} class="bg-gray-100 dark:bg-gray-700"
|
||||||
|
>{voice.name}</option
|
||||||
|
>
|
||||||
|
{/each}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--
|
||||||
<div>
|
<div>
|
||||||
<div class=" mb-2.5 text-sm font-medium">
|
<div class=" mb-2.5 text-sm font-medium">
|
||||||
Gravatar Email <span class=" text-gray-400 text-sm">(optional)</span>
|
Gravatar Email <span class=" text-gray-400 text-sm">(optional)</span>
|
||||||
|
|
|
@ -12,6 +12,7 @@ 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([]);
|
||||||
|
|
Loading…
Reference in a new issue