Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions apps/server/src/speech/SpeechService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,24 @@ it.effect("unloads after the chosen idle period and reloads on the next recordin
);

it.effect.each([
{
cue: undefined,
remove: true,
text: "First paragraph.\n\nSecond paragraph.",
expected: "First paragraph.\n\nSecond paragraph.",
},
{
cue: undefined,
remove: true,
text: "First um\n\nuh Second.",
expected: "First\n\nSecond.",
},
{
cue: undefined,
remove: true,
text: "First um\r\n\r\nuh Second.",
expected: "First\r\n\r\nSecond.",
},
{ cue: "um", remove: true, text: "Make it red, um, blue.", expected: "Make it red, um, blue." },
{
cue: "uh no",
Expand Down
5 changes: 4 additions & 1 deletion apps/server/src/speech/fillerWords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@ export function removeSpeechFillerWords(
"giu",
);
const filtered = text.replace(pattern, (_match, cue: string | undefined) => cue ?? "");
return filtered.replace(/\s{2,}/g, " ").trim();
return filtered
.replace(/[^\S\r\n]{2,}/g, " ")
.replace(/[^\S\r\n]*([\r\n])[^\S\r\n]*/g, "$1")
.trim();
}
Loading