speechflow 1.7.1 → 2.0.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.
- package/CHANGELOG.md +24 -0
- package/README.md +388 -120
- 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.map +1 -1
- package/speechflow-cli/dst/speechflow-main-cli.js +1 -0
- package/speechflow-cli/dst/speechflow-main-cli.js.map +1 -1
- package/speechflow-cli/dst/speechflow-main-graph.d.ts +1 -0
- package/speechflow-cli/dst/speechflow-main-graph.js +30 -9
- package/speechflow-cli/dst/speechflow-main-graph.js.map +1 -1
- package/speechflow-cli/dst/speechflow-main-nodes.js +1 -0
- package/speechflow-cli/dst/speechflow-main-nodes.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-compressor-wt.js +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-compressor-wt.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-compressor.js +7 -9
- package/speechflow-cli/dst/speechflow-node-a2a-compressor.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-expander-wt.js +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-expander-wt.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-expander.js +8 -9
- package/speechflow-cli/dst/speechflow-node-a2a-expander.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-filler.js +2 -0
- package/speechflow-cli/dst/speechflow-node-a2a-filler.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-gender.js +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-gender.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-meter.js +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-pitch.js +11 -9
- package/speechflow-cli/dst/speechflow-node-a2a-pitch.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-rnnoise-wt.js +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-rnnoise-wt.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-rnnoise.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-speex.js +4 -2
- package/speechflow-cli/dst/speechflow-node-a2a-speex.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-vad.js +19 -22
- package/speechflow-cli/dst/speechflow-node-a2a-vad.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-wav.js +31 -4
- 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 +2 -11
- package/speechflow-cli/dst/speechflow-node-a2t-amazon.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2t-google.d.ts +16 -0
- package/speechflow-cli/dst/speechflow-node-a2t-google.js +314 -0
- package/speechflow-cli/dst/speechflow-node-a2t-google.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2t-openai.js +6 -1
- package/speechflow-cli/dst/speechflow-node-a2t-openai.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2a-amazon.d.ts +1 -1
- package/speechflow-cli/dst/speechflow-node-t2a-amazon.js +27 -7
- package/speechflow-cli/dst/speechflow-node-t2a-amazon.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2a-elevenlabs.d.ts +1 -1
- package/speechflow-cli/dst/speechflow-node-t2a-elevenlabs.js +5 -3
- 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 +215 -0
- package/speechflow-cli/dst/speechflow-node-t2a-google.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2a-kokoro.d.ts +1 -1
- package/speechflow-cli/dst/speechflow-node-t2a-kokoro.js +27 -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 +192 -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 +619 -0
- package/speechflow-cli/dst/speechflow-node-t2a-supertonic.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2t-amazon.js +0 -2
- package/speechflow-cli/dst/speechflow-node-t2t-amazon.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-deepl.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-google.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 +161 -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} +48 -100
- package/speechflow-cli/dst/speechflow-node-t2t-spellcheck.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2t-subtitle.js +8 -8
- 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.js +2 -0
- package/speechflow-cli/dst/speechflow-node-x2x-filter.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 +224 -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 +78 -67
- package/speechflow-cli/dst/speechflow-node-xio-file.js.map +1 -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 +502 -0
- package/speechflow-cli/dst/speechflow-node-xio-webrtc.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-xio-websocket.js +9 -9
- package/speechflow-cli/dst/speechflow-node-xio-websocket.js.map +1 -1
- package/speechflow-cli/dst/speechflow-util-audio.js +8 -5
- package/speechflow-cli/dst/speechflow-util-audio.js.map +1 -1
- package/speechflow-cli/dst/speechflow-util-error.d.ts +1 -0
- package/speechflow-cli/dst/speechflow-util-error.js +5 -0
- 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-queue.js +2 -1
- package/speechflow-cli/dst/speechflow-util-queue.js.map +1 -1
- package/speechflow-cli/dst/speechflow-util.d.ts +1 -0
- package/speechflow-cli/dst/speechflow-util.js +2 -0
- package/speechflow-cli/dst/speechflow-util.js.map +1 -1
- package/speechflow-cli/etc/oxlint.jsonc +2 -1
- package/speechflow-cli/package.json +35 -18
- package/speechflow-cli/src/lib.d.ts +5 -0
- package/speechflow-cli/src/speechflow-main-api.ts +16 -16
- package/speechflow-cli/src/speechflow-main-cli.ts +1 -0
- package/speechflow-cli/src/speechflow-main-graph.ts +38 -14
- package/speechflow-cli/src/speechflow-main-nodes.ts +1 -0
- package/speechflow-cli/src/speechflow-node-a2a-compressor-wt.ts +1 -0
- package/speechflow-cli/src/speechflow-node-a2a-compressor.ts +8 -10
- package/speechflow-cli/src/speechflow-node-a2a-expander-wt.ts +1 -0
- package/speechflow-cli/src/speechflow-node-a2a-expander.ts +9 -10
- package/speechflow-cli/src/speechflow-node-a2a-filler.ts +2 -0
- package/speechflow-cli/src/speechflow-node-a2a-gender.ts +3 -3
- package/speechflow-cli/src/speechflow-node-a2a-meter.ts +2 -2
- package/speechflow-cli/src/speechflow-node-a2a-pitch.ts +11 -9
- package/speechflow-cli/src/speechflow-node-a2a-rnnoise-wt.ts +1 -0
- package/speechflow-cli/src/speechflow-node-a2a-rnnoise.ts +1 -1
- package/speechflow-cli/src/speechflow-node-a2a-speex.ts +5 -3
- package/speechflow-cli/src/speechflow-node-a2a-vad.ts +20 -23
- package/speechflow-cli/src/speechflow-node-a2a-wav.ts +31 -4
- package/speechflow-cli/src/speechflow-node-a2t-amazon.ts +6 -18
- package/speechflow-cli/src/speechflow-node-a2t-google.ts +315 -0
- package/speechflow-cli/src/speechflow-node-a2t-openai.ts +12 -7
- package/speechflow-cli/src/speechflow-node-t2a-amazon.ts +32 -10
- package/speechflow-cli/src/speechflow-node-t2a-elevenlabs.ts +6 -4
- package/speechflow-cli/src/speechflow-node-t2a-google.ts +203 -0
- package/speechflow-cli/src/speechflow-node-t2a-kokoro.ts +33 -10
- package/speechflow-cli/src/speechflow-node-t2a-openai.ts +176 -0
- package/speechflow-cli/src/speechflow-node-t2a-supertonic.ts +710 -0
- package/speechflow-cli/src/speechflow-node-t2t-amazon.ts +3 -4
- package/speechflow-cli/src/speechflow-node-t2t-deepl.ts +2 -2
- package/speechflow-cli/src/speechflow-node-t2t-google.ts +1 -1
- package/speechflow-cli/src/speechflow-node-t2t-opus.ts +137 -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-spellcheck.ts +188 -0
- package/speechflow-cli/src/speechflow-node-t2t-subtitle.ts +8 -8
- 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 +2 -0
- package/speechflow-cli/src/speechflow-node-xio-exec.ts +211 -0
- package/speechflow-cli/src/speechflow-node-xio-file.ts +91 -80
- package/speechflow-cli/src/speechflow-node-xio-mqtt.ts +2 -2
- package/speechflow-cli/src/speechflow-node-xio-vban.ts +325 -0
- package/speechflow-cli/src/speechflow-node-xio-webrtc.ts +535 -0
- package/speechflow-cli/src/speechflow-node-xio-websocket.ts +9 -9
- package/speechflow-cli/src/speechflow-util-audio.ts +10 -5
- package/speechflow-cli/src/speechflow-util-error.ts +9 -0
- package/speechflow-cli/src/speechflow-util-llm.ts +367 -0
- package/speechflow-cli/src/speechflow-util-queue.ts +3 -3
- package/speechflow-cli/src/speechflow-util.ts +2 -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-openai.ts +0 -247
- package/speechflow-cli/src/speechflow-node-t2t-transformers.ts +0 -247
|
@@ -0,0 +1,224 @@
|
|
|
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
|
+
/* clear subprocess reference */
|
|
214
|
+
this.subprocess = null;
|
|
215
|
+
}
|
|
216
|
+
/* shutdown stream */
|
|
217
|
+
if (this.stream !== null) {
|
|
218
|
+
await util.destroyStream(this.stream);
|
|
219
|
+
this.stream = null;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
exports.default = SpeechFlowNodeXIOExec;
|
|
224
|
+
//# sourceMappingURL=speechflow-node-xio-exec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"speechflow-node-xio-exec.js","sourceRoot":"","sources":["../src/speechflow-node-xio-exec.ts"],"names":[],"mappings":";A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AAuB;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;;AA/LL,wCAgMC"}
|
|
@@ -51,26 +51,27 @@ const util = __importStar(require("./speechflow-util"));
|
|
|
51
51
|
class SpeechFlowNodeXIOFile extends speechflow_node_1.default {
|
|
52
52
|
/* declare official node name */
|
|
53
53
|
static name = "xio-file";
|
|
54
|
+
/* file descriptor for seekable write mode */
|
|
55
|
+
fd = null;
|
|
54
56
|
/* construct node */
|
|
55
57
|
constructor(id, cfg, opts, args) {
|
|
56
58
|
super(id, cfg, opts, args);
|
|
57
59
|
/* declare node configuration parameters */
|
|
58
60
|
this.configure({
|
|
59
61
|
path: { type: "string", pos: 0, val: "" },
|
|
60
|
-
mode: { type: "string", pos: 1, val: "r", match: /^(?:r|w
|
|
62
|
+
mode: { type: "string", pos: 1, val: "r", match: /^(?:r|w)$/ },
|
|
61
63
|
type: { type: "string", pos: 2, val: "audio", match: /^(?:audio|text)$/ },
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
seekable: { type: "boolean", val: false },
|
|
65
|
+
chunkAudio: { type: "number", val: 200, match: (n) => n >= 10 && n <= 1000 },
|
|
66
|
+
chunkText: { type: "number", val: 65536, match: (n) => n >= 1024 && n <= 131072 }
|
|
64
67
|
});
|
|
65
68
|
/* sanity check parameters */
|
|
66
69
|
if (this.params.path === "")
|
|
67
70
|
throw new Error("required parameter \"path\" has to be given");
|
|
71
|
+
if (this.params.seekable && this.params.path === "-")
|
|
72
|
+
throw new Error("parameter \"seekable\" cannot be used with standard I/O");
|
|
68
73
|
/* declare node input/output format */
|
|
69
|
-
if (this.params.mode === "
|
|
70
|
-
this.input = this.params.type;
|
|
71
|
-
this.output = this.params.type;
|
|
72
|
-
}
|
|
73
|
-
else if (this.params.mode === "r") {
|
|
74
|
+
if (this.params.mode === "r") {
|
|
74
75
|
this.input = "none";
|
|
75
76
|
this.output = this.params.type;
|
|
76
77
|
}
|
|
@@ -82,10 +83,10 @@ class SpeechFlowNodeXIOFile extends speechflow_node_1.default {
|
|
|
82
83
|
/* open node */
|
|
83
84
|
async open() {
|
|
84
85
|
/* determine how many bytes we need per chunk when
|
|
85
|
-
the chunk should be of the required duration/size
|
|
86
|
+
the chunk should be of the required duration/size */
|
|
86
87
|
const highWaterMarkAudio = (this.config.audioSampleRate *
|
|
87
|
-
(this.config.audioBitDepth / 8)) / (1000 / this.params.
|
|
88
|
-
const highWaterMarkText = this.params.
|
|
88
|
+
(this.config.audioBitDepth / 8)) / (1000 / this.params.chunkAudio);
|
|
89
|
+
const highWaterMarkText = this.params.chunkText;
|
|
89
90
|
/* utility function: create a writable stream as chunker that
|
|
90
91
|
writes to process.stdout but properly handles finish events.
|
|
91
92
|
This ensures the writable side of the composed stream below
|
|
@@ -106,55 +107,7 @@ class SpeechFlowNodeXIOFile extends speechflow_node_1.default {
|
|
|
106
107
|
}
|
|
107
108
|
});
|
|
108
109
|
/* dispatch according to mode and path */
|
|
109
|
-
if (this.params.mode === "
|
|
110
|
-
if (this.params.path === "-") {
|
|
111
|
-
/* standard I/O */
|
|
112
|
-
if (this.params.type === "audio") {
|
|
113
|
-
process.stdin.setEncoding();
|
|
114
|
-
process.stdout.setEncoding();
|
|
115
|
-
const streamR = new node_stream_1.default.PassThrough({ highWaterMark: highWaterMarkAudio });
|
|
116
|
-
process.stdin.pipe(streamR);
|
|
117
|
-
const streamW = new node_stream_1.default.PassThrough({ highWaterMark: highWaterMarkAudio });
|
|
118
|
-
streamW.pipe(process.stdout);
|
|
119
|
-
this.stream = node_stream_1.default.Duplex.from({ readable: streamR, writable: streamW });
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
process.stdin.setEncoding(this.config.textEncoding);
|
|
123
|
-
process.stdout.setEncoding(this.config.textEncoding);
|
|
124
|
-
const streamR = new node_stream_1.default.PassThrough({ highWaterMark: highWaterMarkText });
|
|
125
|
-
process.stdin.pipe(streamR);
|
|
126
|
-
const streamW = new node_stream_1.default.PassThrough({ highWaterMark: highWaterMarkText });
|
|
127
|
-
streamW.pipe(process.stdout);
|
|
128
|
-
this.stream = node_stream_1.default.Duplex.from({ readable: streamR, writable: streamW });
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
/* file I/O */
|
|
133
|
-
if (this.params.type === "audio") {
|
|
134
|
-
this.stream = node_stream_1.default.Duplex.from({
|
|
135
|
-
readable: node_fs_1.default.createReadStream(this.params.path, { highWaterMark: highWaterMarkAudio }),
|
|
136
|
-
writable: node_fs_1.default.createWriteStream(this.params.path, { highWaterMark: highWaterMarkAudio })
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
this.stream = node_stream_1.default.Duplex.from({
|
|
141
|
-
readable: node_fs_1.default.createReadStream(this.params.path, {
|
|
142
|
-
highWaterMark: highWaterMarkText,
|
|
143
|
-
encoding: this.config.textEncoding
|
|
144
|
-
}),
|
|
145
|
-
writable: node_fs_1.default.createWriteStream(this.params.path, {
|
|
146
|
-
highWaterMark: highWaterMarkText,
|
|
147
|
-
encoding: this.config.textEncoding
|
|
148
|
-
})
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
/* convert regular stream into object-mode stream */
|
|
153
|
-
const wrapper1 = util.createTransformStreamForWritableSide(this.params.type, 1);
|
|
154
|
-
const wrapper2 = util.createTransformStreamForReadableSide(this.params.type, () => this.timeZero);
|
|
155
|
-
this.stream = node_stream_1.default.compose(wrapper1, this.stream, wrapper2);
|
|
156
|
-
}
|
|
157
|
-
else if (this.params.mode === "r") {
|
|
110
|
+
if (this.params.mode === "r") {
|
|
158
111
|
if (this.params.path === "-") {
|
|
159
112
|
/* standard I/O */
|
|
160
113
|
let chunker;
|
|
@@ -193,13 +146,59 @@ class SpeechFlowNodeXIOFile extends speechflow_node_1.default {
|
|
|
193
146
|
}
|
|
194
147
|
else {
|
|
195
148
|
/* file I/O */
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
149
|
+
if (this.params.seekable) {
|
|
150
|
+
/* seekable file I/O with file descriptor */
|
|
151
|
+
this.fd = node_fs_1.default.openSync(this.params.path, "w");
|
|
152
|
+
let writePosition = 0;
|
|
153
|
+
const self = this;
|
|
154
|
+
const writable = new node_stream_1.default.Writable({
|
|
155
|
+
objectMode: true,
|
|
156
|
+
decodeStrings: false,
|
|
157
|
+
highWaterMark: 1,
|
|
158
|
+
write(chunk, encoding, callback) {
|
|
159
|
+
const payload = Buffer.isBuffer(chunk.payload) ?
|
|
160
|
+
chunk.payload : Buffer.from(chunk.payload);
|
|
161
|
+
const seekPosition = chunk.meta.get("chunk:seek");
|
|
162
|
+
if (seekPosition !== undefined)
|
|
163
|
+
/* seek to specified position and write (overload) */
|
|
164
|
+
node_fs_1.default.write(self.fd, payload, 0, payload.byteLength, seekPosition, callback);
|
|
165
|
+
else
|
|
166
|
+
/* append at current position */
|
|
167
|
+
node_fs_1.default.write(self.fd, payload, 0, payload.byteLength, writePosition, (err) => {
|
|
168
|
+
if (err)
|
|
169
|
+
callback(err);
|
|
170
|
+
else {
|
|
171
|
+
writePosition += payload.byteLength;
|
|
172
|
+
callback();
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
},
|
|
176
|
+
final(callback) {
|
|
177
|
+
callback();
|
|
178
|
+
},
|
|
179
|
+
destroy(err, callback) {
|
|
180
|
+
if (self.fd !== null) {
|
|
181
|
+
node_fs_1.default.close(self.fd, () => {
|
|
182
|
+
self.fd = null;
|
|
183
|
+
callback(err);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
else
|
|
187
|
+
callback(err);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
this.stream = writable;
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
/* non-seekable file I/O with stream */
|
|
194
|
+
let writable;
|
|
195
|
+
if (this.params.type === "audio")
|
|
196
|
+
writable = node_fs_1.default.createWriteStream(this.params.path, { highWaterMark: highWaterMarkAudio });
|
|
197
|
+
else
|
|
198
|
+
writable = node_fs_1.default.createWriteStream(this.params.path, { highWaterMark: highWaterMarkText, encoding: this.config.textEncoding });
|
|
199
|
+
const wrapper = util.createTransformStreamForWritableSide(this.params.type, 1);
|
|
200
|
+
this.stream = node_stream_1.default.compose(wrapper, writable);
|
|
201
|
+
}
|
|
203
202
|
}
|
|
204
203
|
}
|
|
205
204
|
else
|
|
@@ -232,6 +231,18 @@ class SpeechFlowNodeXIOFile extends speechflow_node_1.default {
|
|
|
232
231
|
}
|
|
233
232
|
this.stream = null;
|
|
234
233
|
}
|
|
234
|
+
/* ensure file descriptor is closed */
|
|
235
|
+
if (this.fd !== null) {
|
|
236
|
+
await new Promise((resolve, reject) => {
|
|
237
|
+
node_fs_1.default.close(this.fd, (err) => {
|
|
238
|
+
this.fd = null;
|
|
239
|
+
if (err)
|
|
240
|
+
reject(err);
|
|
241
|
+
else
|
|
242
|
+
resolve();
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
}
|
|
235
246
|
}
|
|
236
247
|
}
|
|
237
248
|
exports.default = SpeechFlowNodeXIOFile;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"speechflow-node-xio-file.js","sourceRoot":"","sources":["../src/speechflow-node-xio-file.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,6BAA6B;AAC7B,sDAAsC;AACtC,8DAA0C;AAE1C,6BAA6B;AAC7B,
|
|
1
|
+
{"version":3,"file":"speechflow-node-xio-file.js","sourceRoot":"","sources":["../src/speechflow-node-xio-file.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;;;;;;;;;;;;;;;;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CAAC,GAAG,CAAC,CAAA;;wBAEX,OAAO,EAAE,CAAA;gBACjB,CAAC,CAAC,CAAA;YACN,CAAC,CAAC,CAAA;QACN,CAAC;IACL,CAAC;;AAtNL,wCAuNC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"speechflow-node-xio-mqtt.js","sourceRoot":"","sources":["../src/speechflow-node-xio-mqtt.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,6BAA6B;AAC7B,8DAAgC;AAEhC,6BAA6B;AAC7B,gDAAyB;AACzB,0DAA8B;AAE9B,6BAA6B;AAC7B,wEAAmE;AACnE,wDAAmE;AAEnE,2CAA2C;AAC3C,MAAqB,qBAAsB,SAAQ,yBAAc;IAC7D,kCAAkC;IAC3B,MAAM,CAAC,IAAI,GAAG,UAAU,CAAA;IAE/B,sBAAsB;IACd,MAAM,
|
|
1
|
+
{"version":3,"file":"speechflow-node-xio-mqtt.js","sourceRoot":"","sources":["../src/speechflow-node-xio-mqtt.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,6BAA6B;AAC7B,8DAAgC;AAEhC,6BAA6B;AAC7B,gDAAyB;AACzB,0DAA8B;AAE9B,6BAA6B;AAC7B,wEAAmE;AACnE,wDAAmE;AAEnE,2CAA2C;AAC3C,MAAqB,qBAAsB,SAAQ,yBAAc;IAC7D,kCAAkC;IAC3B,MAAM,CAAC,IAAI,GAAG,UAAU,CAAA;IAE/B,sBAAsB;IACd,MAAM,GAAiD,IAAI,CAAA;IAC3D,QAAQ,GAA+C,CAAC,IAAI,mBAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAA;IAC7E,UAAU,GAA6C,IAAI,CAAA;IAEnE,sBAAsB;IACtB,YAAa,EAAU,EAAE,GAA4B,EAAE,IAA6B,EAAE,IAAW;QAC7F,KAAK,CAA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AE,CAAA;YACd,CAAC;YACD,IAAI,CAAE,IAAY;gBACd,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,GAAG;oBACxB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAA;gBACxD,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,UAAW,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;oBAC7C,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;gBAC9B,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAU,EAAE,EAAE;oBACpB,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,yCAAyC,GAAG,EAAE,CAAC,CAAA;gBACvE,CAAC,CAAC,CAAC,CAAA;YACP,CAAC;SACJ,CAAC,CAAA;IACN,CAAC;IAED,kBAAkB;IAClB,KAAK,CAAC,KAAK;QACP,mCAAmC;QACnC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAA;QAEtB,yBAAyB;QACzB,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;YACvB,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS;gBACrB,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAA;YACrB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QACtB,CAAC;QAED,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;;AAzJL,wCA0JC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import SpeechFlowNode from "./speechflow-node";
|
|
2
|
+
export default class SpeechFlowNodeXIOVBAN extends SpeechFlowNode {
|
|
3
|
+
static name: string;
|
|
4
|
+
private server;
|
|
5
|
+
private chunkQueue;
|
|
6
|
+
private frameCounter;
|
|
7
|
+
private targetAddress;
|
|
8
|
+
private targetPort;
|
|
9
|
+
constructor(id: string, cfg: {
|
|
10
|
+
[id: string]: any;
|
|
11
|
+
}, opts: {
|
|
12
|
+
[id: string]: any;
|
|
13
|
+
}, args: any[]);
|
|
14
|
+
private parseAddress;
|
|
15
|
+
open(): Promise<void>;
|
|
16
|
+
close(): Promise<void>;
|
|
17
|
+
}
|