speechflow 1.7.0 → 2.0.0
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.
- package/CHANGELOG.md +23 -0
- package/README.md +425 -146
- package/etc/claude.md +5 -5
- package/etc/speechflow.yaml +2 -2
- package/package.json +3 -3
- package/speechflow-cli/dst/speechflow-main-api.js +6 -5
- package/speechflow-cli/dst/speechflow-main-api.js.map +1 -1
- package/speechflow-cli/dst/speechflow-main-graph.d.ts +1 -0
- package/speechflow-cli/dst/speechflow-main-graph.js +35 -13
- package/speechflow-cli/dst/speechflow-main-graph.js.map +1 -1
- package/speechflow-cli/dst/speechflow-main-status.js +3 -7
- package/speechflow-cli/dst/speechflow-main-status.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-compressor-wt.js +3 -0
- package/speechflow-cli/dst/speechflow-node-a2a-compressor-wt.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-compressor.js +4 -2
- package/speechflow-cli/dst/speechflow-node-a2a-compressor.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-expander-wt.js +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-expander.js +4 -2
- package/speechflow-cli/dst/speechflow-node-a2a-expander.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-gender.js +2 -2
- package/speechflow-cli/dst/speechflow-node-a2a-gender.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-pitch.js +1 -2
- package/speechflow-cli/dst/speechflow-node-a2a-pitch.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-wav.js +32 -5
- package/speechflow-cli/dst/speechflow-node-a2a-wav.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2t-amazon.d.ts +0 -1
- package/speechflow-cli/dst/speechflow-node-a2t-amazon.js +1 -6
- package/speechflow-cli/dst/speechflow-node-a2t-amazon.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2t-deepgram.d.ts +0 -1
- package/speechflow-cli/dst/speechflow-node-a2t-deepgram.js +9 -9
- package/speechflow-cli/dst/speechflow-node-a2t-deepgram.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2t-google.d.ts +17 -0
- package/speechflow-cli/dst/speechflow-node-a2t-google.js +320 -0
- package/speechflow-cli/dst/speechflow-node-a2t-google.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2t-openai.js +6 -4
- package/speechflow-cli/dst/speechflow-node-a2t-openai.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2a-amazon.js +6 -11
- package/speechflow-cli/dst/speechflow-node-t2a-amazon.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2a-elevenlabs.js +6 -5
- package/speechflow-cli/dst/speechflow-node-t2a-elevenlabs.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2a-google.d.ts +15 -0
- package/speechflow-cli/dst/speechflow-node-t2a-google.js +218 -0
- package/speechflow-cli/dst/speechflow-node-t2a-google.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2a-kokoro.d.ts +2 -0
- package/speechflow-cli/dst/speechflow-node-t2a-kokoro.js +19 -6
- package/speechflow-cli/dst/speechflow-node-t2a-kokoro.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2a-openai.d.ts +15 -0
- package/speechflow-cli/dst/speechflow-node-t2a-openai.js +195 -0
- package/speechflow-cli/dst/speechflow-node-t2a-openai.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2a-supertonic.d.ts +17 -0
- package/speechflow-cli/dst/speechflow-node-t2a-supertonic.js +608 -0
- package/speechflow-cli/dst/speechflow-node-t2a-supertonic.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2t-amazon.js.map +1 -1
- package/speechflow-cli/dst/{speechflow-node-t2t-transformers.d.ts → speechflow-node-t2t-opus.d.ts} +1 -3
- package/speechflow-cli/dst/speechflow-node-t2t-opus.js +159 -0
- package/speechflow-cli/dst/speechflow-node-t2t-opus.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2t-profanity.d.ts +11 -0
- package/speechflow-cli/dst/speechflow-node-t2t-profanity.js +118 -0
- package/speechflow-cli/dst/speechflow-node-t2t-profanity.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2t-punctuation.d.ts +13 -0
- package/speechflow-cli/dst/speechflow-node-t2t-punctuation.js +220 -0
- package/speechflow-cli/dst/speechflow-node-t2t-punctuation.js.map +1 -0
- package/speechflow-cli/dst/{speechflow-node-t2t-openai.d.ts → speechflow-node-t2t-spellcheck.d.ts} +2 -2
- package/speechflow-cli/dst/{speechflow-node-t2t-openai.js → speechflow-node-t2t-spellcheck.js} +47 -99
- package/speechflow-cli/dst/speechflow-node-t2t-spellcheck.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2t-subtitle.js +3 -6
- package/speechflow-cli/dst/speechflow-node-t2t-subtitle.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-summary.d.ts +16 -0
- package/speechflow-cli/dst/speechflow-node-t2t-summary.js +241 -0
- package/speechflow-cli/dst/speechflow-node-t2t-summary.js.map +1 -0
- package/speechflow-cli/dst/{speechflow-node-t2t-ollama.d.ts → speechflow-node-t2t-translate.d.ts} +2 -2
- package/speechflow-cli/dst/{speechflow-node-t2t-transformers.js → speechflow-node-t2t-translate.js} +53 -115
- package/speechflow-cli/dst/speechflow-node-t2t-translate.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-x2x-filter.d.ts +1 -0
- package/speechflow-cli/dst/speechflow-node-x2x-filter.js +10 -0
- package/speechflow-cli/dst/speechflow-node-x2x-filter.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-x2x-trace.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-xio-device.js +3 -3
- package/speechflow-cli/dst/speechflow-node-xio-device.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-xio-exec.d.ts +12 -0
- package/speechflow-cli/dst/speechflow-node-xio-exec.js +223 -0
- package/speechflow-cli/dst/speechflow-node-xio-exec.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-xio-file.d.ts +1 -0
- package/speechflow-cli/dst/speechflow-node-xio-file.js +80 -67
- package/speechflow-cli/dst/speechflow-node-xio-file.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-xio-mqtt.js +2 -1
- package/speechflow-cli/dst/speechflow-node-xio-mqtt.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-xio-vban.d.ts +17 -0
- package/speechflow-cli/dst/speechflow-node-xio-vban.js +330 -0
- package/speechflow-cli/dst/speechflow-node-xio-vban.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-xio-webrtc.d.ts +39 -0
- package/speechflow-cli/dst/speechflow-node-xio-webrtc.js +500 -0
- package/speechflow-cli/dst/speechflow-node-xio-webrtc.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-xio-websocket.js +2 -1
- package/speechflow-cli/dst/speechflow-node-xio-websocket.js.map +1 -1
- package/speechflow-cli/dst/speechflow-util-audio.js +5 -6
- package/speechflow-cli/dst/speechflow-util-audio.js.map +1 -1
- package/speechflow-cli/dst/speechflow-util-error.d.ts +1 -1
- package/speechflow-cli/dst/speechflow-util-error.js +5 -7
- package/speechflow-cli/dst/speechflow-util-error.js.map +1 -1
- package/speechflow-cli/dst/speechflow-util-llm.d.ts +35 -0
- package/speechflow-cli/dst/speechflow-util-llm.js +363 -0
- package/speechflow-cli/dst/speechflow-util-llm.js.map +1 -0
- package/speechflow-cli/dst/speechflow-util-misc.d.ts +1 -1
- package/speechflow-cli/dst/speechflow-util-misc.js +4 -4
- package/speechflow-cli/dst/speechflow-util-misc.js.map +1 -1
- package/speechflow-cli/dst/speechflow-util-queue.js +3 -3
- package/speechflow-cli/dst/speechflow-util-queue.js.map +1 -1
- package/speechflow-cli/dst/speechflow-util-stream.js +4 -2
- package/speechflow-cli/dst/speechflow-util-stream.js.map +1 -1
- package/speechflow-cli/dst/speechflow-util.d.ts +1 -0
- package/speechflow-cli/dst/speechflow-util.js +1 -0
- package/speechflow-cli/dst/speechflow-util.js.map +1 -1
- package/speechflow-cli/etc/oxlint.jsonc +2 -1
- package/speechflow-cli/package.json +34 -17
- package/speechflow-cli/src/lib.d.ts +5 -0
- package/speechflow-cli/src/speechflow-main-api.ts +6 -5
- package/speechflow-cli/src/speechflow-main-graph.ts +40 -13
- package/speechflow-cli/src/speechflow-main-status.ts +4 -8
- package/speechflow-cli/src/speechflow-node-a2a-compressor-wt.ts +4 -0
- package/speechflow-cli/src/speechflow-node-a2a-compressor.ts +4 -2
- package/speechflow-cli/src/speechflow-node-a2a-expander-wt.ts +1 -1
- package/speechflow-cli/src/speechflow-node-a2a-expander.ts +4 -2
- package/speechflow-cli/src/speechflow-node-a2a-gender.ts +2 -2
- package/speechflow-cli/src/speechflow-node-a2a-pitch.ts +1 -2
- package/speechflow-cli/src/speechflow-node-a2a-wav.ts +33 -6
- package/speechflow-cli/src/speechflow-node-a2t-amazon.ts +6 -11
- package/speechflow-cli/src/speechflow-node-a2t-deepgram.ts +13 -12
- package/speechflow-cli/src/speechflow-node-a2t-google.ts +322 -0
- package/speechflow-cli/src/speechflow-node-a2t-openai.ts +8 -4
- package/speechflow-cli/src/speechflow-node-t2a-amazon.ts +7 -11
- package/speechflow-cli/src/speechflow-node-t2a-elevenlabs.ts +6 -5
- package/speechflow-cli/src/speechflow-node-t2a-google.ts +206 -0
- package/speechflow-cli/src/speechflow-node-t2a-kokoro.ts +22 -6
- package/speechflow-cli/src/speechflow-node-t2a-openai.ts +179 -0
- package/speechflow-cli/src/speechflow-node-t2a-supertonic.ts +701 -0
- package/speechflow-cli/src/speechflow-node-t2t-amazon.ts +2 -1
- package/speechflow-cli/src/speechflow-node-t2t-opus.ts +136 -0
- package/speechflow-cli/src/speechflow-node-t2t-profanity.ts +93 -0
- package/speechflow-cli/src/speechflow-node-t2t-punctuation.ts +201 -0
- package/speechflow-cli/src/{speechflow-node-t2t-openai.ts → speechflow-node-t2t-spellcheck.ts} +48 -107
- package/speechflow-cli/src/speechflow-node-t2t-subtitle.ts +3 -6
- package/speechflow-cli/src/speechflow-node-t2t-summary.ts +229 -0
- package/speechflow-cli/src/speechflow-node-t2t-translate.ts +181 -0
- package/speechflow-cli/src/speechflow-node-x2x-filter.ts +16 -3
- package/speechflow-cli/src/speechflow-node-x2x-trace.ts +3 -3
- package/speechflow-cli/src/speechflow-node-xio-device.ts +4 -7
- package/speechflow-cli/src/speechflow-node-xio-exec.ts +210 -0
- package/speechflow-cli/src/speechflow-node-xio-file.ts +93 -80
- package/speechflow-cli/src/speechflow-node-xio-mqtt.ts +3 -2
- package/speechflow-cli/src/speechflow-node-xio-vban.ts +325 -0
- package/speechflow-cli/src/speechflow-node-xio-webrtc.ts +533 -0
- package/speechflow-cli/src/speechflow-node-xio-websocket.ts +2 -1
- package/speechflow-cli/src/speechflow-util-audio-wt.ts +4 -4
- package/speechflow-cli/src/speechflow-util-audio.ts +10 -10
- package/speechflow-cli/src/speechflow-util-error.ts +9 -7
- package/speechflow-cli/src/speechflow-util-llm.ts +367 -0
- package/speechflow-cli/src/speechflow-util-misc.ts +4 -4
- package/speechflow-cli/src/speechflow-util-queue.ts +4 -4
- package/speechflow-cli/src/speechflow-util-stream.ts +5 -3
- package/speechflow-cli/src/speechflow-util.ts +1 -0
- package/speechflow-ui-db/package.json +9 -9
- package/speechflow-ui-st/package.json +9 -9
- package/speechflow-cli/dst/speechflow-node-t2t-ollama.js +0 -293
- package/speechflow-cli/dst/speechflow-node-t2t-ollama.js.map +0 -1
- package/speechflow-cli/dst/speechflow-node-t2t-openai.js.map +0 -1
- package/speechflow-cli/dst/speechflow-node-t2t-transformers.js.map +0 -1
- package/speechflow-cli/src/speechflow-node-t2t-ollama.ts +0 -281
- package/speechflow-cli/src/speechflow-node-t2t-transformers.ts +0 -247
package/speechflow-cli/dst/{speechflow-node-t2t-transformers.js → speechflow-node-t2t-translate.js}
RENAMED
|
@@ -42,26 +42,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
42
42
|
};
|
|
43
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
44
|
/* standard dependencies */
|
|
45
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
46
45
|
const node_stream_1 = __importDefault(require("node:stream"));
|
|
47
|
-
/* external dependencies */
|
|
48
|
-
const Transformers = __importStar(require("@huggingface/transformers"));
|
|
49
46
|
/* internal dependencies */
|
|
50
47
|
const speechflow_node_1 = __importDefault(require("./speechflow-node"));
|
|
51
48
|
const util = __importStar(require("./speechflow-util"));
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
const speechflow_util_llm_1 = require("./speechflow-util-llm");
|
|
50
|
+
/* SpeechFlow node for LLM-based text-to-text translation */
|
|
51
|
+
class SpeechFlowNodeT2TTranslate extends speechflow_node_1.default {
|
|
54
52
|
/* declare official node name */
|
|
55
|
-
static name = "t2t-
|
|
53
|
+
static name = "t2t-translate";
|
|
56
54
|
/* internal state */
|
|
57
|
-
|
|
58
|
-
generator = null;
|
|
55
|
+
llm = null;
|
|
59
56
|
/* internal LLM setup */
|
|
60
57
|
setup = {
|
|
61
|
-
/*
|
|
62
|
-
"
|
|
63
|
-
systemPrompt: "
|
|
64
|
-
"You are a translator.\n" +
|
|
58
|
+
/* English (EN) to German (DE) translation */
|
|
59
|
+
"en-de": {
|
|
60
|
+
systemPrompt: "You are a translator.\n" +
|
|
65
61
|
"Output only the requested text.\n" +
|
|
66
62
|
"Do not use markdown.\n" +
|
|
67
63
|
"Do not chat.\n" +
|
|
@@ -82,10 +78,9 @@ class SpeechFlowNodeT2TTransformers extends speechflow_node_1.default {
|
|
|
82
78
|
{ role: "assistant", content: "Das Leben ist einfach großartig." }
|
|
83
79
|
]
|
|
84
80
|
},
|
|
85
|
-
/*
|
|
86
|
-
"
|
|
87
|
-
systemPrompt: "
|
|
88
|
-
"You are a translator.\n" +
|
|
81
|
+
/* German (DE) to English (EN) translation */
|
|
82
|
+
"de-en": {
|
|
83
|
+
systemPrompt: "You are a translator.\n" +
|
|
89
84
|
"Output only the requested text.\n" +
|
|
90
85
|
"Do not use markdown.\n" +
|
|
91
86
|
"Do not chat.\n" +
|
|
@@ -114,102 +109,50 @@ class SpeechFlowNodeT2TTransformers extends speechflow_node_1.default {
|
|
|
114
109
|
this.configure({
|
|
115
110
|
src: { type: "string", pos: 0, val: "de", match: /^(?:de|en)$/ },
|
|
116
111
|
dst: { type: "string", pos: 1, val: "en", match: /^(?:de|en)$/ },
|
|
117
|
-
|
|
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: /^.*$/ }
|
|
118
116
|
});
|
|
119
|
-
/*
|
|
117
|
+
/* validate translation direction */
|
|
120
118
|
if (this.params.src === this.params.dst)
|
|
121
|
-
throw new Error("source and destination
|
|
119
|
+
throw new Error("source and destination language must be different for translation");
|
|
120
|
+
/* tell effective mode */
|
|
121
|
+
this.log("info", `translating from language "${this.params.src}" to language "${this.params.dst}" ` +
|
|
122
|
+
`via ${this.params.provider} LLM (model: ${this.params.model})`);
|
|
122
123
|
/* declare node input/output format */
|
|
123
124
|
this.input = "text";
|
|
124
125
|
this.output = "text";
|
|
125
126
|
}
|
|
126
127
|
/* open node */
|
|
127
128
|
async open() {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
progressState.set(artifact, percent);
|
|
142
|
-
};
|
|
143
|
-
const interval = setInterval(() => {
|
|
144
|
-
for (const [artifact, percent] of progressState) {
|
|
145
|
-
this.log("info", `downloaded ${percent.toFixed(2)}% of artifact "${artifact}"`);
|
|
146
|
-
if (percent >= 100.0)
|
|
147
|
-
progressState.delete(artifact);
|
|
148
|
-
}
|
|
149
|
-
}, 1000);
|
|
150
|
-
/* instantiate Transformers engine and model */
|
|
151
|
-
if (this.params.model === "OPUS") {
|
|
152
|
-
model = `onnx-community/opus-mt-${this.params.src}-${this.params.dst}`;
|
|
153
|
-
const pipeline = Transformers.pipeline("translation", model, {
|
|
154
|
-
cache_dir: node_path_1.default.join(this.config.cacheDir, "transformers"),
|
|
155
|
-
dtype: "q4",
|
|
156
|
-
device: "auto",
|
|
157
|
-
progress_callback: progressCallback
|
|
158
|
-
});
|
|
159
|
-
this.translator = await pipeline;
|
|
160
|
-
if (this.translator === null)
|
|
161
|
-
throw new Error("failed to instantiate translator pipeline");
|
|
162
|
-
}
|
|
163
|
-
else if (this.params.model === "SmolLM3") {
|
|
164
|
-
model = "HuggingFaceTB/SmolLM3-3B-ONNX";
|
|
165
|
-
const pipeline = Transformers.pipeline("text-generation", model, {
|
|
166
|
-
cache_dir: node_path_1.default.join(this.config.cacheDir, "transformers"),
|
|
167
|
-
dtype: "q4",
|
|
168
|
-
device: "auto",
|
|
169
|
-
progress_callback: progressCallback
|
|
170
|
-
});
|
|
171
|
-
this.generator = await pipeline;
|
|
172
|
-
if (this.generator === null)
|
|
173
|
-
throw new Error("failed to instantiate generator pipeline");
|
|
174
|
-
}
|
|
175
|
-
else
|
|
176
|
-
throw new Error("invalid model");
|
|
177
|
-
/* clear progress interval again */
|
|
178
|
-
clearInterval(interval);
|
|
129
|
+
/* instantiate LLM */
|
|
130
|
+
this.llm = new speechflow_util_llm_1.LLM({
|
|
131
|
+
provider: this.params.provider,
|
|
132
|
+
api: this.params.api,
|
|
133
|
+
model: this.params.model,
|
|
134
|
+
key: this.params.key,
|
|
135
|
+
temperature: 0.7,
|
|
136
|
+
topP: 0.5
|
|
137
|
+
});
|
|
138
|
+
this.llm.on("log", (level, message) => {
|
|
139
|
+
this.log(level, message);
|
|
140
|
+
});
|
|
141
|
+
await this.llm.open();
|
|
179
142
|
/* provide text-to-text translation */
|
|
143
|
+
const llm = this.llm;
|
|
180
144
|
const translate = async (text) => {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
{ role: "system", content: cfg.systemPrompt },
|
|
191
|
-
...cfg.chat,
|
|
192
|
-
{ role: "user", content: text }
|
|
193
|
-
];
|
|
194
|
-
const result = await this.generator(messages, {
|
|
195
|
-
max_new_tokens: 100,
|
|
196
|
-
temperature: 0.6,
|
|
197
|
-
top_p: 0.95,
|
|
198
|
-
streamer: new Transformers.TextStreamer(this.generator.tokenizer, {
|
|
199
|
-
skip_prompt: true,
|
|
200
|
-
skip_special_tokens: true
|
|
201
|
-
})
|
|
202
|
-
});
|
|
203
|
-
const single = Array.isArray(result) ? result[0] : result;
|
|
204
|
-
const generatedText = single.generated_text;
|
|
205
|
-
return typeof generatedText === "string" ?
|
|
206
|
-
generatedText :
|
|
207
|
-
generatedText.at(-1).content;
|
|
208
|
-
}
|
|
209
|
-
else
|
|
210
|
-
throw new Error("invalid model");
|
|
145
|
+
const key = `${this.params.src}-${this.params.dst}`;
|
|
146
|
+
const cfg = this.setup[key];
|
|
147
|
+
if (!cfg)
|
|
148
|
+
throw new Error(`unsupported language pair: ${key}`);
|
|
149
|
+
return llm.complete({
|
|
150
|
+
system: cfg.systemPrompt,
|
|
151
|
+
messages: cfg.chat,
|
|
152
|
+
prompt: text
|
|
153
|
+
});
|
|
211
154
|
};
|
|
212
|
-
/* establish a
|
|
155
|
+
/* establish a transform stream and connect it to LLM */
|
|
213
156
|
this.stream = new node_stream_1.default.Transform({
|
|
214
157
|
readableObjectMode: true,
|
|
215
158
|
writableObjectMode: true,
|
|
@@ -224,9 +167,9 @@ class SpeechFlowNodeT2TTransformers extends speechflow_node_1.default {
|
|
|
224
167
|
}
|
|
225
168
|
else {
|
|
226
169
|
translate(chunk.payload).then((payload) => {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
this.push(
|
|
170
|
+
const chunkNew = chunk.clone();
|
|
171
|
+
chunkNew.payload = payload;
|
|
172
|
+
this.push(chunkNew);
|
|
230
173
|
callback();
|
|
231
174
|
}).catch((error) => {
|
|
232
175
|
callback(util.ensureError(error));
|
|
@@ -234,7 +177,6 @@ class SpeechFlowNodeT2TTransformers extends speechflow_node_1.default {
|
|
|
234
177
|
}
|
|
235
178
|
},
|
|
236
179
|
final(callback) {
|
|
237
|
-
this.push(null);
|
|
238
180
|
callback();
|
|
239
181
|
}
|
|
240
182
|
});
|
|
@@ -246,16 +188,12 @@ class SpeechFlowNodeT2TTransformers extends speechflow_node_1.default {
|
|
|
246
188
|
await util.destroyStream(this.stream);
|
|
247
189
|
this.stream = null;
|
|
248
190
|
}
|
|
249
|
-
/* shutdown
|
|
250
|
-
if (this.
|
|
251
|
-
this.
|
|
252
|
-
this.
|
|
253
|
-
}
|
|
254
|
-
if (this.generator !== null) {
|
|
255
|
-
this.generator.dispose();
|
|
256
|
-
this.generator = null;
|
|
191
|
+
/* shutdown LLM */
|
|
192
|
+
if (this.llm !== null) {
|
|
193
|
+
await this.llm.close();
|
|
194
|
+
this.llm = null;
|
|
257
195
|
}
|
|
258
196
|
}
|
|
259
197
|
}
|
|
260
|
-
exports.default =
|
|
261
|
-
//# sourceMappingURL=speechflow-node-t2t-
|
|
198
|
+
exports.default = SpeechFlowNodeT2TTranslate;
|
|
199
|
+
//# sourceMappingURL=speechflow-node-t2t-translate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"speechflow-node-t2t-translate.js","sourceRoot":"","sources":["../src/speechflow-node-t2t-translate.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,6BAA6B;AAC7B,8DAA6D;AAE7D,6BAA6B;AAC7B,wEAAmE;AAC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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;;AAhKL,6CAiKC"}
|
|
@@ -52,6 +52,8 @@ class SpeechFlowNodeX2XFilter extends speechflow_node_1.default {
|
|
|
52
52
|
static name = "x2x-filter";
|
|
53
53
|
/* cached regular expression instance */
|
|
54
54
|
cachedRegExp = new util.CachedRegExp();
|
|
55
|
+
/* internal state */
|
|
56
|
+
closing = false;
|
|
55
57
|
/* construct node */
|
|
56
58
|
constructor(id, cfg, opts, args) {
|
|
57
59
|
super(id, cfg, opts, args);
|
|
@@ -69,6 +71,8 @@ class SpeechFlowNodeX2XFilter extends speechflow_node_1.default {
|
|
|
69
71
|
}
|
|
70
72
|
/* open node */
|
|
71
73
|
async open() {
|
|
74
|
+
/* clear destruction flag */
|
|
75
|
+
this.closing = false;
|
|
72
76
|
/* helper function for comparing two values */
|
|
73
77
|
const comparison = (val1, op, val2) => {
|
|
74
78
|
if (op === "==" || op === "!=") {
|
|
@@ -114,6 +118,10 @@ class SpeechFlowNodeX2XFilter extends speechflow_node_1.default {
|
|
|
114
118
|
decodeStrings: false,
|
|
115
119
|
highWaterMark: 1,
|
|
116
120
|
transform(chunk, encoding, callback) {
|
|
121
|
+
if (self.closing) {
|
|
122
|
+
callback(new Error("stream already destroyed"));
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
117
125
|
let val1;
|
|
118
126
|
const val2 = self.params.val;
|
|
119
127
|
const m = self.params.var.match(/^meta:(.+)$/);
|
|
@@ -144,6 +152,8 @@ class SpeechFlowNodeX2XFilter extends speechflow_node_1.default {
|
|
|
144
152
|
}
|
|
145
153
|
/* close node */
|
|
146
154
|
async close() {
|
|
155
|
+
/* indicate closing */
|
|
156
|
+
this.closing = true;
|
|
147
157
|
/* shutdown stream */
|
|
148
158
|
if (this.stream !== null) {
|
|
149
159
|
await util.destroyStream(this.stream);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"speechflow-node-x2x-filter.js","sourceRoot":"","sources":["../src/speechflow-node-x2x-filter.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,6BAA6B;AAC7B,8DAAgC;AAEhC,6BAA6B;AAC7B,wEAAmE;AACnE,wDAAmE;AAEnE,2EAA2E;AAC3E,MAAqB,uBAAwB,SAAQ,yBAAc;IAC/D,kCAAkC;IAC3B,MAAM,CAAC,IAAI,GAAG,YAAY,CAAA;IAEjC,0CAA0C;IAClC,YAAY,GAAG,IAAI,IAAI,CAAC,YAAY,EAAE,CAAA;IAE9C,sBAAsB;IACtB,YAAa,EAAU,EAAE,GAA4B,EAAE,IAA6B,EAAE,IAAW;QAC7F,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;QAE1B,6CAA6C;QAC7C,IAAI,CAAC,SAAS,CAAC;YACX,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,OAAO,EAAG,KAAK,EAAE,kBAAkB,EAAE;YAC1E,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,GAA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AAC,KAAK,EAAE,QAAQ,CAAC,CAAA;oBAC1B,QAAQ,EAAE,CAAA;gBACd,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,wBAAwB;QACxB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QAEnB,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;IACL,CAAC;;AAvHL,yCAwHC"}
|
|
@@ -107,7 +107,7 @@ class SpeechFlowNodeXIODevice extends speechflow_node_1.default {
|
|
|
107
107
|
throw new Error(`invalid audio device "${name}" (of audio API type "${type}")`);
|
|
108
108
|
return device;
|
|
109
109
|
}
|
|
110
|
-
/* NOTICE: "
|
|
110
|
+
/* NOTICE: "naudiodon" actually implements Stream.{Readable,Writable,Duplex}, but
|
|
111
111
|
declares just its sub-interface NodeJS.{Readable,Writable,Duplex}Stream,
|
|
112
112
|
so it is correct to cast it back to Stream.{Readable,Writable,Duplex}
|
|
113
113
|
in the following device stream setup functions! */
|
|
@@ -216,7 +216,7 @@ class SpeechFlowNodeXIODevice extends speechflow_node_1.default {
|
|
|
216
216
|
throw error;
|
|
217
217
|
};
|
|
218
218
|
await Promise.race([
|
|
219
|
-
util.
|
|
219
|
+
util.timeout(2 * 1000, "PortAudio abort timeout"),
|
|
220
220
|
new Promise((resolve) => {
|
|
221
221
|
this.io.abort(() => {
|
|
222
222
|
resolve();
|
|
@@ -224,7 +224,7 @@ class SpeechFlowNodeXIODevice extends speechflow_node_1.default {
|
|
|
224
224
|
}).catch(catchHandler)
|
|
225
225
|
]);
|
|
226
226
|
await Promise.race([
|
|
227
|
-
util.
|
|
227
|
+
util.timeout(2 * 1000, "PortAudio quit timeout"),
|
|
228
228
|
new Promise((resolve) => {
|
|
229
229
|
this.io.quit(() => {
|
|
230
230
|
resolve();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"speechflow-node-xio-device.js","sourceRoot":"","sources":["../src/speechflow-node-xio-device.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,6BAA6B;AAC7B,8DAA0C;AAE1C,6BAA6B;AAC7B,iEAA+C;AAE/C,6BAA6B;AAC7B,wEAAgD;AAChD,wDAAgD;AAEhD,yCAAyC;AACzC,MAAqB,uBAAwB,SAAQ,yBAAc;IAC/D,kCAAkC;IAC3B,MAAM,CAAC,IAAI,GAAG,YAAY,CAAA;IAEjC,sBAAsB;IACd,EAAE,
|
|
1
|
+
{"version":3,"file":"speechflow-node-xio-device.js","sourceRoot":"","sources":["../src/speechflow-node-xio-device.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,6BAA6B;AAC7B,8DAA0C;AAE1C,6BAA6B;AAC7B,iEAA+C;AAE/C,6BAA6B;AAC7B,wEAAgD;AAChD,wDAAgD;AAEhD,yCAAyC;AACzC,MAAqB,uBAAwB,SAAQ,yBAAc;IAC/D,kCAAkC;IAC3B,MAAM,CAAC,IAAI,GAAG,YAAY,CAAA;IAEjC,sBAAsB;IACd,EAAE,GAAuF,IAAI,CAAA;IAErG,sBAAsB;IACtB,YAAa,EAAU,EAAE,GAA4B,EAAE,IAA6B,EAAE,IAAW;QAC7F,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;QAE1B,6CAA6C;QAC7C,IAAI,CAAC,SAAS,CAAC;YACX,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAA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;gBACf,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,EAAE,yBAAyB,CAAC;gBACjD,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;oBAC1B,IAAI,CAAC,EAAG,CAAC,KAAK,CAAC,GAAG,EAAE;wBAChB,OAAO,EAAE,CAAA;oBACb,CAAC,CAAC,CAAA;gBACN,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC;aACzB,CAAC,CAAA;YACF,MAAM,OAAO,CAAC,IAAI,CAAC;gBACf,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,EAAE,wBAAwB,CAAC;gBAChD,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;oBAC1B,IAAI,CAAC,EAAG,CAAC,IAAI,CAAC,GAAG,EAAE;wBACf,OAAO,EAAE,CAAA;oBACb,CAAC,CAAC,CAAA;gBACN,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC;aACzB,CAAC,CAAA;YACF,IAAI,CAAC,EAAE,GAAG,IAAI,CAAA;QAClB,CAAC;IACL,CAAC;;AAlNL,0CAmNC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import SpeechFlowNode from "./speechflow-node";
|
|
2
|
+
export default class SpeechFlowNodeXIOExec extends SpeechFlowNode {
|
|
3
|
+
static name: string;
|
|
4
|
+
private subprocess;
|
|
5
|
+
constructor(id: string, cfg: {
|
|
6
|
+
[id: string]: any;
|
|
7
|
+
}, opts: {
|
|
8
|
+
[id: string]: any;
|
|
9
|
+
}, args: any[]);
|
|
10
|
+
open(): Promise<void>;
|
|
11
|
+
close(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
** SpeechFlow - Speech Processing Flow Graph
|
|
4
|
+
** Copyright (c) 2024-2025 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
|
+
/* external dependencies */
|
|
47
|
+
const execa_1 = require("execa");
|
|
48
|
+
const shell_parser_1 = __importDefault(require("shell-parser"));
|
|
49
|
+
/* internal dependencies */
|
|
50
|
+
const speechflow_node_1 = __importDefault(require("./speechflow-node"));
|
|
51
|
+
const util = __importStar(require("./speechflow-util"));
|
|
52
|
+
/* SpeechFlow node for external command execution */
|
|
53
|
+
class SpeechFlowNodeXIOExec extends speechflow_node_1.default {
|
|
54
|
+
/* declare official node name */
|
|
55
|
+
static name = "xio-exec";
|
|
56
|
+
/* internal state */
|
|
57
|
+
subprocess = null;
|
|
58
|
+
/* construct node */
|
|
59
|
+
constructor(id, cfg, opts, args) {
|
|
60
|
+
super(id, cfg, opts, args);
|
|
61
|
+
/* declare node configuration parameters */
|
|
62
|
+
this.configure({
|
|
63
|
+
command: { type: "string", pos: 0, val: "" },
|
|
64
|
+
mode: { type: "string", pos: 1, val: "r", match: /^(?:r|w|rw)$/ },
|
|
65
|
+
type: { type: "string", pos: 2, val: "audio", match: /^(?:audio|text)$/ },
|
|
66
|
+
chunkAudio: { type: "number", val: 200, match: (n) => n >= 10 && n <= 1000 },
|
|
67
|
+
chunkText: { type: "number", val: 65536, match: (n) => n >= 1024 && n <= 131072 }
|
|
68
|
+
});
|
|
69
|
+
/* sanity check parameters */
|
|
70
|
+
if (this.params.command === "")
|
|
71
|
+
throw new Error("required parameter \"command\" has to be given");
|
|
72
|
+
/* declare node input/output format */
|
|
73
|
+
if (this.params.mode === "rw") {
|
|
74
|
+
this.input = this.params.type;
|
|
75
|
+
this.output = this.params.type;
|
|
76
|
+
}
|
|
77
|
+
else if (this.params.mode === "r") {
|
|
78
|
+
this.input = "none";
|
|
79
|
+
this.output = this.params.type;
|
|
80
|
+
}
|
|
81
|
+
else if (this.params.mode === "w") {
|
|
82
|
+
this.input = this.params.type;
|
|
83
|
+
this.output = "none";
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/* open node */
|
|
87
|
+
async open() {
|
|
88
|
+
/* determine how many bytes we need per chunk when
|
|
89
|
+
the chunk should be of the required duration/size */
|
|
90
|
+
const highWaterMarkAudio = (this.config.audioSampleRate *
|
|
91
|
+
(this.config.audioBitDepth / 8)) / (1000 / this.params.chunkAudio);
|
|
92
|
+
const highWaterMarkText = this.params.chunkText;
|
|
93
|
+
/* parse command into executable and arguments
|
|
94
|
+
(SECURITY: caller must ensure command parameter is properly validated
|
|
95
|
+
and does not contain untrusted user input to prevent command injection) */
|
|
96
|
+
const cmdParts = (0, shell_parser_1.default)(this.params.command);
|
|
97
|
+
if (cmdParts.length === 0)
|
|
98
|
+
throw new Error("failed to parse command: no executable found");
|
|
99
|
+
/* warn about potentially dangerous shell metacharacters */
|
|
100
|
+
if (/[;&|`$()<>]/.test(this.params.command))
|
|
101
|
+
this.log("warning", "command contains shell metacharacters -- ensure input is trusted");
|
|
102
|
+
const executable = cmdParts[0];
|
|
103
|
+
const args = cmdParts.slice(1);
|
|
104
|
+
/* determine subprocess options */
|
|
105
|
+
const encoding = (this.params.type === "text" ?
|
|
106
|
+
this.config.textEncoding : "buffer");
|
|
107
|
+
/* spawn subprocess */
|
|
108
|
+
this.log("info", `executing command: ${this.params.command}`);
|
|
109
|
+
this.subprocess = (0, execa_1.execa)(executable, args, {
|
|
110
|
+
buffer: false,
|
|
111
|
+
encoding,
|
|
112
|
+
...(this.params.mode === "rw" ? { stdin: "pipe", stdout: "pipe" } : {}),
|
|
113
|
+
...(this.params.mode === "r" ? { stdin: "ignore", stdout: "pipe" } : {}),
|
|
114
|
+
...(this.params.mode === "w" ? { stdin: "pipe", stdout: "ignore" } : {})
|
|
115
|
+
});
|
|
116
|
+
/* handle subprocess errors */
|
|
117
|
+
this.subprocess.on("error", (err) => {
|
|
118
|
+
this.log("error", `subprocess error: ${err.message}`);
|
|
119
|
+
this.emit("error", err);
|
|
120
|
+
if (this.stream !== null)
|
|
121
|
+
this.stream.emit("error", err);
|
|
122
|
+
});
|
|
123
|
+
/* handle subprocess exit */
|
|
124
|
+
this.subprocess.on("exit", (code, signal) => {
|
|
125
|
+
if (code !== 0 && code !== null)
|
|
126
|
+
this.log("warning", `subprocess exited with code ${code}`);
|
|
127
|
+
else if (signal)
|
|
128
|
+
this.log("warning", `subprocess terminated by signal ${signal}`);
|
|
129
|
+
else
|
|
130
|
+
this.log("info", "subprocess terminated gracefully");
|
|
131
|
+
});
|
|
132
|
+
/* determine high water mark based on type */
|
|
133
|
+
const highWaterMark = this.params.type === "audio" ? highWaterMarkAudio : highWaterMarkText;
|
|
134
|
+
/* configure stream encoding */
|
|
135
|
+
if (this.subprocess.stdout && this.params.type === "text")
|
|
136
|
+
this.subprocess.stdout.setEncoding(this.config.textEncoding);
|
|
137
|
+
if (this.subprocess.stdin)
|
|
138
|
+
this.subprocess.stdin.setDefaultEncoding(this.params.type === "text" ?
|
|
139
|
+
this.config.textEncoding : "binary");
|
|
140
|
+
/* dispatch according to mode */
|
|
141
|
+
if (this.params.mode === "rw") {
|
|
142
|
+
/* bidirectional mode: both stdin and stdout */
|
|
143
|
+
this.stream = node_stream_1.default.Duplex.from({
|
|
144
|
+
readable: this.subprocess.stdout,
|
|
145
|
+
writable: this.subprocess.stdin
|
|
146
|
+
});
|
|
147
|
+
const wrapper1 = util.createTransformStreamForWritableSide(this.params.type, highWaterMark);
|
|
148
|
+
const wrapper2 = util.createTransformStreamForReadableSide(this.params.type, () => this.timeZero, highWaterMark);
|
|
149
|
+
this.stream = node_stream_1.default.compose(wrapper1, this.stream, wrapper2);
|
|
150
|
+
}
|
|
151
|
+
else if (this.params.mode === "r") {
|
|
152
|
+
/* read-only mode: stdout only */
|
|
153
|
+
const wrapper = util.createTransformStreamForReadableSide(this.params.type, () => this.timeZero, highWaterMark);
|
|
154
|
+
this.stream = node_stream_1.default.compose(this.subprocess.stdout, wrapper);
|
|
155
|
+
}
|
|
156
|
+
else if (this.params.mode === "w") {
|
|
157
|
+
/* write-only mode: stdin only */
|
|
158
|
+
const wrapper = util.createTransformStreamForWritableSide(this.params.type, highWaterMark);
|
|
159
|
+
this.stream = node_stream_1.default.compose(wrapper, this.subprocess.stdin);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/* close node */
|
|
163
|
+
async close() {
|
|
164
|
+
/* terminate subprocess */
|
|
165
|
+
if (this.subprocess !== null) {
|
|
166
|
+
/* gracefully end stdin if in write or read/write mode */
|
|
167
|
+
if ((this.params.mode === "w" || this.params.mode === "rw") && this.subprocess.stdin &&
|
|
168
|
+
!this.subprocess.stdin.destroyed && !this.subprocess.stdin.writableEnded) {
|
|
169
|
+
await Promise.race([
|
|
170
|
+
new Promise((resolve, reject) => {
|
|
171
|
+
this.subprocess.stdin.end((err) => {
|
|
172
|
+
if (err)
|
|
173
|
+
reject(err);
|
|
174
|
+
else
|
|
175
|
+
resolve();
|
|
176
|
+
});
|
|
177
|
+
}),
|
|
178
|
+
util.timeout(2000)
|
|
179
|
+
]).catch((err) => {
|
|
180
|
+
const error = util.ensureError(err);
|
|
181
|
+
this.log("warning", `failed to gracefully close stdin: ${error.message}`);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
/* wait for subprocess to exit gracefully */
|
|
185
|
+
await Promise.race([
|
|
186
|
+
this.subprocess,
|
|
187
|
+
util.timeout(5000, "subprocess exit timeout")
|
|
188
|
+
]).catch(async (err) => {
|
|
189
|
+
/* force kill with SIGTERM */
|
|
190
|
+
const error = util.ensureError(err);
|
|
191
|
+
if (error.message.includes("timeout")) {
|
|
192
|
+
this.log("warning", "subprocess did not exit gracefully, forcing termination");
|
|
193
|
+
this.subprocess.kill("SIGTERM");
|
|
194
|
+
return Promise.race([
|
|
195
|
+
this.subprocess,
|
|
196
|
+
util.timeout(2000)
|
|
197
|
+
]);
|
|
198
|
+
}
|
|
199
|
+
}).catch(async () => {
|
|
200
|
+
/* force kill with SIGKILL */
|
|
201
|
+
this.log("warning", "subprocess did not respond to SIGTERM, forcing SIGKILL");
|
|
202
|
+
this.subprocess.kill("SIGKILL");
|
|
203
|
+
return Promise.race([
|
|
204
|
+
this.subprocess,
|
|
205
|
+
util.timeout(1000)
|
|
206
|
+
]);
|
|
207
|
+
}).catch(() => {
|
|
208
|
+
this.log("error", "subprocess did not terminate even after SIGKILL");
|
|
209
|
+
});
|
|
210
|
+
/* remove event listeners to prevent memory leaks */
|
|
211
|
+
this.subprocess.removeAllListeners("error");
|
|
212
|
+
this.subprocess.removeAllListeners("exit");
|
|
213
|
+
this.subprocess = null;
|
|
214
|
+
}
|
|
215
|
+
/* shutdown stream */
|
|
216
|
+
if (this.stream !== null) {
|
|
217
|
+
await util.destroyStream(this.stream);
|
|
218
|
+
this.stream = null;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
exports.default = SpeechFlowNodeXIOExec;
|
|
223
|
+
//# sourceMappingURL=speechflow-node-xio-exec.js.map
|