mirror of
https://github.com/open-webui/open-webui
synced 2024-11-06 16:59:42 +00:00
feat: merge one word sentence
This commit is contained in:
parent
f01428f502
commit
66f86062b8
@ -151,7 +151,22 @@
|
|||||||
if ($settings?.speech?.engine === 'openai') {
|
if ($settings?.speech?.engine === 'openai') {
|
||||||
loadingSpeech = true;
|
loadingSpeech = true;
|
||||||
|
|
||||||
const sentences = extractSentences(message.content);
|
const sentences = extractSentences(message.content).reduce((mergedTexts, currentText) => {
|
||||||
|
const lastIndex = mergedTexts.length - 1;
|
||||||
|
if (lastIndex >= 0) {
|
||||||
|
const previousText = mergedTexts[lastIndex];
|
||||||
|
const wordCount = previousText.split(/\s+/).length;
|
||||||
|
if (wordCount < 2) {
|
||||||
|
mergedTexts[lastIndex] = previousText + ' ' + currentText;
|
||||||
|
} else {
|
||||||
|
mergedTexts.push(currentText);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mergedTexts.push(currentText);
|
||||||
|
}
|
||||||
|
return mergedTexts;
|
||||||
|
}, []);
|
||||||
|
|
||||||
console.log(sentences);
|
console.log(sentences);
|
||||||
|
|
||||||
sentencesAudio = sentences.reduce((a, e, i, arr) => {
|
sentencesAudio = sentences.reduce((a, e, i, arr) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user