Skip to content

Commit ddbc525

Browse files
EtanHeycodex
andauthored
fix(speech): removing filler words no longer joins paragraphs (pingdotgg#34101)
Co-authored-by: GPT-6.1 Sol <[email protected]>
1 parent fe5b51e commit ddbc525

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

‎apps/server/src/speech/SpeechService.test.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,24 @@ it.effect("unloads after the chosen idle period and reloads on the next recordin
533533
);
534534

535535
it.effect.each([
536+
{
537+
cue: undefined,
538+
remove: true,
539+
text: "First paragraph.\n\nSecond paragraph.",
540+
expected: "First paragraph.\n\nSecond paragraph.",
541+
},
542+
{
543+
cue: undefined,
544+
remove: true,
545+
text: "First um\n\nuh Second.",
546+
expected: "First\n\nSecond.",
547+
},
548+
{
549+
cue: undefined,
550+
remove: true,
551+
text: "First um\r\n\r\nuh Second.",
552+
expected: "First\r\n\r\nSecond.",
553+
},
536554
{ cue: "um", remove: true, text: "Make it red, um, blue.", expected: "Make it red, um, blue." },
537555
{
538556
cue: "uh no",

‎apps/server/src/speech/fillerWords.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,8 @@ export function removeSpeechFillerWords(
3838
"giu",
3939
);
4040
const filtered = text.replace(pattern, (_match, cue: string | undefined) => cue ?? "");
41-
return filtered.replace(/\s{2,}/g, " ").trim();
41+
return filtered
42+
.replace(/[^\S\r\n]{2,}/g, " ")
43+
.replace(/[^\S\r\n]*([\r\n])[^\S\r\n]*/g, "$1")
44+
.trim();
4245
}

0 commit comments

Comments
 (0)