From 6c5e03c2ecbed99b69035b3f58cd3807093a4ca6 Mon Sep 17 00:00:00 2001 From: collissimo <148455189+collissimo@users.noreply.github.com> Date: Tue, 17 Nov 2026 19:26:46 +0100 Subject: [PATCH] fix(dictation): local dictation no longer removes filler words The transcript from the local model now reaches the composer unchanged, apart from the structure codeword at the end. Co-Authored-By: Claude Opus 5.5 --- apps/server/src/dictation/localDictation.ts | 4 +- .../src/dictation/transcriptText.test.ts | 31 +---------- apps/server/src/dictation/transcriptText.ts | 53 ------------------- 3 files changed, 3 insertions(+), 85 deletions(-) diff --git a/apps/server/src/dictation/localDictation.ts b/apps/server/src/dictation/localDictation.ts index 732ad18835472..a72d0765a24e4 100644 --- a/apps/server/src/dictation/localDictation.ts +++ b/apps/server/src/dictation/localDictation.ts @@ -18,7 +18,7 @@ import { type TranscriptResult, } from "./DictationEngine.ts"; import { findModel, findVadModel, modelDirectories } from "./modelFiles.ts"; -import { DEFAULT_STRUCTURE_CODEWORDS, removeFillers, splitCodeword } from "./transcriptText.ts"; +import { DEFAULT_STRUCTURE_CODEWORDS, splitCodeword } from "./transcriptText.ts"; const IDLE_UNLOAD_MS = 15 * 60_000; export const HOUSEKEEPING_INTERVAL_MS = 30_000; @@ -102,7 +102,7 @@ export function finishResult(result: TranscriptResult): DictationFinishResult { if (result.reason !== undefined) { return { text: "", reason: result.reason, structureRequested: false }; } - const cleaned = splitCodeword(removeFillers(result.text), DEFAULT_STRUCTURE_CODEWORDS); + const cleaned = splitCodeword(result.text, DEFAULT_STRUCTURE_CODEWORDS); if (cleaned.text === "") return { text: "", reason: "no-speech", structureRequested: false }; return { text: cleaned.text, structureRequested: cleaned.found }; } diff --git a/apps/server/src/dictation/transcriptText.test.ts b/apps/server/src/dictation/transcriptText.test.ts index 2eb6b8c2883bb..c748a86afbe6c 100644 --- a/apps/server/src/dictation/transcriptText.test.ts +++ b/apps/server/src/dictation/transcriptText.test.ts @@ -1,35 +1,6 @@ import { describe, expect, it } from "@effect/vitest"; -import { DEFAULT_STRUCTURE_CODEWORDS, removeFillers, splitCodeword } from "./transcriptText.ts"; - -describe("removeFillers", () => { - it.each([ - ["Okay. Ähm, mir ist gerade etwas aufgefallen.", "Okay. Mir ist gerade etwas aufgefallen."], - ["dass es keinen Modus gibt, ähm, der mir hilft", "dass es keinen Modus gibt, der mir hilft"], - ["und äh das war es", "und das war es"], - ["und äh, das war es", "und das war es"], - ["Das ist gut äh, aber teuer", "Das ist gut aber teuer"], - [ - "mit meiner Stimme äh, aufzunehmen. Die äh, ist besser.", - "mit meiner Stimme aufzunehmen. Die ist besser.", - ], - ["Das passt. Ähm... Du kannst das Repo ziehen.", "Das passt. Du kannst das Repo ziehen."], - ["Ähm, genau, und es soll passen", "Genau, und es soll passen"], - ["Das Fenster, äh. Und dann", "Das Fenster. Und dann"], - ["Das war's äh.", "Das war's."], - ["Hm, mh, also ich denke mhm ja", "Also ich denke ja"], - ["um das zu testen, ähm, um zu sehen", "um das zu testen, um zu sehen"], - ["Das ist ähnlich wie bei Ämtern und Öhmd", "Das ist ähnlich wie bei Ämtern und Öhmd"], - ["5 mm Abstand und um 9 Uhr", "5 mm Abstand und um 9 Uhr"], - ["uh, please refactor this, uhm, function", "Please refactor this, function"], - ["Erste Zeile ähm\nzweite Zeile", "Erste Zeile\nzweite Zeile"], - ["Ähm.", ""], - ["Kein Füllwort hier.", "Kein Füllwort hier."], - ["weil, äh, ich das hm brauche", "weil, ich das brauche"], - ])("%j", (spoken, expected) => { - expect(removeFillers(spoken)).toBe(expected); - }); -}); +import { DEFAULT_STRUCTURE_CODEWORDS, splitCodeword } from "./transcriptText.ts"; describe("splitCodeword", () => { const codewords = ["Reinschrift", "Prompt aufräumen"]; diff --git a/apps/server/src/dictation/transcriptText.ts b/apps/server/src/dictation/transcriptText.ts index 8ff168eb839b1..711994349b56b 100644 --- a/apps/server/src/dictation/transcriptText.ts +++ b/apps/server/src/dictation/transcriptText.ts @@ -1,58 +1,5 @@ // Cleanup of a dictated transcript before it reaches the composer. -// Only sounds that are never words, so removing them cannot change what was said. Words that -// merely pad a sentence ("also", "halt") stay, and so does "um", which is a German word. -const FILLER = - "(?:" + - "ä+h*m*" + // ä, äh, ähm - "|ö+h+m*|ö+m+" + // öh, öhm, öm - "|e+h+m+|e+rm+" + // ehm, erm - "|h+m+h*" + // hm, hmm - "|m+h+m*" + // mh, mhm - "|mmm+" + // mmm, but not "mm" (millimetres) - "|u+h+m*|u+mm+" + // uh, uhm, umm - ")"; -const WORD_CHAR = "[\\p{L}\\p{N}_'’\\-]"; -// A filler together with the punctuation the transcriber attached to it. -const FILLER_PATTERN = new RegExp( - `(? { - const before = text.slice(0, offset).trimEnd(); - if (before === "" || SENTENCE_END.includes(before.at(-1)!)) { - // "Okay. Ähm, mir ..." -> "Okay. Mir ...": the next word now opens the sentence. - return CAPITALIZE; - } - if (after !== undefined && SENTENCE_END.includes(after[0]!)) { - // "..., äh. Und" -> "... . Und": the sentence end wins over the comma before it. - return SENTENCE_END_MARK + after; - } - // A comma after the filler belongs to the filler: transcripts read "Stimme äh, aufzunehmen", - // and keeping it would leave "Stimme, aufzunehmen". - return ""; - }, - ); - cleaned = cleaned.replace(/[,;:]?\s*/gu, ""); - cleaned = cleaned.replace( - /[ \t]*([\p{L}\p{N}_])/gu, - (_match, first: string) => ` ${first.toUpperCase()}`, - ); - cleaned = cleaned.replaceAll(CAPITALIZE, ""); - cleaned = cleaned.replace(/[ \t]{2,}/gu, " "); - cleaned = cleaned.replace(/[ \t]+([,;:.!?…])/gu, "$1"); - cleaned = cleaned.replace(/[ \t]*\n[ \t]*/gu, "\n"); - return cleaned.trim(); -} - // "Reihenschrift" is what the transcriber makes of "Reinschrift". export const DEFAULT_STRUCTURE_CODEWORDS = ["Reinschrift", "Reihenschrift"] as const; const SEPARATORS = "\\s.,;:!?…";