Commit 66f86062 authored by Timothy J. Baek's avatar Timothy J. Baek
Browse files

feat: merge one word sentence

parent f01428f5
...@@ -151,7 +151,22 @@ ...@@ -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) => {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment