speechflow 1.3.1 → 1.4.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/etc/stx.conf +54 -58
- package/package.json +25 -106
- package/{etc → speechflow-cli/etc}/eslint.mjs +1 -2
- package/speechflow-cli/etc/stx.conf +77 -0
- package/speechflow-cli/package.json +116 -0
- package/{src → speechflow-cli/src}/speechflow-node-a2a-gender.ts +148 -64
- package/speechflow-cli/src/speechflow-node-a2a-meter.ts +217 -0
- package/{src → speechflow-cli/src}/speechflow-node-a2a-mute.ts +39 -11
- package/speechflow-cli/src/speechflow-node-a2a-vad.ts +384 -0
- package/{src → speechflow-cli/src}/speechflow-node-a2a-wav.ts +27 -11
- package/speechflow-cli/src/speechflow-node-a2t-deepgram.ts +313 -0
- package/{src → speechflow-cli/src}/speechflow-node-t2a-elevenlabs.ts +59 -12
- package/{src → speechflow-cli/src}/speechflow-node-t2a-kokoro.ts +11 -4
- package/{src → speechflow-cli/src}/speechflow-node-t2t-deepl.ts +9 -4
- package/{src → speechflow-cli/src}/speechflow-node-t2t-format.ts +2 -2
- package/{src → speechflow-cli/src}/speechflow-node-t2t-ollama.ts +1 -1
- package/{src → speechflow-cli/src}/speechflow-node-t2t-openai.ts +1 -1
- package/{src → speechflow-cli/src}/speechflow-node-t2t-sentence.ts +37 -20
- package/speechflow-cli/src/speechflow-node-t2t-subtitle.ts +276 -0
- package/{src → speechflow-cli/src}/speechflow-node-t2t-transformers.ts +4 -3
- package/{src → speechflow-cli/src}/speechflow-node-x2x-filter.ts +9 -5
- package/{src → speechflow-cli/src}/speechflow-node-x2x-trace.ts +16 -8
- package/{src → speechflow-cli/src}/speechflow-node-xio-device.ts +12 -8
- package/{src → speechflow-cli/src}/speechflow-node-xio-file.ts +9 -3
- package/{src → speechflow-cli/src}/speechflow-node-xio-mqtt.ts +5 -2
- package/{src → speechflow-cli/src}/speechflow-node-xio-websocket.ts +12 -12
- package/{src → speechflow-cli/src}/speechflow-node.ts +7 -0
- package/{src → speechflow-cli/src}/speechflow-utils.ts +78 -44
- package/{src → speechflow-cli/src}/speechflow.ts +188 -53
- package/speechflow-ui-db/etc/eslint.mjs +106 -0
- package/speechflow-ui-db/etc/htmllint.json +55 -0
- package/speechflow-ui-db/etc/stx.conf +79 -0
- package/speechflow-ui-db/etc/stylelint.js +46 -0
- package/speechflow-ui-db/etc/stylelint.yaml +33 -0
- package/speechflow-ui-db/etc/tsc-client.json +30 -0
- package/speechflow-ui-db/etc/tsc.node.json +9 -0
- package/speechflow-ui-db/etc/vite-client.mts +63 -0
- package/speechflow-ui-db/package.d/htmllint-cli+0.0.7.patch +20 -0
- package/speechflow-ui-db/package.json +75 -0
- package/speechflow-ui-db/src/app-icon.ai +1989 -4
- package/speechflow-ui-db/src/app-icon.svg +26 -0
- package/speechflow-ui-db/src/app.styl +64 -0
- package/speechflow-ui-db/src/app.vue +221 -0
- package/speechflow-ui-db/src/index.html +23 -0
- package/speechflow-ui-db/src/index.ts +26 -0
- package/{dst/speechflow.d.ts → speechflow-ui-db/src/lib.d.ts} +5 -3
- package/speechflow-ui-db/src/tsconfig.json +3 -0
- package/speechflow-ui-st/etc/eslint.mjs +106 -0
- package/speechflow-ui-st/etc/htmllint.json +55 -0
- package/speechflow-ui-st/etc/stx.conf +79 -0
- package/speechflow-ui-st/etc/stylelint.js +46 -0
- package/speechflow-ui-st/etc/stylelint.yaml +33 -0
- package/speechflow-ui-st/etc/tsc-client.json +30 -0
- package/speechflow-ui-st/etc/tsc.node.json +9 -0
- package/speechflow-ui-st/etc/vite-client.mts +63 -0
- package/speechflow-ui-st/package.d/htmllint-cli+0.0.7.patch +20 -0
- package/speechflow-ui-st/package.json +79 -0
- package/speechflow-ui-st/src/app-icon.ai +1989 -4
- package/speechflow-ui-st/src/app-icon.svg +26 -0
- package/speechflow-ui-st/src/app.styl +64 -0
- package/speechflow-ui-st/src/app.vue +142 -0
- package/speechflow-ui-st/src/index.html +23 -0
- package/speechflow-ui-st/src/index.ts +26 -0
- package/speechflow-ui-st/src/lib.d.ts +9 -0
- package/speechflow-ui-st/src/tsconfig.json +3 -0
- package/dst/speechflow-node-a2a-ffmpeg.d.ts +0 -13
- package/dst/speechflow-node-a2a-ffmpeg.js +0 -153
- package/dst/speechflow-node-a2a-ffmpeg.js.map +0 -1
- package/dst/speechflow-node-a2a-gender.d.ts +0 -18
- package/dst/speechflow-node-a2a-gender.js +0 -271
- package/dst/speechflow-node-a2a-gender.js.map +0 -1
- package/dst/speechflow-node-a2a-meter.d.ts +0 -12
- package/dst/speechflow-node-a2a-meter.js +0 -155
- package/dst/speechflow-node-a2a-meter.js.map +0 -1
- package/dst/speechflow-node-a2a-mute.d.ts +0 -16
- package/dst/speechflow-node-a2a-mute.js +0 -91
- package/dst/speechflow-node-a2a-mute.js.map +0 -1
- package/dst/speechflow-node-a2a-vad.d.ts +0 -16
- package/dst/speechflow-node-a2a-vad.js +0 -285
- package/dst/speechflow-node-a2a-vad.js.map +0 -1
- package/dst/speechflow-node-a2a-wav.d.ts +0 -11
- package/dst/speechflow-node-a2a-wav.js +0 -195
- package/dst/speechflow-node-a2a-wav.js.map +0 -1
- package/dst/speechflow-node-a2t-deepgram.d.ts +0 -15
- package/dst/speechflow-node-a2t-deepgram.js +0 -255
- package/dst/speechflow-node-a2t-deepgram.js.map +0 -1
- package/dst/speechflow-node-t2a-elevenlabs.d.ts +0 -16
- package/dst/speechflow-node-t2a-elevenlabs.js +0 -195
- package/dst/speechflow-node-t2a-elevenlabs.js.map +0 -1
- package/dst/speechflow-node-t2a-kokoro.d.ts +0 -13
- package/dst/speechflow-node-t2a-kokoro.js +0 -149
- package/dst/speechflow-node-t2a-kokoro.js.map +0 -1
- package/dst/speechflow-node-t2t-deepl.d.ts +0 -15
- package/dst/speechflow-node-t2t-deepl.js +0 -142
- package/dst/speechflow-node-t2t-deepl.js.map +0 -1
- package/dst/speechflow-node-t2t-format.d.ts +0 -11
- package/dst/speechflow-node-t2t-format.js +0 -82
- package/dst/speechflow-node-t2t-format.js.map +0 -1
- package/dst/speechflow-node-t2t-ollama.d.ts +0 -13
- package/dst/speechflow-node-t2t-ollama.js +0 -247
- package/dst/speechflow-node-t2t-ollama.js.map +0 -1
- package/dst/speechflow-node-t2t-openai.d.ts +0 -13
- package/dst/speechflow-node-t2t-openai.js +0 -227
- package/dst/speechflow-node-t2t-openai.js.map +0 -1
- package/dst/speechflow-node-t2t-sentence.d.ts +0 -17
- package/dst/speechflow-node-t2t-sentence.js +0 -234
- package/dst/speechflow-node-t2t-sentence.js.map +0 -1
- package/dst/speechflow-node-t2t-subtitle.d.ts +0 -13
- package/dst/speechflow-node-t2t-subtitle.js +0 -278
- package/dst/speechflow-node-t2t-subtitle.js.map +0 -1
- package/dst/speechflow-node-t2t-transformers.d.ts +0 -14
- package/dst/speechflow-node-t2t-transformers.js +0 -265
- package/dst/speechflow-node-t2t-transformers.js.map +0 -1
- package/dst/speechflow-node-x2x-filter.d.ts +0 -11
- package/dst/speechflow-node-x2x-filter.js +0 -117
- package/dst/speechflow-node-x2x-filter.js.map +0 -1
- package/dst/speechflow-node-x2x-trace.d.ts +0 -11
- package/dst/speechflow-node-x2x-trace.js +0 -111
- package/dst/speechflow-node-x2x-trace.js.map +0 -1
- package/dst/speechflow-node-xio-device.d.ts +0 -13
- package/dst/speechflow-node-xio-device.js +0 -226
- package/dst/speechflow-node-xio-device.js.map +0 -1
- package/dst/speechflow-node-xio-file.d.ts +0 -11
- package/dst/speechflow-node-xio-file.js +0 -210
- package/dst/speechflow-node-xio-file.js.map +0 -1
- package/dst/speechflow-node-xio-mqtt.d.ts +0 -13
- package/dst/speechflow-node-xio-mqtt.js +0 -185
- package/dst/speechflow-node-xio-mqtt.js.map +0 -1
- package/dst/speechflow-node-xio-websocket.d.ts +0 -13
- package/dst/speechflow-node-xio-websocket.js +0 -278
- package/dst/speechflow-node-xio-websocket.js.map +0 -1
- package/dst/speechflow-node.d.ts +0 -65
- package/dst/speechflow-node.js +0 -180
- package/dst/speechflow-node.js.map +0 -1
- package/dst/speechflow-utils.d.ts +0 -69
- package/dst/speechflow-utils.js +0 -486
- package/dst/speechflow-utils.js.map +0 -1
- package/dst/speechflow.js +0 -768
- package/dst/speechflow.js.map +0 -1
- package/src/speechflow-node-a2a-meter.ts +0 -130
- package/src/speechflow-node-a2a-vad.ts +0 -285
- package/src/speechflow-node-a2t-deepgram.ts +0 -234
- package/src/speechflow-node-t2t-subtitle.ts +0 -149
- /package/{etc → speechflow-cli/etc}/biome.jsonc +0 -0
- /package/{etc → speechflow-cli/etc}/oxlint.jsonc +0 -0
- /package/{etc → speechflow-cli/etc}/speechflow.bat +0 -0
- /package/{etc → speechflow-cli/etc}/speechflow.sh +0 -0
- /package/{etc → speechflow-cli/etc}/speechflow.yaml +0 -0
- /package/{etc → speechflow-cli/etc}/tsconfig.json +0 -0
- /package/{package.d → speechflow-cli/package.d}/@ericedouard+vad-node-realtime+0.2.0.patch +0 -0
- /package/{src → speechflow-cli/src}/lib.d.ts +0 -0
- /package/{src → speechflow-cli/src}/speechflow-logo.ai +0 -0
- /package/{src → speechflow-cli/src}/speechflow-logo.svg +0 -0
- /package/{src → speechflow-cli/src}/speechflow-node-a2a-ffmpeg.ts +0 -0
- /package/{tsconfig.json → speechflow-cli/tsconfig.json} +0 -0
|
@@ -1,210 +0,0 @@
|
|
|
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_fs_1 = __importDefault(require("node:fs"));
|
|
46
|
-
const node_stream_1 = __importDefault(require("node:stream"));
|
|
47
|
-
/* internal dependencies */
|
|
48
|
-
const speechflow_node_1 = __importDefault(require("./speechflow-node"));
|
|
49
|
-
const utils = __importStar(require("./speechflow-utils"));
|
|
50
|
-
/* SpeechFlow node for file access */
|
|
51
|
-
class SpeechFlowNodeFile extends speechflow_node_1.default {
|
|
52
|
-
/* declare official node name */
|
|
53
|
-
static name = "file";
|
|
54
|
-
/* construct node */
|
|
55
|
-
constructor(id, cfg, opts, args) {
|
|
56
|
-
super(id, cfg, opts, args);
|
|
57
|
-
/* declare node configuration parameters */
|
|
58
|
-
this.configure({
|
|
59
|
-
path: { type: "string", pos: 0, val: "" },
|
|
60
|
-
mode: { type: "string", pos: 1, val: "r", match: /^(?:r|w|rw)$/ },
|
|
61
|
-
type: { type: "string", pos: 2, val: "audio", match: /^(?:audio|text)$/ },
|
|
62
|
-
chunka: { type: "number", val: 200, match: (n) => n >= 10 && n <= 1000 },
|
|
63
|
-
chunkt: { type: "number", val: 65536, match: (n) => n >= 1024 && n <= 131072 }
|
|
64
|
-
});
|
|
65
|
-
/* declare node input/output format */
|
|
66
|
-
if (this.params.mode === "rw") {
|
|
67
|
-
this.input = this.params.type;
|
|
68
|
-
this.output = this.params.type;
|
|
69
|
-
}
|
|
70
|
-
else if (this.params.mode === "r") {
|
|
71
|
-
this.input = "none";
|
|
72
|
-
this.output = this.params.type;
|
|
73
|
-
}
|
|
74
|
-
else if (this.params.mode === "w") {
|
|
75
|
-
this.input = this.params.type;
|
|
76
|
-
this.output = "none";
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/* open node */
|
|
80
|
-
async open() {
|
|
81
|
-
/* determine how many bytes we need per chunk when
|
|
82
|
-
the chunk should be of the required duration/size */
|
|
83
|
-
const highWaterMarkAudio = (this.config.audioSampleRate *
|
|
84
|
-
(this.config.audioBitDepth / 8)) / (1000 / this.params.chunka);
|
|
85
|
-
const highWaterMarkText = this.params.chunkt;
|
|
86
|
-
/* sanity check */
|
|
87
|
-
if (this.params.path === "")
|
|
88
|
-
throw new Error("required parameter \"path\" has to be given");
|
|
89
|
-
/* dispatch according to mode and path */
|
|
90
|
-
if (this.params.mode === "rw") {
|
|
91
|
-
if (this.params.path === "-") {
|
|
92
|
-
/* standard I/O */
|
|
93
|
-
if (this.params.type === "audio") {
|
|
94
|
-
process.stdin.setEncoding();
|
|
95
|
-
process.stdout.setEncoding();
|
|
96
|
-
const streamR = new node_stream_1.default.PassThrough({ highWaterMark: highWaterMarkAudio });
|
|
97
|
-
process.stdin.pipe(streamR);
|
|
98
|
-
const streamW = new node_stream_1.default.PassThrough({ highWaterMark: highWaterMarkAudio });
|
|
99
|
-
streamW.pipe(process.stdout);
|
|
100
|
-
this.stream = node_stream_1.default.Duplex.from({ readable: streamR, writable: streamW });
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
process.stdin.setEncoding(this.config.textEncoding);
|
|
104
|
-
process.stdout.setEncoding(this.config.textEncoding);
|
|
105
|
-
const streamR = new node_stream_1.default.PassThrough({ highWaterMark: highWaterMarkText });
|
|
106
|
-
process.stdin.pipe(streamR);
|
|
107
|
-
const streamW = new node_stream_1.default.PassThrough({ highWaterMark: highWaterMarkText });
|
|
108
|
-
streamW.pipe(process.stdout);
|
|
109
|
-
this.stream = node_stream_1.default.Duplex.from({ readable: streamR, writable: streamW });
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
/* file I/O */
|
|
114
|
-
if (this.params.type === "audio") {
|
|
115
|
-
this.stream = node_stream_1.default.Duplex.from({
|
|
116
|
-
readable: node_fs_1.default.createReadStream(this.params.path, { highWaterMark: highWaterMarkAudio }),
|
|
117
|
-
writable: node_fs_1.default.createWriteStream(this.params.path, { highWaterMark: highWaterMarkAudio })
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
this.stream = node_stream_1.default.Duplex.from({
|
|
122
|
-
readable: node_fs_1.default.createReadStream(this.params.path, {
|
|
123
|
-
highWaterMark: highWaterMarkText,
|
|
124
|
-
encoding: this.config.textEncoding
|
|
125
|
-
}),
|
|
126
|
-
writable: node_fs_1.default.createWriteStream(this.params.path, {
|
|
127
|
-
highWaterMark: highWaterMarkText,
|
|
128
|
-
encoding: this.config.textEncoding
|
|
129
|
-
})
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
/* convert regular stream into object-mode stream */
|
|
134
|
-
const wrapper1 = utils.createTransformStreamForWritableSide();
|
|
135
|
-
const wrapper2 = utils.createTransformStreamForReadableSide(this.params.type, () => this.timeZero);
|
|
136
|
-
this.stream = node_stream_1.default.compose(wrapper1, this.stream, wrapper2);
|
|
137
|
-
}
|
|
138
|
-
else if (this.params.mode === "r") {
|
|
139
|
-
if (this.params.path === "-") {
|
|
140
|
-
/* standard I/O */
|
|
141
|
-
let chunker;
|
|
142
|
-
if (this.params.type === "audio") {
|
|
143
|
-
process.stdin.setEncoding();
|
|
144
|
-
chunker = new node_stream_1.default.PassThrough({ highWaterMark: highWaterMarkAudio });
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
process.stdin.setEncoding(this.config.textEncoding);
|
|
148
|
-
chunker = new node_stream_1.default.PassThrough({ highWaterMark: highWaterMarkText });
|
|
149
|
-
}
|
|
150
|
-
const wrapper = utils.createTransformStreamForReadableSide(this.params.type, () => this.timeZero);
|
|
151
|
-
this.stream = node_stream_1.default.compose(process.stdin, chunker, wrapper);
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
/* file I/O */
|
|
155
|
-
let readable;
|
|
156
|
-
if (this.params.type === "audio")
|
|
157
|
-
readable = node_fs_1.default.createReadStream(this.params.path, { highWaterMark: highWaterMarkAudio });
|
|
158
|
-
else
|
|
159
|
-
readable = node_fs_1.default.createReadStream(this.params.path, { highWaterMark: highWaterMarkText, encoding: this.config.textEncoding });
|
|
160
|
-
const wrapper = utils.createTransformStreamForReadableSide(this.params.type, () => this.timeZero);
|
|
161
|
-
this.stream = node_stream_1.default.compose(readable, wrapper);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
else if (this.params.mode === "w") {
|
|
165
|
-
if (this.params.path === "-") {
|
|
166
|
-
/* standard I/O */
|
|
167
|
-
let chunker;
|
|
168
|
-
if (this.params.type === "audio") {
|
|
169
|
-
process.stdout.setEncoding();
|
|
170
|
-
chunker = new node_stream_1.default.PassThrough({ highWaterMark: highWaterMarkAudio });
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
process.stdout.setEncoding(this.config.textEncoding);
|
|
174
|
-
chunker = new node_stream_1.default.PassThrough({ highWaterMark: highWaterMarkText });
|
|
175
|
-
}
|
|
176
|
-
const wrapper = utils.createTransformStreamForWritableSide();
|
|
177
|
-
this.stream = node_stream_1.default.compose(wrapper, chunker, process.stdout);
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
/* file I/O */
|
|
181
|
-
let writable;
|
|
182
|
-
if (this.params.type === "audio")
|
|
183
|
-
writable = node_fs_1.default.createWriteStream(this.params.path, { highWaterMark: highWaterMarkAudio });
|
|
184
|
-
else
|
|
185
|
-
writable = node_fs_1.default.createWriteStream(this.params.path, { highWaterMark: highWaterMarkText, encoding: this.config.textEncoding });
|
|
186
|
-
const wrapper = utils.createTransformStreamForWritableSide();
|
|
187
|
-
this.stream = node_stream_1.default.compose(wrapper, writable);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
else
|
|
191
|
-
throw new Error(`invalid file mode "${this.params.mode}"`);
|
|
192
|
-
}
|
|
193
|
-
/* close node */
|
|
194
|
-
async close() {
|
|
195
|
-
/* shutdown stream */
|
|
196
|
-
if (this.stream !== null) {
|
|
197
|
-
await new Promise((resolve) => {
|
|
198
|
-
if (this.stream instanceof node_stream_1.default.Writable || this.stream instanceof node_stream_1.default.Duplex)
|
|
199
|
-
this.stream.end(() => { resolve(); });
|
|
200
|
-
else
|
|
201
|
-
resolve();
|
|
202
|
-
});
|
|
203
|
-
if (this.params.path !== "-")
|
|
204
|
-
this.stream.destroy();
|
|
205
|
-
this.stream = null;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
exports.default = SpeechFlowNodeFile;
|
|
210
|
-
//# sourceMappingURL=speechflow-node-xio-file.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,wEAAgD;AAChD,0DAAiD;AAEjD,uCAAuC;AACvC,MAAqB,kBAAmB,SAAQ,yBAAc;IAC1D,kCAAkC;IAC3B,MAAM,CAAC,IAAI,GAAG,MAAM,CAAA;IAE3B,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,EAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;YAC3C,IAAI,EAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAM,KAAK,EAAE,cAAc,EAAE;YACvE,IAAI,EAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE;YAC3E,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAU,GAAG,EAAE,GAAG,EAAM,KAAK,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE;YAC5F,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAU,GAAG,EAAE,KAAK,EAA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G;gBACxB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAA;YACzB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QACtB,CAAC;IACL,CAAC;;AA/KL,qCAgLC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import SpeechFlowNode from "./speechflow-node";
|
|
2
|
-
export default class SpeechFlowNodeMQTT extends SpeechFlowNode {
|
|
3
|
-
static name: string;
|
|
4
|
-
private broker;
|
|
5
|
-
private clientId;
|
|
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,185 +0,0 @@
|
|
|
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 mqtt_1 = __importDefault(require("mqtt"));
|
|
48
|
-
const pure_uuid_1 = __importDefault(require("pure-uuid"));
|
|
49
|
-
/* internal dependencies */
|
|
50
|
-
const speechflow_node_1 = __importDefault(require("./speechflow-node"));
|
|
51
|
-
const utils = __importStar(require("./speechflow-utils"));
|
|
52
|
-
/* SpeechFlow node for MQTT networking */
|
|
53
|
-
class SpeechFlowNodeMQTT extends speechflow_node_1.default {
|
|
54
|
-
/* declare official node name */
|
|
55
|
-
static name = "mqtt";
|
|
56
|
-
/* internal state */
|
|
57
|
-
broker = null;
|
|
58
|
-
clientId = (new pure_uuid_1.default(1)).format();
|
|
59
|
-
/* construct node */
|
|
60
|
-
constructor(id, cfg, opts, args) {
|
|
61
|
-
super(id, cfg, opts, args);
|
|
62
|
-
/* declare node configuration parameters */
|
|
63
|
-
this.configure({
|
|
64
|
-
url: { type: "string", pos: 0, val: "", match: /^(?:|(?:ws|mqtt):\/\/(.+?):(\d+)(?:\/.*)?)$/ },
|
|
65
|
-
username: { type: "string", pos: 1, val: "", match: /^.+$/ },
|
|
66
|
-
password: { type: "string", pos: 2, val: "", match: /^.+$/ },
|
|
67
|
-
topicRead: { type: "string", pos: 3, val: "", match: /^.+$/ },
|
|
68
|
-
topicWrite: { type: "string", pos: 4, val: "", match: /^.+$/ },
|
|
69
|
-
mode: { type: "string", pos: 5, val: "w", match: /^(?:r|w|rw)$/ },
|
|
70
|
-
type: { type: "string", pos: 6, val: "text", match: /^(?:audio|text)$/ }
|
|
71
|
-
});
|
|
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
|
-
/* logical parameter sanity check */
|
|
89
|
-
if (this.params.url === "")
|
|
90
|
-
throw new Error("required parameter \"url\" has to be given");
|
|
91
|
-
if ((this.params.mode === "w" || this.params.mode === "rw") && this.params.topicWrite === "")
|
|
92
|
-
throw new Error("writing to MQTT requires a topicWrite parameter");
|
|
93
|
-
if ((this.params.mode === "r" || this.params.mode === "rw") && this.params.topicRead === "")
|
|
94
|
-
throw new Error("reading from MQTT requires a topicRead parameter");
|
|
95
|
-
/* connect remotely to a MQTT broker */
|
|
96
|
-
this.broker = mqtt_1.default.connect(this.params.url, {
|
|
97
|
-
protocolId: "MQTT",
|
|
98
|
-
protocolVersion: 5,
|
|
99
|
-
username: this.params.username,
|
|
100
|
-
password: this.params.password,
|
|
101
|
-
clientId: this.clientId,
|
|
102
|
-
clean: true,
|
|
103
|
-
resubscribe: true,
|
|
104
|
-
keepalive: 60, /* 60s */
|
|
105
|
-
reconnectPeriod: 2 * 1000, /* 2s */
|
|
106
|
-
connectTimeout: 30 * 1000 /* 30s */
|
|
107
|
-
});
|
|
108
|
-
this.broker.on("error", (error) => {
|
|
109
|
-
this.log("error", `error on MQTT ${this.params.url}: ${error.message}`);
|
|
110
|
-
});
|
|
111
|
-
this.broker.on("connect", (packet) => {
|
|
112
|
-
this.log("info", `connection opened to MQTT ${this.params.url}`);
|
|
113
|
-
if (this.params.mode !== "w" && !packet.sessionPresent)
|
|
114
|
-
this.broker.subscribe([this.params.topicRead], () => { });
|
|
115
|
-
});
|
|
116
|
-
this.broker.on("reconnect", () => {
|
|
117
|
-
this.log("info", `connection re-opened to MQTT ${this.params.url}`);
|
|
118
|
-
});
|
|
119
|
-
this.broker.on("disconnect", (packet) => {
|
|
120
|
-
this.log("info", `connection closed to MQTT ${this.params.url}`);
|
|
121
|
-
});
|
|
122
|
-
const chunkQueue = new utils.SingleQueue();
|
|
123
|
-
this.broker.on("message", (topic, payload, packet) => {
|
|
124
|
-
if (topic !== this.params.topicRead)
|
|
125
|
-
return;
|
|
126
|
-
try {
|
|
127
|
-
const chunk = utils.streamChunkDecode(payload);
|
|
128
|
-
chunkQueue.write(chunk);
|
|
129
|
-
}
|
|
130
|
-
catch (_err) {
|
|
131
|
-
this.log("warning", `received invalid CBOR chunk from MQTT ${this.params.url}`);
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
const broker = this.broker;
|
|
135
|
-
const topicWrite = this.params.topicWrite;
|
|
136
|
-
const type = this.params.type;
|
|
137
|
-
const mode = this.params.mode;
|
|
138
|
-
this.stream = new node_stream_1.default.Duplex({
|
|
139
|
-
writableObjectMode: true,
|
|
140
|
-
readableObjectMode: true,
|
|
141
|
-
decodeStrings: false,
|
|
142
|
-
highWaterMark: 1,
|
|
143
|
-
write(chunk, encoding, callback) {
|
|
144
|
-
if (mode === "r")
|
|
145
|
-
callback(new Error("write operation on read-only node"));
|
|
146
|
-
else if (chunk.type !== type)
|
|
147
|
-
callback(new Error(`written chunk is not of ${type} type`));
|
|
148
|
-
else if (!broker.connected)
|
|
149
|
-
callback(new Error("still no MQTT connection available"));
|
|
150
|
-
else {
|
|
151
|
-
const data = Buffer.from(utils.streamChunkEncode(chunk));
|
|
152
|
-
broker.publish(topicWrite, data, { qos: 2, retain: false }, (err) => {
|
|
153
|
-
if (err)
|
|
154
|
-
callback(new Error(`failed to publish to MQTT topic "${topicWrite}": ${err}`));
|
|
155
|
-
else
|
|
156
|
-
callback();
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
read(size) {
|
|
161
|
-
if (mode === "w")
|
|
162
|
-
throw new Error("read operation on write-only node");
|
|
163
|
-
chunkQueue.read().then((chunk) => {
|
|
164
|
-
this.push(chunk, "binary");
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
/* close node */
|
|
170
|
-
async close() {
|
|
171
|
-
/* close Websocket server */
|
|
172
|
-
if (this.broker !== null) {
|
|
173
|
-
if (this.broker.connected)
|
|
174
|
-
this.broker.end();
|
|
175
|
-
this.broker = null;
|
|
176
|
-
}
|
|
177
|
-
/* close stream */
|
|
178
|
-
if (this.stream !== null) {
|
|
179
|
-
this.stream.destroy();
|
|
180
|
-
this.stream = null;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
exports.default = SpeechFlowNodeMQTT;
|
|
185
|
-
//# sourceMappingURL=speechflow-node-xio-mqtt.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"speechflow-node-xio-mqtt.js","sourceRoot":"","sources":["../src/speechflow-node-xio-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BAC7B,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;gBAC9B,CAAC,CAAC,CAAA;YACN,CAAC;SACJ,CAAC,CAAA;IACN,CAAC;IAED,kBAAkB;IAClB,KAAK,CAAC,KAAK;QACP,8BAA8B;QAC9B,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,oBAAoB;QACpB,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;YACvB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAA;YACrB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QACtB,CAAC;IACL,CAAC;;AAzIL,qCA0IC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import SpeechFlowNode from "./speechflow-node";
|
|
2
|
-
export default class SpeechFlowNodeWebsocket extends SpeechFlowNode {
|
|
3
|
-
static name: string;
|
|
4
|
-
private server;
|
|
5
|
-
private client;
|
|
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
|
-
}
|