mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-13 12:55:19 +00:00
enh: voice call skip code block & expression
This commit is contained in:
parent
fd96c9c68d
commit
6e084b4a73
1 changed files with 5 additions and 1 deletions
|
|
@ -506,12 +506,16 @@ export const removeEmojis = (str) => {
|
||||||
return str.replace(emojiRegex, '');
|
return str.replace(emojiRegex, '');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const removeFormattings = (str) => {
|
||||||
|
return str.replace(/(\*)(.*?)\1/g, '').replace(/(```)(.*?)\1/gs, '');
|
||||||
|
};
|
||||||
|
|
||||||
export const extractSentences = (text) => {
|
export const extractSentences = (text) => {
|
||||||
// Split the paragraph into sentences based on common punctuation marks
|
// Split the paragraph into sentences based on common punctuation marks
|
||||||
const sentences = text.split(/(?<=[.!?])\s+/);
|
const sentences = text.split(/(?<=[.!?])\s+/);
|
||||||
|
|
||||||
return sentences
|
return sentences
|
||||||
.map((sentence) => removeEmojis(sentence.trim()))
|
.map((sentence) => removeFormattings(removeEmojis(sentence.trim())))
|
||||||
.filter((sentence) => sentence !== '');
|
.filter((sentence) => sentence !== '');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue