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
7f260938
"src/vscode:/vscode.git/clone" did not exist on "2ea45ae989e82b628e0869a40f510b5b9a4168ef"
Commit
7f260938
authored
Aug 02, 2024
by
Timothy J. Baek
Browse files
refac
parent
c416444e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
25 deletions
+24
-25
src/lib/components/chat/Settings/Audio.svelte
src/lib/components/chat/Settings/Audio.svelte
+24
-25
No files found.
src/lib/components/chat/Settings/Audio.svelte
View file @
7f260938
<script lang="ts">
<script lang="ts">
import { user, settings, config } from '$lib/stores';
import { createEventDispatcher, onMount, getContext } from 'svelte';
import { toast } from 'svelte-sonner';
import { toast } from 'svelte-sonner';
import { createEventDispatcher, onMount, getContext } from 'svelte';
import { user, settings, config } from '$lib/stores';
import { getVoices as _getVoices } from '$lib/apis/audio';
import Switch from '$lib/components/common/Switch.svelte';
import Switch from '$lib/components/common/Switch.svelte';
const dispatch = createEventDispatcher();
const dispatch = createEventDispatcher();
...
@@ -20,26 +23,26 @@
...
@@ -20,26 +23,26 @@
let voices = [];
let voices = [];
let voice = '';
let voice = '';
const getOpenAIVoices = () => {
const getVoices = async () => {
voices = [
if ($config.audio.tts.engine === '') {
{ name: 'alloy' },
const getVoicesLoop = setInterval(async () => {
{ name: 'echo' },
voices = await speechSynthesis.getVoices();
{ name: 'fable' },
{ name: 'onyx' },
{ name: 'nova' },
{ name: 'shimmer' }
];
};
const getWebAPIVoices = () => {
// do your loop
const getVoicesLoop = setInterval(async () => {
if (voices.length > 0) {
voices = await speechSynthesis.getVoices();
clearInterval(getVoicesLoop);
}
}, 100);
} else {
const res = await _getVoices(localStorage.token).catch((e) => {
toast.error(e);
});
// do your loop
if (res) {
if (voices.length > 0) {
console.log(res);
clearInterval(getVoicesLoop)
;
voices = res.voices
;
}
}
}
, 100);
}
};
};
const toggleResponseAutoPlayback = async () => {
const toggleResponseAutoPlayback = async () => {
...
@@ -61,11 +64,7 @@
...
@@ -61,11 +64,7 @@
voice = $settings?.audio?.tts?.voice ?? $config.audio.tts.voice ?? '';
voice = $settings?.audio?.tts?.voice ?? $config.audio.tts.voice ?? '';
nonLocalVoices = $settings.audio?.tts?.nonLocalVoices ?? false;
nonLocalVoices = $settings.audio?.tts?.nonLocalVoices ?? false;
if ($config.audio.tts.engine === 'openai') {
await getVoices();
getOpenAIVoices();
} else {
getWebAPIVoices();
}
});
});
</script>
</script>
...
@@ -195,7 +194,7 @@
...
@@ -195,7 +194,7 @@
<datalist id="voice-list">
<datalist id="voice-list">
{#each voices as voice}
{#each voices as voice}
<option value={voice.
name} /
>
<option value={voice.
id}>{voice.name}</option
>
{/each}
{/each}
</datalist>
</datalist>
</div>
</div>
...
...
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