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
c954f1b4
Commit
c954f1b4
authored
Jun 27, 2024
by
Timothy J. Baek
Browse files
refac
parent
edbd07f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
28 deletions
+33
-28
src/lib/components/chat/Messages/ResponseMessage.svelte
src/lib/components/chat/Messages/ResponseMessage.svelte
+33
-28
No files found.
src/lib/components/chat/Messages/ResponseMessage.svelte
View file @
c954f1b4
...
@@ -234,35 +234,40 @@
...
@@ -234,35 +234,40 @@
console.log(sentences);
console.log(sentences);
sentencesAudio = sentences.reduce((a, e, i, arr) => {
if (sentences.length > 0) {
a[i] = null;
sentencesAudio = sentences.reduce((a, e, i, arr) => {
return a;
a[i] = null;
}, {});
return a;
}, {});
let lastPlayedAudioPromise = Promise.resolve(); // Initialize a promise that resolves immediately
let lastPlayedAudioPromise = Promise.resolve(); // Initialize a promise that resolves immediately
for (const [idx, sentence] of sentences.entries()) {
const res = await synthesizeOpenAISpeech(
for (const [idx, sentence] of sentences.entries()) {
localStorage.token,
const res = await synthesizeOpenAISpeech(
$settings?.audio?.tts?.voice ?? $config?.audio?.tts?.voice,
localStorage.token,
sentence
$settings?.audio?.tts?.voice ?? $config?.audio?.tts?.voice,
).catch((error) => {
sentence
toast.error(error);
).catch((error) => {
toast.error(error);
speaking = null;
loadingSpeech = false;
speaking = null;
loadingSpeech = false;
return null;
});
return null;
});
if (res) {
const blob = await res.blob();
if (res) {
const blobUrl = URL.createObjectURL(blob);
const blob = await res.blob();
const audio = new Audio(blobUrl);
const blobUrl = URL.createObjectURL(blob);
sentencesAudio[idx] = audio;
const audio = new Audio(blobUrl);
loadingSpeech = false;
sentencesAudio[idx] = audio;
lastPlayedAudioPromise = lastPlayedAudioPromise.then(() => playAudio(idx));
loadingSpeech = false;
lastPlayedAudioPromise = lastPlayedAudioPromise.then(() => playAudio(idx));
}
}
}
} else {
speaking = null;
loadingSpeech = false;
}
}
} else {
} else {
let voices = [];
let voices = [];
...
...
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