speechflow 2.3.1 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/.ase/service.log +10357 -0
  2. package/.ase/service.yaml +1 -0
  3. package/.claude/CLAUDE.md +1 -0
  4. package/AGENTS.md +1 -1
  5. package/CHANGELOG.md +25 -1
  6. package/README.md +10 -37
  7. package/package.json +8 -8
  8. package/speechflow-cli/dst/speechflow-main-api.js +8 -1
  9. package/speechflow-cli/dst/speechflow-main-api.js.map +1 -1
  10. package/speechflow-cli/dst/speechflow-main-graph.js +14 -5
  11. package/speechflow-cli/dst/speechflow-main-graph.js.map +1 -1
  12. package/speechflow-cli/dst/speechflow-node-a2a-mute.js +5 -1
  13. package/speechflow-cli/dst/speechflow-node-a2a-mute.js.map +1 -1
  14. package/speechflow-cli/dst/speechflow-node-a2t-deepgram.d.ts +7 -0
  15. package/speechflow-cli/dst/speechflow-node-a2t-deepgram.js +145 -62
  16. package/speechflow-cli/dst/speechflow-node-a2t-deepgram.js.map +1 -1
  17. package/speechflow-cli/dst/speechflow-node-a2t-google.js +10 -4
  18. package/speechflow-cli/dst/speechflow-node-a2t-google.js.map +1 -1
  19. package/speechflow-cli/dst/speechflow-node-a2t-openai.js +10 -4
  20. package/speechflow-cli/dst/speechflow-node-a2t-openai.js.map +1 -1
  21. package/speechflow-cli/dst/speechflow-node-t2t-google.js +3 -0
  22. package/speechflow-cli/dst/speechflow-node-t2t-google.js.map +1 -1
  23. package/speechflow-cli/dst/{speechflow-node-t2t-spellcheck.d.ts → speechflow-node-t2t-proofread.d.ts} +1 -1
  24. package/speechflow-cli/dst/{speechflow-node-t2t-spellcheck.js → speechflow-node-t2t-proofread.js} +53 -61
  25. package/speechflow-cli/dst/speechflow-node-t2t-proofread.js.map +1 -0
  26. package/speechflow-cli/dst/speechflow-node-t2t-sentence.js +64 -14
  27. package/speechflow-cli/dst/speechflow-node-t2t-sentence.js.map +1 -1
  28. package/speechflow-cli/dst/speechflow-node-t2t-summary.js +1 -1
  29. package/speechflow-cli/dst/speechflow-node-t2t-summary.js.map +1 -1
  30. package/speechflow-cli/dst/speechflow-node-t2t-translate.js +1 -1
  31. package/speechflow-cli/dst/speechflow-node-t2t-translate.js.map +1 -1
  32. package/speechflow-cli/dst/speechflow-node-xio-device.js +4 -1
  33. package/speechflow-cli/dst/speechflow-node-xio-device.js.map +1 -1
  34. package/speechflow-cli/dst/speechflow-node-xio-exec.js +4 -1
  35. package/speechflow-cli/dst/speechflow-node-xio-exec.js.map +1 -1
  36. package/speechflow-cli/dst/speechflow-util-llm.d.ts +1 -0
  37. package/speechflow-cli/dst/speechflow-util-llm.js +7 -3
  38. package/speechflow-cli/dst/speechflow-util-llm.js.map +1 -1
  39. package/speechflow-cli/dst/speechflow-util-misc.js +28 -14
  40. package/speechflow-cli/dst/speechflow-util-misc.js.map +1 -1
  41. package/speechflow-cli/dst/speechflow.js.map +1 -1
  42. package/speechflow-cli/etc/oxlint.jsonc +10 -2
  43. package/speechflow-cli/etc/stx.conf +2 -2
  44. package/speechflow-cli/package.d/{@typescript-eslint+typescript-estree+8.57.2.patch → @typescript-eslint+typescript-estree+8.60.0.patch} +1 -1
  45. package/speechflow-cli/package.json +34 -31
  46. package/speechflow-cli/src/speechflow-main-api.ts +8 -1
  47. package/speechflow-cli/src/speechflow-main-graph.ts +14 -5
  48. package/speechflow-cli/src/speechflow-node-a2a-mute.ts +6 -1
  49. package/speechflow-cli/src/speechflow-node-a2t-deepgram.ts +156 -66
  50. package/speechflow-cli/src/speechflow-node-a2t-google.ts +10 -4
  51. package/speechflow-cli/src/speechflow-node-a2t-openai.ts +10 -4
  52. package/speechflow-cli/src/speechflow-node-t2t-google.ts +3 -0
  53. package/speechflow-cli/src/{speechflow-node-t2t-spellcheck.ts → speechflow-node-t2t-proofread.ts} +61 -66
  54. package/speechflow-cli/src/speechflow-node-t2t-sentence.ts +21 -3
  55. package/speechflow-cli/src/speechflow-node-t2t-summary.ts +1 -1
  56. package/speechflow-cli/src/speechflow-node-t2t-translate.ts +1 -1
  57. package/speechflow-cli/src/speechflow-node-xio-device.ts +4 -1
  58. package/speechflow-cli/src/speechflow-node-xio-exec.ts +4 -1
  59. package/speechflow-cli/src/speechflow-util-llm.ts +8 -3
  60. package/speechflow-cli/src/speechflow-util-misc.ts +33 -16
  61. package/speechflow-cli/src/speechflow.ts +1 -0
  62. package/speechflow-ui-db/dst/index.js +19 -16
  63. package/speechflow-ui-db/etc/oxlint.jsonc +0 -1
  64. package/speechflow-ui-db/etc/stx.conf +2 -2
  65. package/speechflow-ui-db/package.d/{@typescript-eslint+typescript-estree+8.57.2.patch → @typescript-eslint+typescript-estree+8.60.0.patch} +1 -1
  66. package/speechflow-ui-db/package.json +16 -16
  67. package/speechflow-ui-st/dst/index.css +1 -1
  68. package/speechflow-ui-st/dst/index.js +33 -33
  69. package/speechflow-ui-st/etc/oxlint.jsonc +2 -2
  70. package/speechflow-ui-st/etc/stx.conf +2 -2
  71. package/speechflow-ui-st/package.d/{@typescript-eslint+typescript-estree+8.57.2.patch → @typescript-eslint+typescript-estree+8.60.0.patch} +1 -1
  72. package/speechflow-ui-st/package.json +16 -16
  73. package/speechflow-ui-st/src/app.vue +3 -3
  74. package/.claude/settings.local.json +0 -3
  75. package/speechflow-cli/dst/speechflow-node-t2t-punctuation.d.ts +0 -13
  76. package/speechflow-cli/dst/speechflow-node-t2t-punctuation.js +0 -219
  77. package/speechflow-cli/dst/speechflow-node-t2t-punctuation.js.map +0 -1
  78. package/speechflow-cli/dst/speechflow-node-t2t-spellcheck.js.map +0 -1
  79. package/speechflow-cli/src/speechflow-node-t2t-punctuation.ts +0 -200
@@ -59,7 +59,6 @@
59
59
  "no-hex-escape": "off",
60
60
  "no-labels": "off",
61
61
  "no-magic-numbers": "off",
62
- "no-minusminus": "off",
63
62
  "no-named-as-default-member": "off",
64
63
  "no-namespace": "off",
65
64
  "no-negated-condition": "off",
@@ -132,7 +131,8 @@
132
131
  "max-statements": "off",
133
132
  "no-console": "off",
134
133
  "no-unassigned-import": "off",
135
- "no-shadow": "off"
134
+ "no-shadow": "off",
135
+ "require-unicode-regexp": "off"
136
136
  }
137
137
  }
138
138
 
@@ -24,8 +24,8 @@ lint-watch
24
24
  lint
25
25
  check-dependencies && \
26
26
  vue-tsc --project etc/tsc-client.json --noEmit && \
27
- oxlint --config etc/oxlint.jsonc src/*.vue src/*.ts && \
28
- eslint --config etc/eslint.mjs src/*.vue src/*.ts && \
27
+ oxlint --config etc/oxlint.jsonc src && \
28
+ eslint --config etc/eslint.mjs src && \
29
29
  stylelint --config etc/stylelint.yaml src/*.styl src/*.vue && \
30
30
  htmllint --rc etc/htmllint.json src/*.html
31
31
 
@@ -1,5 +1,5 @@
1
1
  diff --git a/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/warnAboutTSVersion.js b/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/warnAboutTSVersion.js
2
- index 8b0402b..b83ef25 100644
2
+ index 7a133e8..6f29aa6 100644
3
3
  --- a/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/warnAboutTSVersion.js
4
4
  +++ b/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/warnAboutTSVersion.js
5
5
  @@ -75,7 +75,6 @@ function warnAboutTSVersion(parseSettings, passedLoggerFn) {
@@ -14,25 +14,25 @@
14
14
  "url": "http://engelschall.com"
15
15
  },
16
16
  "dependencies": {
17
- "vue": "3.5.31",
17
+ "vue": "3.5.35",
18
18
  "vue3-spinners": "1.3.3",
19
19
  "luxon": "3.7.2",
20
20
  "@opensumi/reconnecting-websocket": "4.4.0",
21
- "axios": "1.14.0",
21
+ "axios": "1.16.1",
22
22
  "typopro-web": "4.2.8",
23
23
  "@fortawesome/fontawesome-free": "7.2.0",
24
24
  "patch-package": "8.0.1",
25
- "@rse/stx": "1.1.4",
26
- "animejs": "4.3.6"
25
+ "@rse/stx": "1.1.5",
26
+ "animejs": "4.4.1"
27
27
  },
28
28
  "devDependencies": {
29
29
  "vite": "7.3.1",
30
- "typescript-eslint": "8.57.2",
31
- "@typescript-eslint/eslint-plugin": "8.57.2",
32
- "@typescript-eslint/parser": "8.57.2",
33
- "@vitejs/plugin-vue": "6.0.5",
34
- "@rollup/plugin-yaml": "4.1.2",
35
- "vite-plugin-node-polyfills": "0.25.0",
30
+ "typescript-eslint": "8.60.0",
31
+ "@typescript-eslint/eslint-plugin": "8.60.0",
32
+ "@typescript-eslint/parser": "8.60.0",
33
+ "@vitejs/plugin-vue": "6.0.7",
34
+ "@rollup/plugin-yaml": "5.0.0",
35
+ "vite-plugin-node-polyfills": "0.28.0",
36
36
  "vite-svg-loader": "5.1.1",
37
37
  "@liuli-util/vite-plugin-node": "0.10.0",
38
38
  "mkdirp": "3.0.1",
@@ -43,10 +43,10 @@
43
43
  "@eslint/js": "9.39.4",
44
44
  "neostandard": "0.13.0",
45
45
  "eslint-plugin-import": "2.32.0",
46
- "eslint-plugin-vue": "10.8.0",
46
+ "eslint-plugin-vue": "10.9.1",
47
47
 
48
- "oxlint": "1.57.0",
49
- "eslint-plugin-oxlint": "1.57.0",
48
+ "oxlint": "1.67.0",
49
+ "eslint-plugin-oxlint": "1.67.0",
50
50
 
51
51
  "htmllint": "0.8.0",
52
52
  "htmllint-cli": "0.0.7",
@@ -54,7 +54,7 @@
54
54
  "check-dependencies": "2.0.0",
55
55
  "nodemon": "3.1.14",
56
56
  "shx": "0.4.0",
57
- "stylelint": "17.6.0",
57
+ "stylelint": "17.12.0",
58
58
  "stylelint-config-html": "1.1.0",
59
59
  "stylelint-config-recommended-vue": "1.6.1",
60
60
  "stylelint-config-standard": "40.0.0",
@@ -62,8 +62,8 @@
62
62
  "stylelint-stylus": "1.0.0",
63
63
  "postcss-html": "1.8.1",
64
64
  "stylus": "0.64.0",
65
- "typescript": "6.0.2",
66
- "vue-tsc": "3.2.6",
65
+ "typescript": "6.0.3",
66
+ "vue-tsc": "3.3.3",
67
67
  "delay-cli": "3.0.0",
68
68
  "cross-env": "10.1.0",
69
69
  "serve": "14.2.6",
@@ -82,7 +82,7 @@
82
82
  z-index: 20
83
83
  color: #ffffff
84
84
  -webkit-text-stroke: 4px #00000000
85
- font-size: 2.0vw
85
+ font-size: 2.75vw
86
86
  font-weight: 600
87
87
  line-height: 1.3
88
88
  padding-left: 0.20vw
@@ -95,8 +95,8 @@
95
95
  z-index: -10
96
96
  position: absolute
97
97
  color: #000000
98
- -webkit-text-stroke: 5px #000000e0
99
- font-size: 2.0vw
98
+ -webkit-text-stroke: 4px #000000c0
99
+ font-size: 2.75vw
100
100
  font-weight: 600
101
101
  line-height: 1.3
102
102
  padding-left: 0.20vw
@@ -1,3 +0,0 @@
1
- {
2
- "outputStyle": "coding"
3
- }
@@ -1,13 +0,0 @@
1
- import SpeechFlowNode from "./speechflow-node";
2
- export default class SpeechFlowNodeT2TPunctuation extends SpeechFlowNode {
3
- static name: string;
4
- private llm;
5
- private setup;
6
- constructor(id: string, cfg: {
7
- [id: string]: any;
8
- }, opts: {
9
- [id: string]: any;
10
- }, args: any[]);
11
- open(): Promise<void>;
12
- close(): Promise<void>;
13
- }
@@ -1,219 +0,0 @@
1
- "use strict";
2
- /*
3
- ** SpeechFlow - Speech Processing Flow Graph
4
- ** Copyright (c) 2024-2026 Dr. Ralf S. Engelschall <rse@engelschall.com>
5
- ** Licensed under GPL 3.0 <https://spdx.org/licenses/GPL-3.0-only>
6
- */
7
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
- if (k2 === undefined) k2 = k;
9
- var desc = Object.getOwnPropertyDescriptor(m, k);
10
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
- desc = { enumerable: true, get: function() { return m[k]; } };
12
- }
13
- Object.defineProperty(o, k2, desc);
14
- }) : (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- o[k2] = m[k];
17
- }));
18
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
- Object.defineProperty(o, "default", { enumerable: true, value: v });
20
- }) : function(o, v) {
21
- o["default"] = v;
22
- });
23
- var __importStar = (this && this.__importStar) || (function () {
24
- var ownKeys = function(o) {
25
- ownKeys = Object.getOwnPropertyNames || function (o) {
26
- var ar = [];
27
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
- return ar;
29
- };
30
- return ownKeys(o);
31
- };
32
- return function (mod) {
33
- if (mod && mod.__esModule) return mod;
34
- var result = {};
35
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
- __setModuleDefault(result, mod);
37
- return result;
38
- };
39
- })();
40
- var __importDefault = (this && this.__importDefault) || function (mod) {
41
- return (mod && mod.__esModule) ? mod : { "default": mod };
42
- };
43
- Object.defineProperty(exports, "__esModule", { value: true });
44
- /* standard dependencies */
45
- const node_stream_1 = __importDefault(require("node:stream"));
46
- /* internal dependencies */
47
- const speechflow_node_1 = __importDefault(require("./speechflow-node"));
48
- const util = __importStar(require("./speechflow-util"));
49
- const speechflow_util_llm_1 = require("./speechflow-util-llm");
50
- /* SpeechFlow node for text-to-text punctuation restoration */
51
- class SpeechFlowNodeT2TPunctuation extends speechflow_node_1.default {
52
- /* declare official node name */
53
- static name = "t2t-punctuation";
54
- /* internal state */
55
- llm = null;
56
- /* internal LLM setup */
57
- setup = {
58
- /* English (EN) punctuation restoration */
59
- "en": {
60
- systemPrompt: "You are a punctuation restoration specialist for English.\n" +
61
- "Your task is to add missing punctuation to unpunctuated text.\n" +
62
- "Output only the punctuated text.\n" +
63
- "Do NOT use markdown.\n" +
64
- "Do NOT give any explanations.\n" +
65
- "Do NOT give any introduction.\n" +
66
- "Do NOT give any comments.\n" +
67
- "Do NOT give any preamble.\n" +
68
- "Do NOT give any prolog.\n" +
69
- "Do NOT give any epilog.\n" +
70
- "Do NOT change the words.\n" +
71
- "Do NOT add or remove words.\n" +
72
- "Do NOT fix spelling errors.\n" +
73
- "Do NOT change the grammar.\n" +
74
- "Do NOT use synonyms.\n" +
75
- "Keep all original words exactly as they are.\n" +
76
- "Add periods at sentence endings.\n" +
77
- "Add commas where appropriate.\n" +
78
- "Add question marks for questions.\n" +
79
- "Add exclamation marks where appropriate.\n" +
80
- "Add colons and semicolons where appropriate.\n" +
81
- "Capitalize first letters of sentences.\n" +
82
- "The text you have to punctuate is:\n",
83
- chat: [
84
- { role: "user", content: "hello how are you today" },
85
- { role: "assistant", content: "Hello, how are you today?" },
86
- { role: "user", content: "i went to the store and bought some milk eggs and bread" },
87
- { role: "assistant", content: "I went to the store and bought some milk, eggs, and bread." },
88
- { role: "user", content: "what time is it i need to leave soon" },
89
- { role: "assistant", content: "What time is it? I need to leave soon." },
90
- { role: "user", content: "thats amazing i cant believe it worked" },
91
- { role: "assistant", content: "That's amazing! I can't believe it worked!" }
92
- ]
93
- },
94
- /* German (DE) punctuation restoration */
95
- "de": {
96
- systemPrompt: "Du bist ein Spezialist für Zeichensetzung im Deutschen.\n" +
97
- "Deine Aufgabe ist es, fehlende Satzzeichen in unpunktierten Text einzufügen.\n" +
98
- "Gib nur den punktierten Text aus.\n" +
99
- "Benutze KEIN Markdown.\n" +
100
- "Gib KEINE Erklärungen.\n" +
101
- "Gib KEINE Einleitung.\n" +
102
- "Gib KEINE Kommentare.\n" +
103
- "Gib KEINE Präambel.\n" +
104
- "Gib KEINEN Prolog.\n" +
105
- "Gib KEINEN Epilog.\n" +
106
- "Ändere NICHT die Wörter.\n" +
107
- "Füge KEINE Wörter hinzu oder entferne welche.\n" +
108
- "Korrigiere KEINE Rechtschreibfehler.\n" +
109
- "Ändere NICHT die Grammatik.\n" +
110
- "Verwende KEINE Synonyme.\n" +
111
- "Behalte alle ursprünglichen Wörter genau bei.\n" +
112
- "Füge Punkte am Satzende ein.\n" +
113
- "Füge Kommas an passenden Stellen ein.\n" +
114
- "Füge Fragezeichen bei Fragen ein.\n" +
115
- "Füge Ausrufezeichen an passenden Stellen ein.\n" +
116
- "Füge Doppelpunkte und Semikolons an passenden Stellen ein.\n" +
117
- "Großschreibe die ersten Buchstaben von Sätzen.\n" +
118
- "Der von dir zu punktierende Text ist:\n",
119
- chat: [
120
- { role: "user", content: "hallo wie geht es dir heute" },
121
- { role: "assistant", content: "Hallo, wie geht es dir heute?" },
122
- { role: "user", content: "ich bin in den laden gegangen und habe milch eier und brot gekauft" },
123
- { role: "assistant", content: "Ich bin in den Laden gegangen und habe Milch, Eier und Brot gekauft." },
124
- { role: "user", content: "wie spät ist es ich muss bald los" },
125
- { role: "assistant", content: "Wie spät ist es? Ich muss bald los." },
126
- { role: "user", content: "das ist fantastisch ich kann nicht glauben dass es funktioniert hat" },
127
- { role: "assistant", content: "Das ist fantastisch! Ich kann nicht glauben, dass es funktioniert hat!" }
128
- ]
129
- }
130
- };
131
- /* construct node */
132
- constructor(id, cfg, opts, args) {
133
- super(id, cfg, opts, args);
134
- /* declare node configuration parameters */
135
- this.configure({
136
- provider: { type: "string", val: "ollama", match: /^(?:openai|anthropic|google|ollama|transformers)$/ },
137
- api: { type: "string", val: "http://127.0.0.1:11434", match: /^https?:\/\/.+?(:\d+)?$/ },
138
- model: { type: "string", val: "gemma3:4b-it-q4_K_M", match: /^.+$/ },
139
- key: { type: "string", val: "", match: /^.*$/ },
140
- lang: { type: "string", pos: 0, val: "en", match: /^(?:de|en)$/ }
141
- });
142
- /* tell effective mode */
143
- this.log("info", `punctuation restoration for language "${this.params.lang}" ` +
144
- `via ${this.params.provider} LLM (model: ${this.params.model})`);
145
- /* declare node input/output format */
146
- this.input = "text";
147
- this.output = "text";
148
- }
149
- /* open node */
150
- async open() {
151
- /* instantiate LLM */
152
- this.llm = new speechflow_util_llm_1.LLM({
153
- provider: this.params.provider,
154
- api: this.params.api,
155
- model: this.params.model,
156
- key: this.params.key,
157
- temperature: 0.7
158
- });
159
- this.llm.on("log", (level, message) => {
160
- this.log(level, message);
161
- });
162
- await this.llm.open();
163
- /* provide text-to-text punctuation restoration */
164
- const llm = this.llm;
165
- const punctuate = async (text) => {
166
- const cfg = this.setup[this.params.lang];
167
- if (!cfg)
168
- throw new Error(`unsupported language: ${this.params.lang}`);
169
- return llm.complete({
170
- system: cfg.systemPrompt,
171
- messages: cfg.chat,
172
- prompt: text
173
- });
174
- };
175
- /* establish a transform stream for punctuation restoration */
176
- this.stream = new node_stream_1.default.Transform({
177
- readableObjectMode: true,
178
- writableObjectMode: true,
179
- decodeStrings: false,
180
- highWaterMark: 1,
181
- transform(chunk, encoding, callback) {
182
- if (Buffer.isBuffer(chunk.payload))
183
- callback(new Error("invalid chunk payload type"));
184
- else if (chunk.payload === "") {
185
- this.push(chunk);
186
- callback();
187
- }
188
- else {
189
- punctuate(chunk.payload).then((payload) => {
190
- const chunkNew = chunk.clone();
191
- chunkNew.payload = payload;
192
- this.push(chunkNew);
193
- callback();
194
- }).catch((error) => {
195
- callback(util.ensureError(error));
196
- });
197
- }
198
- },
199
- final(callback) {
200
- callback();
201
- }
202
- });
203
- }
204
- /* close node */
205
- async close() {
206
- /* shutdown stream */
207
- if (this.stream !== null) {
208
- await util.destroyStream(this.stream);
209
- this.stream = null;
210
- }
211
- /* shutdown LLM */
212
- if (this.llm !== null) {
213
- await this.llm.close();
214
- this.llm = null;
215
- }
216
- }
217
- }
218
- exports.default = SpeechFlowNodeT2TPunctuation;
219
- //# sourceMappingURL=speechflow-node-t2t-punctuation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"speechflow-node-t2t-punctuation.js","sourceRoot":"","sources":["../src/speechflow-node-t2t-punctuation.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,6BAA6B;AAC7B,8DAA6D;AAE7D,6BAA6B;AAC7B,wEAAmE;AACnE,wDAAmE;AACnE,+DAAuE;AAMvE,gEAAgE;AAChE,MAAqB,4BAA6B,SAAQ,yBAAc;IACpE,kCAAkC;IAC3B,MAAM,CAAC,I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AC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;wBACxB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAA;oBACrC,CAAC,CAAC,CAAA;gBACN,CAAC;YACL,CAAC;YACD,KAAK,CAAE,QAAQ;gBACX,QAAQ,EAAE,CAAA;YACd,CAAC;SACJ,CAAC,CAAA;IACN,CAAC;IAED,kBAAkB;IAClB,KAAK,CAAC,KAAK;QACP,uBAAuB;QACvB,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;YACvB,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YACrC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QACtB,CAAC;QAED,oBAAoB;QACpB,IAAI,IAAI,CAAC,GAAG,KAAK,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAA;YACtB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAA;QACnB,CAAC;IACL,CAAC;;AAnLL,+CAoLC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"speechflow-node-t2t-spellcheck.js","sourceRoot":"","sources":["../src/speechflow-node-t2t-spellcheck.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,6BAA6B;AAC7B,8DAA6D;AAE7D,6BAA6B;AAC7B,wEAAmE;AACnE,wDAAmE;AACnE,+DAAuE;AAMvE,gEAAgE;AAChE,MAAqB,2BAA4B,SAAQ,yBAAc;IACnE,kCAAkC;IAC3B,MAAM,CAAC,IAAI,GAAG,gBAAgB,CAAA;IAErC,sBAAsB;IACd,GAAG,GAAe,IAAI,CAAA;IAE9B,0BAA0B;IAClB,KAAK,GAAW;QACpB,kCAAkC;QAClC,IAAI,EAAE;YACF,YAAY,EACR,uDAAuD;gBACvD,mCAAmC;gBACnC,wBAAwB;gBAC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CAAA;YACtB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAA;QACnB,CAAC;IACL,CAAC;;AAtKL,8CAuKC"}
@@ -1,200 +0,0 @@
1
- /*
2
- ** SpeechFlow - Speech Processing Flow Graph
3
- ** Copyright (c) 2024-2026 Dr. Ralf S. Engelschall <rse@engelschall.com>
4
- ** Licensed under GPL 3.0 <https://spdx.org/licenses/GPL-3.0-only>
5
- */
6
-
7
- /* standard dependencies */
8
- import Stream from "node:stream"
9
-
10
- /* internal dependencies */
11
- import SpeechFlowNode, { SpeechFlowChunk } from "./speechflow-node"
12
- import * as util from "./speechflow-util"
13
- import { LLM, type LLMCompleteMessage } from "./speechflow-util-llm"
14
-
15
- /* internal utility types */
16
- type ConfigEntry = { systemPrompt: string, chat: LLMCompleteMessage[] }
17
- type Config = { [ key: string ]: ConfigEntry }
18
-
19
- /* SpeechFlow node for text-to-text punctuation restoration */
20
- export default class SpeechFlowNodeT2TPunctuation extends SpeechFlowNode {
21
- /* declare official node name */
22
- public static name = "t2t-punctuation"
23
-
24
- /* internal state */
25
- private llm: LLM | null = null
26
-
27
- /* internal LLM setup */
28
- private setup: Config = {
29
- /* English (EN) punctuation restoration */
30
- "en": {
31
- systemPrompt:
32
- "You are a punctuation restoration specialist for English.\n" +
33
- "Your task is to add missing punctuation to unpunctuated text.\n" +
34
- "Output only the punctuated text.\n" +
35
- "Do NOT use markdown.\n" +
36
- "Do NOT give any explanations.\n" +
37
- "Do NOT give any introduction.\n" +
38
- "Do NOT give any comments.\n" +
39
- "Do NOT give any preamble.\n" +
40
- "Do NOT give any prolog.\n" +
41
- "Do NOT give any epilog.\n" +
42
- "Do NOT change the words.\n" +
43
- "Do NOT add or remove words.\n" +
44
- "Do NOT fix spelling errors.\n" +
45
- "Do NOT change the grammar.\n" +
46
- "Do NOT use synonyms.\n" +
47
- "Keep all original words exactly as they are.\n" +
48
- "Add periods at sentence endings.\n" +
49
- "Add commas where appropriate.\n" +
50
- "Add question marks for questions.\n" +
51
- "Add exclamation marks where appropriate.\n" +
52
- "Add colons and semicolons where appropriate.\n" +
53
- "Capitalize first letters of sentences.\n" +
54
- "The text you have to punctuate is:\n",
55
- chat: [
56
- { role: "user", content: "hello how are you today" },
57
- { role: "assistant", content: "Hello, how are you today?" },
58
- { role: "user", content: "i went to the store and bought some milk eggs and bread" },
59
- { role: "assistant", content: "I went to the store and bought some milk, eggs, and bread." },
60
- { role: "user", content: "what time is it i need to leave soon" },
61
- { role: "assistant", content: "What time is it? I need to leave soon." },
62
- { role: "user", content: "thats amazing i cant believe it worked" },
63
- { role: "assistant", content: "That's amazing! I can't believe it worked!" }
64
- ]
65
- },
66
-
67
- /* German (DE) punctuation restoration */
68
- "de": {
69
- systemPrompt:
70
- "Du bist ein Spezialist für Zeichensetzung im Deutschen.\n" +
71
- "Deine Aufgabe ist es, fehlende Satzzeichen in unpunktierten Text einzufügen.\n" +
72
- "Gib nur den punktierten Text aus.\n" +
73
- "Benutze KEIN Markdown.\n" +
74
- "Gib KEINE Erklärungen.\n" +
75
- "Gib KEINE Einleitung.\n" +
76
- "Gib KEINE Kommentare.\n" +
77
- "Gib KEINE Präambel.\n" +
78
- "Gib KEINEN Prolog.\n" +
79
- "Gib KEINEN Epilog.\n" +
80
- "Ändere NICHT die Wörter.\n" +
81
- "Füge KEINE Wörter hinzu oder entferne welche.\n" +
82
- "Korrigiere KEINE Rechtschreibfehler.\n" +
83
- "Ändere NICHT die Grammatik.\n" +
84
- "Verwende KEINE Synonyme.\n" +
85
- "Behalte alle ursprünglichen Wörter genau bei.\n" +
86
- "Füge Punkte am Satzende ein.\n" +
87
- "Füge Kommas an passenden Stellen ein.\n" +
88
- "Füge Fragezeichen bei Fragen ein.\n" +
89
- "Füge Ausrufezeichen an passenden Stellen ein.\n" +
90
- "Füge Doppelpunkte und Semikolons an passenden Stellen ein.\n" +
91
- "Großschreibe die ersten Buchstaben von Sätzen.\n" +
92
- "Der von dir zu punktierende Text ist:\n",
93
- chat: [
94
- { role: "user", content: "hallo wie geht es dir heute" },
95
- { role: "assistant", content: "Hallo, wie geht es dir heute?" },
96
- { role: "user", content: "ich bin in den laden gegangen und habe milch eier und brot gekauft" },
97
- { role: "assistant", content: "Ich bin in den Laden gegangen und habe Milch, Eier und Brot gekauft." },
98
- { role: "user", content: "wie spät ist es ich muss bald los" },
99
- { role: "assistant", content: "Wie spät ist es? Ich muss bald los." },
100
- { role: "user", content: "das ist fantastisch ich kann nicht glauben dass es funktioniert hat" },
101
- { role: "assistant", content: "Das ist fantastisch! Ich kann nicht glauben, dass es funktioniert hat!" }
102
- ]
103
- }
104
- }
105
-
106
- /* construct node */
107
- constructor (id: string, cfg: { [ id: string ]: any }, opts: { [ id: string ]: any }, args: any[]) {
108
- super(id, cfg, opts, args)
109
-
110
- /* declare node configuration parameters */
111
- this.configure({
112
- provider: { type: "string", val: "ollama", match: /^(?:openai|anthropic|google|ollama|transformers)$/ },
113
- api: { type: "string", val: "http://127.0.0.1:11434", match: /^https?:\/\/.+?(:\d+)?$/ },
114
- model: { type: "string", val: "gemma3:4b-it-q4_K_M", match: /^.+$/ },
115
- key: { type: "string", val: "", match: /^.*$/ },
116
- lang: { type: "string", pos: 0, val: "en", match: /^(?:de|en)$/ }
117
- })
118
-
119
- /* tell effective mode */
120
- this.log("info", `punctuation restoration for language "${this.params.lang}" ` +
121
- `via ${this.params.provider} LLM (model: ${this.params.model})`)
122
-
123
- /* declare node input/output format */
124
- this.input = "text"
125
- this.output = "text"
126
- }
127
-
128
- /* open node */
129
- async open () {
130
- /* instantiate LLM */
131
- this.llm = new LLM({
132
- provider: this.params.provider,
133
- api: this.params.api,
134
- model: this.params.model,
135
- key: this.params.key,
136
- temperature: 0.7
137
- })
138
- this.llm.on("log", (level: string, message: string) => {
139
- this.log(level as "info" | "warning" | "error", message)
140
- })
141
- await this.llm.open()
142
-
143
- /* provide text-to-text punctuation restoration */
144
- const llm = this.llm
145
- const punctuate = async (text: string) => {
146
- const cfg = this.setup[this.params.lang]
147
- if (!cfg)
148
- throw new Error(`unsupported language: ${this.params.lang}`)
149
- return llm.complete({
150
- system: cfg.systemPrompt,
151
- messages: cfg.chat,
152
- prompt: text
153
- })
154
- }
155
-
156
- /* establish a transform stream for punctuation restoration */
157
- this.stream = new Stream.Transform({
158
- readableObjectMode: true,
159
- writableObjectMode: true,
160
- decodeStrings: false,
161
- highWaterMark: 1,
162
- transform (chunk: SpeechFlowChunk, encoding, callback) {
163
- if (Buffer.isBuffer(chunk.payload))
164
- callback(new Error("invalid chunk payload type"))
165
- else if (chunk.payload === "") {
166
- this.push(chunk)
167
- callback()
168
- }
169
- else {
170
- punctuate(chunk.payload).then((payload) => {
171
- const chunkNew = chunk.clone()
172
- chunkNew.payload = payload
173
- this.push(chunkNew)
174
- callback()
175
- }).catch((error: unknown) => {
176
- callback(util.ensureError(error))
177
- })
178
- }
179
- },
180
- final (callback) {
181
- callback()
182
- }
183
- })
184
- }
185
-
186
- /* close node */
187
- async close () {
188
- /* shutdown stream */
189
- if (this.stream !== null) {
190
- await util.destroyStream(this.stream)
191
- this.stream = null
192
- }
193
-
194
- /* shutdown LLM */
195
- if (this.llm !== null) {
196
- await this.llm.close()
197
- this.llm = null
198
- }
199
- }
200
- }