speechflow 1.4.2 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/etc/stx.conf +17 -11
  3. package/package.json +7 -4
  4. package/speechflow-cli/dst/speechflow-node-a2a-ffmpeg.d.ts +13 -0
  5. package/speechflow-cli/dst/speechflow-node-a2a-ffmpeg.js +153 -0
  6. package/speechflow-cli/dst/speechflow-node-a2a-ffmpeg.js.map +1 -0
  7. package/speechflow-cli/dst/speechflow-node-a2a-gender.d.ts +20 -0
  8. package/speechflow-cli/dst/speechflow-node-a2a-gender.js +349 -0
  9. package/speechflow-cli/dst/speechflow-node-a2a-gender.js.map +1 -0
  10. package/speechflow-cli/dst/speechflow-node-a2a-meter.d.ts +16 -0
  11. package/speechflow-cli/dst/speechflow-node-a2a-meter.js +232 -0
  12. package/speechflow-cli/dst/speechflow-node-a2a-meter.js.map +1 -0
  13. package/speechflow-cli/dst/speechflow-node-a2a-mute.d.ts +17 -0
  14. package/speechflow-cli/dst/speechflow-node-a2a-mute.js +117 -0
  15. package/speechflow-cli/dst/speechflow-node-a2a-mute.js.map +1 -0
  16. package/speechflow-cli/dst/speechflow-node-a2a-vad.d.ts +19 -0
  17. package/speechflow-cli/dst/speechflow-node-a2a-vad.js +374 -0
  18. package/speechflow-cli/dst/speechflow-node-a2a-vad.js.map +1 -0
  19. package/speechflow-cli/dst/speechflow-node-a2a-wav.d.ts +11 -0
  20. package/speechflow-cli/dst/speechflow-node-a2a-wav.js +211 -0
  21. package/speechflow-cli/dst/speechflow-node-a2a-wav.js.map +1 -0
  22. package/speechflow-cli/dst/speechflow-node-a2t-deepgram.d.ts +19 -0
  23. package/speechflow-cli/dst/speechflow-node-a2t-deepgram.js +328 -0
  24. package/speechflow-cli/dst/speechflow-node-a2t-deepgram.js.map +1 -0
  25. package/speechflow-cli/dst/speechflow-node-t2a-elevenlabs.d.ts +18 -0
  26. package/speechflow-cli/dst/speechflow-node-t2a-elevenlabs.js +238 -0
  27. package/speechflow-cli/dst/speechflow-node-t2a-elevenlabs.js.map +1 -0
  28. package/speechflow-cli/dst/speechflow-node-t2a-kokoro.d.ts +14 -0
  29. package/speechflow-cli/dst/speechflow-node-t2a-kokoro.js +155 -0
  30. package/speechflow-cli/dst/speechflow-node-t2a-kokoro.js.map +1 -0
  31. package/speechflow-cli/dst/speechflow-node-t2t-deepl.d.ts +15 -0
  32. package/speechflow-cli/dst/speechflow-node-t2t-deepl.js +146 -0
  33. package/speechflow-cli/dst/speechflow-node-t2t-deepl.js.map +1 -0
  34. package/speechflow-cli/dst/speechflow-node-t2t-format.d.ts +11 -0
  35. package/speechflow-cli/dst/speechflow-node-t2t-format.js +82 -0
  36. package/speechflow-cli/dst/speechflow-node-t2t-format.js.map +1 -0
  37. package/speechflow-cli/dst/speechflow-node-t2t-ollama.d.ts +13 -0
  38. package/speechflow-cli/dst/speechflow-node-t2t-ollama.js +247 -0
  39. package/speechflow-cli/dst/speechflow-node-t2t-ollama.js.map +1 -0
  40. package/speechflow-cli/dst/speechflow-node-t2t-openai.d.ts +13 -0
  41. package/speechflow-cli/dst/speechflow-node-t2t-openai.js +227 -0
  42. package/speechflow-cli/dst/speechflow-node-t2t-openai.js.map +1 -0
  43. package/speechflow-cli/dst/speechflow-node-t2t-sentence.d.ts +17 -0
  44. package/speechflow-cli/dst/speechflow-node-t2t-sentence.js +250 -0
  45. package/speechflow-cli/dst/speechflow-node-t2t-sentence.js.map +1 -0
  46. package/speechflow-cli/dst/speechflow-node-t2t-subtitle.d.ts +13 -0
  47. package/speechflow-cli/dst/speechflow-node-t2t-subtitle.js +278 -0
  48. package/speechflow-cli/dst/speechflow-node-t2t-subtitle.js.map +1 -0
  49. package/speechflow-cli/dst/speechflow-node-t2t-transformers.d.ts +14 -0
  50. package/speechflow-cli/dst/speechflow-node-t2t-transformers.js +265 -0
  51. package/speechflow-cli/dst/speechflow-node-t2t-transformers.js.map +1 -0
  52. package/speechflow-cli/dst/speechflow-node-x2x-filter.d.ts +11 -0
  53. package/speechflow-cli/dst/speechflow-node-x2x-filter.js +121 -0
  54. package/speechflow-cli/dst/speechflow-node-x2x-filter.js.map +1 -0
  55. package/speechflow-cli/dst/speechflow-node-x2x-trace.d.ts +11 -0
  56. package/speechflow-cli/dst/speechflow-node-x2x-trace.js +111 -0
  57. package/speechflow-cli/dst/speechflow-node-x2x-trace.js.map +1 -0
  58. package/speechflow-cli/dst/speechflow-node-xio-device.d.ts +13 -0
  59. package/speechflow-cli/dst/speechflow-node-xio-device.js +230 -0
  60. package/speechflow-cli/dst/speechflow-node-xio-device.js.map +1 -0
  61. package/speechflow-cli/dst/speechflow-node-xio-file.d.ts +11 -0
  62. package/speechflow-cli/dst/speechflow-node-xio-file.js +216 -0
  63. package/speechflow-cli/dst/speechflow-node-xio-file.js.map +1 -0
  64. package/speechflow-cli/dst/speechflow-node-xio-mqtt.d.ts +13 -0
  65. package/speechflow-cli/dst/speechflow-node-xio-mqtt.js +188 -0
  66. package/speechflow-cli/dst/speechflow-node-xio-mqtt.js.map +1 -0
  67. package/speechflow-cli/dst/speechflow-node-xio-websocket.d.ts +13 -0
  68. package/speechflow-cli/dst/speechflow-node-xio-websocket.js +278 -0
  69. package/speechflow-cli/dst/speechflow-node-xio-websocket.js.map +1 -0
  70. package/speechflow-cli/dst/speechflow-node.d.ts +65 -0
  71. package/speechflow-cli/dst/speechflow-node.js +180 -0
  72. package/speechflow-cli/dst/speechflow-node.js.map +1 -0
  73. package/speechflow-cli/dst/speechflow-utils.d.ts +74 -0
  74. package/speechflow-cli/dst/speechflow-utils.js +519 -0
  75. package/speechflow-cli/dst/speechflow-utils.js.map +1 -0
  76. package/speechflow-cli/dst/speechflow.d.ts +7 -0
  77. package/speechflow-cli/dst/speechflow.js +837 -0
  78. package/speechflow-cli/dst/speechflow.js.map +1 -0
  79. package/speechflow-cli/etc/stx.conf +13 -13
  80. package/speechflow-cli/package.json +7 -7
  81. package/speechflow-cli/src/speechflow.ts +5 -5
  82. package/speechflow-ui-db/dst/app-font-TypoPRO-SourceSansPro-Bold.eot +0 -0
  83. package/speechflow-ui-db/dst/app-font-TypoPRO-SourceSansPro-Bold.ttf +0 -0
  84. package/speechflow-ui-db/dst/app-font-TypoPRO-SourceSansPro-Bold.woff +0 -0
  85. package/speechflow-ui-db/dst/app-font-TypoPRO-SourceSansPro-Regular.eot +0 -0
  86. package/speechflow-ui-db/dst/app-font-TypoPRO-SourceSansPro-Regular.ttf +0 -0
  87. package/speechflow-ui-db/dst/app-font-TypoPRO-SourceSansPro-Regular.woff +0 -0
  88. package/speechflow-ui-db/dst/app-font-fa-brands-400.woff2 +0 -0
  89. package/speechflow-ui-db/dst/app-font-fa-regular-400.woff2 +0 -0
  90. package/speechflow-ui-db/dst/app-font-fa-solid-900.woff2 +0 -0
  91. package/speechflow-ui-db/dst/app-font-fa-v4compatibility.woff2 +0 -0
  92. package/speechflow-ui-db/dst/app-icon.svg +26 -0
  93. package/speechflow-ui-db/dst/index.css +5 -0
  94. package/speechflow-ui-db/dst/index.html +24 -0
  95. package/speechflow-ui-db/dst/index.js +616 -0
  96. package/speechflow-ui-db/etc/stx.conf +17 -17
  97. package/speechflow-ui-db/package.json +2 -2
  98. package/speechflow-ui-db/src/app.vue +14 -7
  99. package/speechflow-ui-st/dst/app-font-TypoPRO-SourceSansPro-Bold.eot +0 -0
  100. package/speechflow-ui-st/dst/app-font-TypoPRO-SourceSansPro-Bold.ttf +0 -0
  101. package/speechflow-ui-st/dst/app-font-TypoPRO-SourceSansPro-Bold.woff +0 -0
  102. package/speechflow-ui-st/dst/app-font-TypoPRO-SourceSansPro-Regular.eot +0 -0
  103. package/speechflow-ui-st/dst/app-font-TypoPRO-SourceSansPro-Regular.ttf +0 -0
  104. package/speechflow-ui-st/dst/app-font-TypoPRO-SourceSansPro-Regular.woff +0 -0
  105. package/speechflow-ui-st/dst/app-font-fa-brands-400.woff2 +0 -0
  106. package/speechflow-ui-st/dst/app-font-fa-regular-400.woff2 +0 -0
  107. package/speechflow-ui-st/dst/app-font-fa-solid-900.woff2 +0 -0
  108. package/speechflow-ui-st/dst/app-font-fa-v4compatibility.woff2 +0 -0
  109. package/speechflow-ui-st/dst/app-icon.svg +26 -0
  110. package/speechflow-ui-st/dst/index.css +5 -0
  111. package/speechflow-ui-st/dst/index.html +24 -0
  112. package/speechflow-ui-st/dst/index.js +610 -0
  113. package/speechflow-ui-st/etc/stx.conf +17 -17
  114. package/speechflow-ui-st/package.json +2 -2
  115. /package/{speechflow-cli/etc → etc}/speechflow.yaml +0 -0
@@ -0,0 +1,188 @@
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], (err) => {
115
+ if (err)
116
+ this.log("error", `failed to subscribe to MQTT topic "${this.params.topicRead}": ${err.message}`);
117
+ });
118
+ });
119
+ this.broker.on("reconnect", () => {
120
+ this.log("info", `connection re-opened to MQTT ${this.params.url}`);
121
+ });
122
+ this.broker.on("disconnect", (packet) => {
123
+ this.log("info", `connection closed to MQTT ${this.params.url}`);
124
+ });
125
+ const chunkQueue = new utils.SingleQueue();
126
+ this.broker.on("message", (topic, payload, packet) => {
127
+ if (topic !== this.params.topicRead)
128
+ return;
129
+ try {
130
+ const chunk = utils.streamChunkDecode(payload);
131
+ chunkQueue.write(chunk);
132
+ }
133
+ catch (_err) {
134
+ this.log("warning", `received invalid CBOR chunk from MQTT ${this.params.url}`);
135
+ }
136
+ });
137
+ const broker = this.broker;
138
+ const topicWrite = this.params.topicWrite;
139
+ const type = this.params.type;
140
+ const mode = this.params.mode;
141
+ this.stream = new node_stream_1.default.Duplex({
142
+ writableObjectMode: true,
143
+ readableObjectMode: true,
144
+ decodeStrings: false,
145
+ highWaterMark: 1,
146
+ write(chunk, encoding, callback) {
147
+ if (mode === "r")
148
+ callback(new Error("write operation on read-only node"));
149
+ else if (chunk.type !== type)
150
+ callback(new Error(`written chunk is not of ${type} type`));
151
+ else if (!broker.connected)
152
+ callback(new Error("still no MQTT connection available"));
153
+ else {
154
+ const data = Buffer.from(utils.streamChunkEncode(chunk));
155
+ broker.publish(topicWrite, data, { qos: 2, retain: false }, (err) => {
156
+ if (err)
157
+ callback(new Error(`failed to publish to MQTT topic "${topicWrite}": ${err}`));
158
+ else
159
+ callback();
160
+ });
161
+ }
162
+ },
163
+ read(size) {
164
+ if (mode === "w")
165
+ throw new Error("read operation on write-only node");
166
+ chunkQueue.read().then((chunk) => {
167
+ this.push(chunk, "binary");
168
+ });
169
+ }
170
+ });
171
+ }
172
+ /* close node */
173
+ async close() {
174
+ /* close MQTT broker */
175
+ if (this.broker !== null) {
176
+ if (this.broker.connected)
177
+ this.broker.end();
178
+ this.broker = null;
179
+ }
180
+ /* close stream */
181
+ if (this.stream !== null) {
182
+ this.stream.destroy();
183
+ this.stream = null;
184
+ }
185
+ }
186
+ }
187
+ exports.default = SpeechFlowNodeMQTT;
188
+ //# sourceMappingURL=speechflow-node-xio-mqtt.js.map
@@ -0,0 +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,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;oBAC7B,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,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,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;;AA5IL,qCA6IC"}
@@ -0,0 +1,13 @@
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
+ }
@@ -0,0 +1,278 @@
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 ws_1 = __importDefault(require("ws"));
48
+ const reconnecting_websocket_1 = __importDefault(require("@opensumi/reconnecting-websocket"));
49
+ /* internal dependencies */
50
+ const speechflow_node_1 = __importDefault(require("./speechflow-node"));
51
+ const utils = __importStar(require("./speechflow-utils"));
52
+ /* SpeechFlow node for Websocket networking */
53
+ class SpeechFlowNodeWebsocket extends speechflow_node_1.default {
54
+ /* declare official node name */
55
+ static name = "websocket";
56
+ /* internal state */
57
+ server = null;
58
+ client = null;
59
+ /* construct node */
60
+ constructor(id, cfg, opts, args) {
61
+ super(id, cfg, opts, args);
62
+ /* declare node configuration parameters */
63
+ this.configure({
64
+ listen: { type: "string", val: "", match: /^(?:|ws:\/\/(.+?):(\d+))$/ },
65
+ connect: { type: "string", val: "", match: /^(?:|ws:\/\/(.+?):(\d+)(?:\/.*)?)$/ },
66
+ mode: { type: "string", val: "r", match: /^(?:r|w|rw)$/ },
67
+ type: { type: "string", val: "text", match: /^(?:audio|text)$/ }
68
+ });
69
+ /* declare node input/output format */
70
+ if (this.params.mode === "rw") {
71
+ this.input = this.params.type;
72
+ this.output = this.params.type;
73
+ }
74
+ else if (this.params.mode === "r") {
75
+ this.input = "none";
76
+ this.output = this.params.type;
77
+ }
78
+ else if (this.params.mode === "w") {
79
+ this.input = this.params.type;
80
+ this.output = "none";
81
+ }
82
+ }
83
+ /* open node */
84
+ async open() {
85
+ /* sanity check usage */
86
+ if (this.params.listen !== "" && this.params.connect !== "")
87
+ throw new Error("Websocket node cannot listen and connect at the same time");
88
+ else if (this.params.listen === "" && this.params.connect === "")
89
+ throw new Error("Websocket node requires either listen or connect mode");
90
+ if (this.params.listen !== "") {
91
+ /* listen locally on a Websocket port */
92
+ const url = new URL(this.params.listen);
93
+ const websockets = new Set();
94
+ const chunkQueue = new utils.SingleQueue();
95
+ this.server = new ws_1.default.WebSocketServer({
96
+ host: url.hostname,
97
+ port: Number.parseInt(url.port),
98
+ path: url.pathname
99
+ });
100
+ this.server.on("listening", () => {
101
+ this.log("info", `listening on URL ${this.params.listen}`);
102
+ });
103
+ this.server.on("connection", (ws, request) => {
104
+ const peer = `${request.socket.remoteAddress}:${request.socket.remotePort}`;
105
+ this.log("info", `connection opened on URL ${this.params.listen} by peer ${peer}`);
106
+ websockets.add(ws);
107
+ ws.on("close", () => {
108
+ this.log("info", `connection closed on URL ${this.params.listen} by peer ${peer}`);
109
+ websockets.delete(ws);
110
+ });
111
+ ws.on("error", (error) => {
112
+ this.log("error", `error of connection on URL ${this.params.listen} for peer ${peer}: ${error.message}`);
113
+ });
114
+ ws.on("message", (data, isBinary) => {
115
+ if (this.params.mode === "w") {
116
+ this.log("warning", `connection on URL ${this.params.listen} by peer ${peer}: ` +
117
+ "received remote data on write-only node");
118
+ return;
119
+ }
120
+ if (!isBinary) {
121
+ this.log("warning", `connection on URL ${this.params.listen} by peer ${peer}: ` +
122
+ "received non-binary message");
123
+ return;
124
+ }
125
+ let buffer;
126
+ if (Buffer.isBuffer(data))
127
+ buffer = data;
128
+ else if (data instanceof ArrayBuffer)
129
+ buffer = Buffer.from(data);
130
+ else
131
+ buffer = Buffer.concat(data);
132
+ const chunk = utils.streamChunkDecode(buffer);
133
+ chunkQueue.write(chunk);
134
+ });
135
+ });
136
+ this.server.on("error", (error) => {
137
+ this.log("error", `error of some connection on URL ${this.params.listen}: ${error.message}`);
138
+ });
139
+ const type = this.params.type;
140
+ const mode = this.params.mode;
141
+ this.stream = new node_stream_1.default.Duplex({
142
+ writableObjectMode: true,
143
+ readableObjectMode: true,
144
+ decodeStrings: false,
145
+ highWaterMark: 1,
146
+ write(chunk, encoding, callback) {
147
+ if (mode === "r")
148
+ callback(new Error("write operation on read-only node"));
149
+ else if (chunk.type !== type)
150
+ callback(new Error(`written chunk is not of ${type} type`));
151
+ else if (websockets.size === 0)
152
+ callback(new Error("still no Websocket connections available"));
153
+ else {
154
+ const data = utils.streamChunkEncode(chunk);
155
+ const results = [];
156
+ for (const websocket of websockets.values()) {
157
+ results.push(new Promise((resolve, reject) => {
158
+ websocket.send(data, (error) => {
159
+ if (error)
160
+ reject(error);
161
+ else
162
+ resolve();
163
+ });
164
+ }));
165
+ }
166
+ Promise.all(results).then(() => {
167
+ callback();
168
+ }).catch((errors) => {
169
+ const error = new Error(errors.map((e) => e.message).join("; "));
170
+ callback(error);
171
+ });
172
+ }
173
+ },
174
+ read(size) {
175
+ if (mode === "w")
176
+ throw new Error("read operation on write-only node");
177
+ chunkQueue.read().then((chunk) => {
178
+ this.push(chunk, "binary");
179
+ });
180
+ }
181
+ });
182
+ }
183
+ else if (this.params.connect !== "") {
184
+ /* connect remotely to a Websocket port */
185
+ this.client = new reconnecting_websocket_1.default(this.params.connect, [], {
186
+ WebSocket: ws_1.default,
187
+ WebSocketOptions: {},
188
+ reconnectionDelayGrowFactor: 1.3,
189
+ maxReconnectionDelay: 4000,
190
+ minReconnectionDelay: 1000,
191
+ connectionTimeout: 4000,
192
+ minUptime: 5000
193
+ });
194
+ this.client.addEventListener("open", (ev) => {
195
+ this.log("info", `connection opened to URL ${this.params.connect}`);
196
+ });
197
+ this.client.addEventListener("close", (ev) => {
198
+ this.log("info", `connection closed to URL ${this.params.connect}`);
199
+ });
200
+ this.client.addEventListener("error", (ev) => {
201
+ this.log("error", `error of connection on URL ${this.params.connect}: ${ev.error.message}`);
202
+ });
203
+ const chunkQueue = new utils.SingleQueue();
204
+ this.client.addEventListener("message", (ev) => {
205
+ if (this.params.mode === "w") {
206
+ this.log("warning", `connection to URL ${this.params.connect}: ` +
207
+ "received remote data on write-only node");
208
+ return;
209
+ }
210
+ if (!(ev.data instanceof ArrayBuffer)) {
211
+ this.log("warning", `connection to URL ${this.params.connect}: ` +
212
+ "received non-binary message");
213
+ return;
214
+ }
215
+ const buffer = Buffer.from(ev.data);
216
+ const chunk = utils.streamChunkDecode(buffer);
217
+ chunkQueue.write(chunk);
218
+ });
219
+ const client = this.client;
220
+ client.binaryType = "arraybuffer";
221
+ const type = this.params.type;
222
+ const mode = this.params.mode;
223
+ this.stream = new node_stream_1.default.Duplex({
224
+ writableObjectMode: true,
225
+ readableObjectMode: true,
226
+ decodeStrings: false,
227
+ highWaterMark: 1,
228
+ write(chunk, encoding, callback) {
229
+ if (mode === "r")
230
+ callback(new Error("write operation on read-only node"));
231
+ else if (chunk.type !== type)
232
+ callback(new Error(`written chunk is not of ${type} type`));
233
+ else if (!client.OPEN)
234
+ callback(new Error("still no Websocket connection available"));
235
+ else {
236
+ const data = utils.streamChunkEncode(chunk);
237
+ client.send(data);
238
+ callback();
239
+ }
240
+ },
241
+ read(size) {
242
+ if (mode === "w")
243
+ throw new Error("read operation on write-only node");
244
+ chunkQueue.read().then((chunk) => {
245
+ this.push(chunk, "binary");
246
+ });
247
+ }
248
+ });
249
+ }
250
+ }
251
+ /* close node */
252
+ async close() {
253
+ /* close Websocket server */
254
+ if (this.server !== null) {
255
+ await new Promise((resolve, reject) => {
256
+ this.server.close((error) => {
257
+ if (error)
258
+ reject(error);
259
+ else
260
+ resolve();
261
+ });
262
+ });
263
+ this.server = null;
264
+ }
265
+ /* close Websocket client */
266
+ if (this.client !== null) {
267
+ this.client.close();
268
+ this.client = null;
269
+ }
270
+ /* close stream */
271
+ if (this.stream !== null) {
272
+ this.stream.destroy();
273
+ this.stream = null;
274
+ }
275
+ }
276
+ }
277
+ exports.default = SpeechFlowNodeWebsocket;
278
+ //# sourceMappingURL=speechflow-node-xio-websocket.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"speechflow-node-xio-websocket.js","sourceRoot":"","sources":["../src/speechflow-node-xio-websocket.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,6BAA6B;AAC7B,8DAAgC;AAEhC,6BAA6B;AAC7B,4CAAgD;AAChD,8FAA8E;AAE9E,6BAA6B;AAC7B,wEAAmE;AACnE,0DAAoE;AAEpE,gDAAgD;AAChD,MAAqB,uBAAwB,SAAQ,yBAAc;IAC/D,kCAAkC;IAC3B,MAAM,CAAC,IAAI,GAAG,WAAW,CAAA;IAEhC,sBAAsB;IACd,MAAM,GAA8B,IAAI,CAAA;IACxC,MAAM,GAA8B,IAAI,CAAA;IAEhD,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,EAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,EAAM,KAAK,EAAE,2BAA2B,EAAE;YAC5E,OAAO,EAAE,EAAE,IAAI,EAA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AAI,IAAI,KAAK,GAAG;wBACZ,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAA;oBACxD,UAAU,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;wBAC7B,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;oBAC9B,CAAC,CAAC,CAAA;gBACN,CAAC;aACJ,CAAC,CAAA;QACN,CAAC;IACL,CAAC;IAED,kBAAkB;IAClB,KAAK,CAAC,KAAK;QACP,8BAA8B;QAC9B,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;YACvB,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACxC,IAAI,CAAC,MAAO,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;oBACzB,IAAI,KAAK;wBAAE,MAAM,CAAC,KAAK,CAAC,CAAA;;wBACb,OAAO,EAAE,CAAA;gBACxB,CAAC,CAAC,CAAA;YACN,CAAC,CAAC,CAAA;YACF,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QACtB,CAAC;QAED,8BAA8B;QAC9B,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;YACvB,IAAI,CAAC,MAAO,CAAC,KAAK,EAAE,CAAA;YACpB,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;;AArOL,0CAsOC"}
@@ -0,0 +1,65 @@
1
+ import Events from "node:events";
2
+ import Stream from "node:stream";
3
+ import { DateTime, Duration } from "luxon";
4
+ export declare class SpeechFlowChunk {
5
+ timestampStart: Duration;
6
+ timestampEnd: Duration;
7
+ kind: "intermediate" | "final";
8
+ type: "audio" | "text";
9
+ payload: Buffer | string;
10
+ meta: Map<string, any>;
11
+ constructor(timestampStart: Duration, timestampEnd: Duration, kind: "intermediate" | "final", type: "audio" | "text", payload: Buffer | string, meta?: Map<string, any>);
12
+ clone(): SpeechFlowChunk;
13
+ }
14
+ export default class SpeechFlowNode extends Events.EventEmitter {
15
+ id: string;
16
+ private cfg;
17
+ private opts;
18
+ private args;
19
+ static name: string | undefined;
20
+ config: {
21
+ audioChannels: number;
22
+ audioBitDepth: (1 | 8 | 16 | 24 | 32);
23
+ audioLittleEndian: boolean;
24
+ audioSampleRate: number;
25
+ textEncoding: BufferEncoding;
26
+ cacheDir: string;
27
+ };
28
+ input: string;
29
+ output: string;
30
+ params: {
31
+ [id: string]: any;
32
+ };
33
+ stream: Stream.Writable | Stream.Readable | Stream.Duplex | null;
34
+ connectionsIn: Set<SpeechFlowNode>;
35
+ connectionsOut: Set<SpeechFlowNode>;
36
+ timeOpen: DateTime<boolean> | undefined;
37
+ timeZero: DateTime<boolean>;
38
+ timeZeroOffset: Duration<boolean>;
39
+ constructor(id: string, cfg: {
40
+ [id: string]: any;
41
+ }, opts: {
42
+ [id: string]: any;
43
+ }, args: any[]);
44
+ setTimeZero(time: DateTime): void;
45
+ receiveRequest(args: any[]): Promise<void>;
46
+ sendResponse(args: any[]): void;
47
+ dashboardInfo(type: "audio", id: string, kind: "final" | "intermediate", value: number): void;
48
+ dashboardInfo(type: "text", id: string, kind: "final" | "intermediate", value: string): void;
49
+ configure(spec: {
50
+ [id: string]: {
51
+ type: string;
52
+ pos?: number;
53
+ val?: any;
54
+ match?: RegExp | ((x: any) => boolean);
55
+ };
56
+ }): void;
57
+ connect(other: SpeechFlowNode): void;
58
+ disconnect(other: SpeechFlowNode): void;
59
+ log(level: string, msg: string, data?: any): void;
60
+ status(): Promise<{
61
+ [key: string]: string | number;
62
+ }>;
63
+ open(): Promise<void>;
64
+ close(): Promise<void>;
65
+ }