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,278 +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 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
|
-
const server = new ws_1.default.WebSocketServer({
|
|
96
|
-
host: url.hostname,
|
|
97
|
-
port: Number.parseInt(url.port),
|
|
98
|
-
path: url.pathname
|
|
99
|
-
});
|
|
100
|
-
server.on("listening", () => {
|
|
101
|
-
this.log("info", `listening on URL ${this.params.listen}`);
|
|
102
|
-
});
|
|
103
|
-
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
|
-
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.listen}: ` +
|
|
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.listen}: ` +
|
|
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
|
-
const data = utils.streamChunkEncode(chunk);
|
|
236
|
-
client.send(data);
|
|
237
|
-
callback();
|
|
238
|
-
},
|
|
239
|
-
read(size) {
|
|
240
|
-
if (mode === "w")
|
|
241
|
-
throw new Error("read operation on write-only node");
|
|
242
|
-
if (!client.OPEN)
|
|
243
|
-
throw new Error("still no Websocket connection available");
|
|
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
|
|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B,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"}
|
package/dst/speechflow-node.d.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
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", name: string, kind: "final" | "intermediate", value: number): void;
|
|
48
|
-
dashboardInfo(type: "text", name: 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
|
-
}
|
package/dst/speechflow-node.js
DELETED
|
@@ -1,180 +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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
-
};
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.SpeechFlowChunk = void 0;
|
|
12
|
-
/* standard dependencies */
|
|
13
|
-
const node_events_1 = __importDefault(require("node:events"));
|
|
14
|
-
/* external dependencies */
|
|
15
|
-
const luxon_1 = require("luxon");
|
|
16
|
-
/* the definition of a single payload chunk passed through the SpeechFlow nodes */
|
|
17
|
-
class SpeechFlowChunk {
|
|
18
|
-
timestampStart;
|
|
19
|
-
timestampEnd;
|
|
20
|
-
kind;
|
|
21
|
-
type;
|
|
22
|
-
payload;
|
|
23
|
-
meta;
|
|
24
|
-
constructor(timestampStart, timestampEnd, kind, type, payload, meta = new Map()) {
|
|
25
|
-
this.timestampStart = timestampStart;
|
|
26
|
-
this.timestampEnd = timestampEnd;
|
|
27
|
-
this.kind = kind;
|
|
28
|
-
this.type = type;
|
|
29
|
-
this.payload = payload;
|
|
30
|
-
this.meta = meta;
|
|
31
|
-
}
|
|
32
|
-
clone() {
|
|
33
|
-
let payload;
|
|
34
|
-
if (Buffer.isBuffer(this.payload))
|
|
35
|
-
payload = Buffer.from(this.payload);
|
|
36
|
-
else
|
|
37
|
-
payload = String(this.payload);
|
|
38
|
-
return new SpeechFlowChunk(luxon_1.Duration.fromMillis(this.timestampStart.toMillis()), luxon_1.Duration.fromMillis(this.timestampEnd.toMillis()), this.kind, this.type, payload, new Map(this.meta));
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
exports.SpeechFlowChunk = SpeechFlowChunk;
|
|
42
|
-
/* the base class for all SpeechFlow nodes */
|
|
43
|
-
class SpeechFlowNode extends node_events_1.default.EventEmitter {
|
|
44
|
-
id;
|
|
45
|
-
cfg;
|
|
46
|
-
opts;
|
|
47
|
-
args;
|
|
48
|
-
static name;
|
|
49
|
-
/* general constant configuration (for reference) */
|
|
50
|
-
config = {
|
|
51
|
-
audioChannels: 1, /* audio mono channel */
|
|
52
|
-
audioBitDepth: 16, /* audio PCM 16-bit integer */
|
|
53
|
-
audioLittleEndian: true, /* audio PCM little-endian */
|
|
54
|
-
audioSampleRate: 48000, /* audio 48kHz sample rate */
|
|
55
|
-
textEncoding: "utf8", /* UTF-8 text encoding */
|
|
56
|
-
cacheDir: "" /* directory for cache files */
|
|
57
|
-
};
|
|
58
|
-
/* announced information */
|
|
59
|
-
input = "none";
|
|
60
|
-
output = "none";
|
|
61
|
-
params = {};
|
|
62
|
-
stream = null;
|
|
63
|
-
connectionsIn = new Set();
|
|
64
|
-
connectionsOut = new Set();
|
|
65
|
-
timeOpen;
|
|
66
|
-
timeZero = luxon_1.DateTime.fromMillis(0);
|
|
67
|
-
timeZeroOffset = luxon_1.Duration.fromMillis(0);
|
|
68
|
-
/* the default constructor */
|
|
69
|
-
constructor(id, cfg, opts, args) {
|
|
70
|
-
super();
|
|
71
|
-
this.id = id;
|
|
72
|
-
this.cfg = cfg;
|
|
73
|
-
this.opts = opts;
|
|
74
|
-
this.args = args;
|
|
75
|
-
for (const key of Object.keys(cfg)) {
|
|
76
|
-
const idx = key;
|
|
77
|
-
if (this.config[idx] !== undefined)
|
|
78
|
-
this.config[idx] = cfg[key];
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
/* set base/zero time for relative timestamp calculations */
|
|
82
|
-
setTimeZero(time) {
|
|
83
|
-
this.timeZero = time;
|
|
84
|
-
if (this.timeOpen === undefined)
|
|
85
|
-
this.timeOpen = this.timeZero;
|
|
86
|
-
this.timeZeroOffset = this.timeZero.diff(this.timeOpen);
|
|
87
|
-
}
|
|
88
|
-
/* receive external request */
|
|
89
|
-
async receiveRequest(args) {
|
|
90
|
-
/* no-op */
|
|
91
|
-
}
|
|
92
|
-
/* send external response */
|
|
93
|
-
sendResponse(args) {
|
|
94
|
-
this.emit("send-response", args);
|
|
95
|
-
}
|
|
96
|
-
dashboardInfo(type, name, kind, value) {
|
|
97
|
-
this.emit("dashboard-info", { type, name, kind, value });
|
|
98
|
-
}
|
|
99
|
-
/* INTERNAL: utility function: create "params" attribute from constructor of sub-classes */
|
|
100
|
-
configure(spec) {
|
|
101
|
-
for (const name of Object.keys(spec)) {
|
|
102
|
-
if (this.opts[name] !== undefined) {
|
|
103
|
-
/* named parameter */
|
|
104
|
-
if (typeof this.opts[name] !== spec[name].type)
|
|
105
|
-
throw new Error(`invalid type of named parameter "${name}" ` +
|
|
106
|
-
`(has to be ${spec[name].type})`);
|
|
107
|
-
if ("match" in spec[name]
|
|
108
|
-
&& ((spec[name].match instanceof RegExp
|
|
109
|
-
&& this.opts[name].match(spec[name].match) === null)
|
|
110
|
-
|| (typeof spec[name].match === "function"
|
|
111
|
-
&& !spec[name].match(this.opts[name]))))
|
|
112
|
-
throw new Error(`invalid value "${this.opts[name]}" of named parameter "${name}"`);
|
|
113
|
-
this.params[name] = this.opts[name];
|
|
114
|
-
}
|
|
115
|
-
else if (this.opts[name] === undefined
|
|
116
|
-
&& "pos" in spec[name]
|
|
117
|
-
&& typeof spec[name].pos === "number"
|
|
118
|
-
&& spec[name].pos < this.args.length) {
|
|
119
|
-
/* positional argument */
|
|
120
|
-
if (typeof this.args[spec[name].pos] !== spec[name].type)
|
|
121
|
-
throw new Error(`invalid type of positional parameter "${name}" ` +
|
|
122
|
-
`(has to be ${spec[name].type})`);
|
|
123
|
-
if ("match" in spec[name]
|
|
124
|
-
&& this.args[spec[name].pos].match(spec[name].match) === null)
|
|
125
|
-
throw new Error(`invalid value of positional parameter "${name}" ` +
|
|
126
|
-
`(has to match ${spec[name].match})`);
|
|
127
|
-
if ("match" in spec[name]
|
|
128
|
-
&& ((spec[name].match instanceof RegExp
|
|
129
|
-
&& this.args[spec[name].pos].match(spec[name].match) === null)
|
|
130
|
-
|| (typeof spec[name].match === "function"
|
|
131
|
-
&& !spec[name].match(this.args[spec[name].pos]))))
|
|
132
|
-
throw new Error(`invalid value "${this.opts[name]}" of positional parameter "${name}"`);
|
|
133
|
-
this.params[name] = this.args[spec[name].pos];
|
|
134
|
-
}
|
|
135
|
-
else if ("val" in spec[name] && spec[name].val !== undefined)
|
|
136
|
-
/* default argument */
|
|
137
|
-
this.params[name] = spec[name].val;
|
|
138
|
-
else
|
|
139
|
-
throw new Error(`required parameter "${name}" not given`);
|
|
140
|
-
}
|
|
141
|
-
for (const name of Object.keys(this.opts)) {
|
|
142
|
-
if (spec[name] === undefined)
|
|
143
|
-
throw new Error(`named parameter "${name}" not known`);
|
|
144
|
-
}
|
|
145
|
-
for (let i = 0; i < this.args.length; i++) {
|
|
146
|
-
let found = false;
|
|
147
|
-
for (const name of Object.keys(spec))
|
|
148
|
-
if (spec[name].pos === i)
|
|
149
|
-
found = true;
|
|
150
|
-
if (!found)
|
|
151
|
-
throw new Error(`positional parameter #${i} ("${this.args[i]}") ` +
|
|
152
|
-
"not mappable to any known argument");
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
/* connect node to another one */
|
|
156
|
-
connect(other) {
|
|
157
|
-
this.connectionsOut.add(other);
|
|
158
|
-
other.connectionsIn.add(this);
|
|
159
|
-
}
|
|
160
|
-
/* disconnect node from another one */
|
|
161
|
-
disconnect(other) {
|
|
162
|
-
if (!this.connectionsOut.has(other))
|
|
163
|
-
throw new Error("invalid node: not connected to this node");
|
|
164
|
-
this.connectionsOut.delete(other);
|
|
165
|
-
other.connectionsIn.delete(this);
|
|
166
|
-
}
|
|
167
|
-
/* internal log function */
|
|
168
|
-
log(level, msg, data) {
|
|
169
|
-
this.emit("log", level, msg, data);
|
|
170
|
-
}
|
|
171
|
-
/* default implementation for status operation */
|
|
172
|
-
async status() {
|
|
173
|
-
return {};
|
|
174
|
-
}
|
|
175
|
-
/* default implementation for open/close operations */
|
|
176
|
-
async open() { }
|
|
177
|
-
async close() { }
|
|
178
|
-
}
|
|
179
|
-
exports.default = SpeechFlowNode;
|
|
180
|
-
//# sourceMappingURL=speechflow-node.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"speechflow-node.js","sourceRoot":"","sources":["../src/speechflow-node.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;;;;;AAEF,6BAA6B;AAC7B,8DAAgC;AAGhC,6BAA6B;AAC7B,iCAA0C;AAE1C,oFAAoF;AACpF,MAAa,eAAe;IAEb;IACA;IACA;IACA;IACA;IACA;IANX,YACW,cAAwB,EACxB,YAAwB,EACxB,IAAwC,EACxC,IAAgC,EAChC,OAA+B,EAC/B,OAAkB,IAAI,GAAG,EAAe;QALxC,mBAAc,GAAd,cAAc,CAAU;QACxB,iBAAY,GAAZ,YAAY,CAAY;QACxB,SAAI,GAAJ,IAAI,CAAoC;QACxC,SAAI,GAAJ,IAAI,CAA4B;QAChC,YAAO,GAAP,OAAO,CAAwB;QAC/B,SAAI,GAAJ,IAAI,CAAoC;IAChD,CAAC;IACJ,KAAK;QACD,IAAI,OAAwB,CAAA;QAC5B,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;YAC7B,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;;YAEnC,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAClC,OAAO,IAAI,eAAe,CACtB,gBAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,EAA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AAC,CAAA;QACjC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACpC,CAAC;IAED,6BAA6B;IAC7B,GAAG,CAAE,KAAa,EAAE,GAAW,EAAE,IAAU;QACvC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;IACtC,CAAC;IAED,mDAAmD;IACnD,KAAK,CAAC,MAAM;QACR,OAAO,EAAE,CAAA;IACb,CAAC;IAED,wDAAwD;IACxD,KAAK,CAAC,IAAI,KAAM,CAAC;IACjB,KAAK,CAAC,KAAK,KAAK,CAAC;CACpB;AApJD,iCAoJC"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import Stream from "node:stream";
|
|
2
|
-
import { EventEmitter } from "node:events";
|
|
3
|
-
import { DateTime, Duration } from "luxon";
|
|
4
|
-
import { SpeechFlowChunk } from "./speechflow-node";
|
|
5
|
-
export declare function audioBufferDuration(buffer: Buffer, sampleRate?: number, bitDepth?: number, channels?: number, littleEndian?: boolean): number;
|
|
6
|
-
export declare function audioArrayDuration(arr: Float32Array, sampleRate?: number, channels?: number): number;
|
|
7
|
-
export declare function convertBufToF32(buf: Buffer, littleEndian?: boolean): Float32Array<ArrayBuffer>;
|
|
8
|
-
export declare function convertF32ToBuf(arr: Float32Array): Buffer<ArrayBuffer>;
|
|
9
|
-
export declare function createTransformStreamForWritableSide(): Stream.Transform;
|
|
10
|
-
export declare function createTransformStreamForReadableSide(type: "text" | "audio", getTimeZero: () => DateTime): Stream.Transform;
|
|
11
|
-
export declare function ensureStreamChunk(type: "audio" | "text", chunk: SpeechFlowChunk | Buffer | string): string | SpeechFlowChunk | Buffer<ArrayBufferLike>;
|
|
12
|
-
export declare function streamChunkEncode(chunk: SpeechFlowChunk): Uint8Array<ArrayBufferLike>;
|
|
13
|
-
export declare function streamChunkDecode(_data: Uint8Array): SpeechFlowChunk;
|
|
14
|
-
export declare class SingleQueue<T> extends EventEmitter {
|
|
15
|
-
private queue;
|
|
16
|
-
write(item: T): void;
|
|
17
|
-
read(): Promise<T>;
|
|
18
|
-
}
|
|
19
|
-
export declare class DoubleQueue<T0, T1> extends EventEmitter {
|
|
20
|
-
private queue0;
|
|
21
|
-
private queue1;
|
|
22
|
-
private notify;
|
|
23
|
-
write0(item: T0): void;
|
|
24
|
-
write1(item: T1): void;
|
|
25
|
-
read(): Promise<[T0, T1]>;
|
|
26
|
-
}
|
|
27
|
-
export type QueueElement = {
|
|
28
|
-
type: string;
|
|
29
|
-
};
|
|
30
|
-
export declare class QueuePointer<T extends QueueElement> extends EventEmitter {
|
|
31
|
-
private name;
|
|
32
|
-
private queue;
|
|
33
|
-
private index;
|
|
34
|
-
constructor(name: string, queue: Queue<T>);
|
|
35
|
-
maxPosition(): number;
|
|
36
|
-
position(index?: number): number;
|
|
37
|
-
walk(num: number): void;
|
|
38
|
-
walkForwardUntil(type: T["type"]): void;
|
|
39
|
-
walkBackwardUntil(type: T["type"]): void;
|
|
40
|
-
searchForward(type: T["type"]): number;
|
|
41
|
-
searchBackward(type: T["type"]): number;
|
|
42
|
-
peek(position?: number): T;
|
|
43
|
-
read(): T;
|
|
44
|
-
slice(size?: number): T[];
|
|
45
|
-
touch(): void;
|
|
46
|
-
append(element: T): void;
|
|
47
|
-
insert(element: T): void;
|
|
48
|
-
delete(): void;
|
|
49
|
-
}
|
|
50
|
-
export declare class Queue<T extends QueueElement> extends EventEmitter {
|
|
51
|
-
elements: T[];
|
|
52
|
-
private pointers;
|
|
53
|
-
constructor();
|
|
54
|
-
pointerUse(name: string): QueuePointer<T>;
|
|
55
|
-
pointerDelete(name: string): void;
|
|
56
|
-
trim(): void;
|
|
57
|
-
}
|
|
58
|
-
export declare class StreamWrapper extends Stream.Transform {
|
|
59
|
-
private foreignStream;
|
|
60
|
-
constructor(foreignStream: any, options?: Stream.TransformOptions);
|
|
61
|
-
_transform(chunk: any, encoding: BufferEncoding, callback: Stream.TransformCallback): void;
|
|
62
|
-
_flush(callback: Stream.TransformCallback): void;
|
|
63
|
-
}
|
|
64
|
-
export declare class TimeStore<T> extends EventEmitter {
|
|
65
|
-
private tree;
|
|
66
|
-
store(start: Duration, end: Duration, item: T): void;
|
|
67
|
-
fetch(start: Duration, end: Duration): T[];
|
|
68
|
-
prune(_before: Duration): void;
|
|
69
|
-
}
|