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.
- package/CHANGELOG.md +19 -0
- package/etc/stx.conf +17 -11
- package/package.json +7 -4
- package/speechflow-cli/dst/speechflow-node-a2a-ffmpeg.d.ts +13 -0
- package/speechflow-cli/dst/speechflow-node-a2a-ffmpeg.js +153 -0
- package/speechflow-cli/dst/speechflow-node-a2a-ffmpeg.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-gender.d.ts +20 -0
- package/speechflow-cli/dst/speechflow-node-a2a-gender.js +349 -0
- package/speechflow-cli/dst/speechflow-node-a2a-gender.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-meter.d.ts +16 -0
- package/speechflow-cli/dst/speechflow-node-a2a-meter.js +232 -0
- package/speechflow-cli/dst/speechflow-node-a2a-meter.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-mute.d.ts +17 -0
- package/speechflow-cli/dst/speechflow-node-a2a-mute.js +117 -0
- package/speechflow-cli/dst/speechflow-node-a2a-mute.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-vad.d.ts +19 -0
- package/speechflow-cli/dst/speechflow-node-a2a-vad.js +374 -0
- package/speechflow-cli/dst/speechflow-node-a2a-vad.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-wav.d.ts +11 -0
- package/speechflow-cli/dst/speechflow-node-a2a-wav.js +211 -0
- package/speechflow-cli/dst/speechflow-node-a2a-wav.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2t-deepgram.d.ts +19 -0
- package/speechflow-cli/dst/speechflow-node-a2t-deepgram.js +328 -0
- package/speechflow-cli/dst/speechflow-node-a2t-deepgram.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2a-elevenlabs.d.ts +18 -0
- package/speechflow-cli/dst/speechflow-node-t2a-elevenlabs.js +238 -0
- package/speechflow-cli/dst/speechflow-node-t2a-elevenlabs.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2a-kokoro.d.ts +14 -0
- package/speechflow-cli/dst/speechflow-node-t2a-kokoro.js +155 -0
- package/speechflow-cli/dst/speechflow-node-t2a-kokoro.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2t-deepl.d.ts +15 -0
- package/speechflow-cli/dst/speechflow-node-t2t-deepl.js +146 -0
- package/speechflow-cli/dst/speechflow-node-t2t-deepl.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2t-format.d.ts +11 -0
- package/speechflow-cli/dst/speechflow-node-t2t-format.js +82 -0
- package/speechflow-cli/dst/speechflow-node-t2t-format.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2t-ollama.d.ts +13 -0
- package/speechflow-cli/dst/speechflow-node-t2t-ollama.js +247 -0
- package/speechflow-cli/dst/speechflow-node-t2t-ollama.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2t-openai.d.ts +13 -0
- package/speechflow-cli/dst/speechflow-node-t2t-openai.js +227 -0
- package/speechflow-cli/dst/speechflow-node-t2t-openai.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2t-sentence.d.ts +17 -0
- package/speechflow-cli/dst/speechflow-node-t2t-sentence.js +250 -0
- package/speechflow-cli/dst/speechflow-node-t2t-sentence.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2t-subtitle.d.ts +13 -0
- package/speechflow-cli/dst/speechflow-node-t2t-subtitle.js +278 -0
- package/speechflow-cli/dst/speechflow-node-t2t-subtitle.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2t-transformers.d.ts +14 -0
- package/speechflow-cli/dst/speechflow-node-t2t-transformers.js +265 -0
- package/speechflow-cli/dst/speechflow-node-t2t-transformers.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-x2x-filter.d.ts +11 -0
- package/speechflow-cli/dst/speechflow-node-x2x-filter.js +121 -0
- package/speechflow-cli/dst/speechflow-node-x2x-filter.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-x2x-trace.d.ts +11 -0
- package/speechflow-cli/dst/speechflow-node-x2x-trace.js +111 -0
- package/speechflow-cli/dst/speechflow-node-x2x-trace.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-xio-device.d.ts +13 -0
- package/speechflow-cli/dst/speechflow-node-xio-device.js +230 -0
- package/speechflow-cli/dst/speechflow-node-xio-device.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-xio-file.d.ts +11 -0
- package/speechflow-cli/dst/speechflow-node-xio-file.js +216 -0
- package/speechflow-cli/dst/speechflow-node-xio-file.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-xio-mqtt.d.ts +13 -0
- package/speechflow-cli/dst/speechflow-node-xio-mqtt.js +188 -0
- package/speechflow-cli/dst/speechflow-node-xio-mqtt.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-xio-websocket.d.ts +13 -0
- package/speechflow-cli/dst/speechflow-node-xio-websocket.js +278 -0
- package/speechflow-cli/dst/speechflow-node-xio-websocket.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node.d.ts +65 -0
- package/speechflow-cli/dst/speechflow-node.js +180 -0
- package/speechflow-cli/dst/speechflow-node.js.map +1 -0
- package/speechflow-cli/dst/speechflow-utils.d.ts +74 -0
- package/speechflow-cli/dst/speechflow-utils.js +519 -0
- package/speechflow-cli/dst/speechflow-utils.js.map +1 -0
- package/speechflow-cli/dst/speechflow.d.ts +7 -0
- package/speechflow-cli/dst/speechflow.js +837 -0
- package/speechflow-cli/dst/speechflow.js.map +1 -0
- package/speechflow-cli/etc/stx.conf +13 -13
- package/speechflow-cli/package.json +7 -7
- package/speechflow-cli/src/speechflow.ts +5 -5
- package/speechflow-ui-db/dst/app-font-TypoPRO-SourceSansPro-Bold.eot +0 -0
- package/speechflow-ui-db/dst/app-font-TypoPRO-SourceSansPro-Bold.ttf +0 -0
- package/speechflow-ui-db/dst/app-font-TypoPRO-SourceSansPro-Bold.woff +0 -0
- package/speechflow-ui-db/dst/app-font-TypoPRO-SourceSansPro-Regular.eot +0 -0
- package/speechflow-ui-db/dst/app-font-TypoPRO-SourceSansPro-Regular.ttf +0 -0
- package/speechflow-ui-db/dst/app-font-TypoPRO-SourceSansPro-Regular.woff +0 -0
- package/speechflow-ui-db/dst/app-font-fa-brands-400.woff2 +0 -0
- package/speechflow-ui-db/dst/app-font-fa-regular-400.woff2 +0 -0
- package/speechflow-ui-db/dst/app-font-fa-solid-900.woff2 +0 -0
- package/speechflow-ui-db/dst/app-font-fa-v4compatibility.woff2 +0 -0
- package/speechflow-ui-db/dst/app-icon.svg +26 -0
- package/speechflow-ui-db/dst/index.css +5 -0
- package/speechflow-ui-db/dst/index.html +24 -0
- package/speechflow-ui-db/dst/index.js +616 -0
- package/speechflow-ui-db/etc/stx.conf +17 -17
- package/speechflow-ui-db/package.json +2 -2
- package/speechflow-ui-db/src/app.vue +14 -7
- package/speechflow-ui-st/dst/app-font-TypoPRO-SourceSansPro-Bold.eot +0 -0
- package/speechflow-ui-st/dst/app-font-TypoPRO-SourceSansPro-Bold.ttf +0 -0
- package/speechflow-ui-st/dst/app-font-TypoPRO-SourceSansPro-Bold.woff +0 -0
- package/speechflow-ui-st/dst/app-font-TypoPRO-SourceSansPro-Regular.eot +0 -0
- package/speechflow-ui-st/dst/app-font-TypoPRO-SourceSansPro-Regular.ttf +0 -0
- package/speechflow-ui-st/dst/app-font-TypoPRO-SourceSansPro-Regular.woff +0 -0
- package/speechflow-ui-st/dst/app-font-fa-brands-400.woff2 +0 -0
- package/speechflow-ui-st/dst/app-font-fa-regular-400.woff2 +0 -0
- package/speechflow-ui-st/dst/app-font-fa-solid-900.woff2 +0 -0
- package/speechflow-ui-st/dst/app-font-fa-v4compatibility.woff2 +0 -0
- package/speechflow-ui-st/dst/app-icon.svg +26 -0
- package/speechflow-ui-st/dst/index.css +5 -0
- package/speechflow-ui-st/dst/index.html +24 -0
- package/speechflow-ui-st/dst/index.js +610 -0
- package/speechflow-ui-st/etc/stx.conf +17 -17
- package/speechflow-ui-st/package.json +2 -2
- /package/{speechflow-cli/etc → etc}/speechflow.yaml +0 -0
|
@@ -0,0 +1,230 @@
|
|
|
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 naudiodon_1 = __importDefault(require("@gpeng/naudiodon"));
|
|
48
|
+
/* internal dependencies */
|
|
49
|
+
const speechflow_node_1 = __importDefault(require("./speechflow-node"));
|
|
50
|
+
const utils = __importStar(require("./speechflow-utils"));
|
|
51
|
+
/* SpeechFlow node for device access */
|
|
52
|
+
class SpeechFlowNodeDevice extends speechflow_node_1.default {
|
|
53
|
+
/* declare official node name */
|
|
54
|
+
static name = "device";
|
|
55
|
+
/* internal state */
|
|
56
|
+
io = null;
|
|
57
|
+
/* construct node */
|
|
58
|
+
constructor(id, cfg, opts, args) {
|
|
59
|
+
super(id, cfg, opts, args);
|
|
60
|
+
/* declare node configuration parameters */
|
|
61
|
+
this.configure({
|
|
62
|
+
device: { type: "string", pos: 0, val: "", match: /^(.+?):(.+)$/ },
|
|
63
|
+
mode: { type: "string", pos: 1, val: "rw", match: /^(?:r|w|rw)$/ },
|
|
64
|
+
chunk: { type: "number", pos: 2, val: 200, match: (n) => n >= 10 && n <= 1000 }
|
|
65
|
+
});
|
|
66
|
+
/* declare node input/output format */
|
|
67
|
+
if (this.params.mode === "rw") {
|
|
68
|
+
this.input = "audio";
|
|
69
|
+
this.output = "audio";
|
|
70
|
+
}
|
|
71
|
+
else if (this.params.mode === "r") {
|
|
72
|
+
this.input = "none";
|
|
73
|
+
this.output = "audio";
|
|
74
|
+
}
|
|
75
|
+
else if (this.params.mode === "w") {
|
|
76
|
+
this.input = "audio";
|
|
77
|
+
this.output = "none";
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/* INTERNAL: utility function for finding audio device by pseudo-URL notation */
|
|
81
|
+
audioDeviceFromURL(mode, url) {
|
|
82
|
+
/* parse URL */
|
|
83
|
+
const m = url.match(/^(.+?):(.+)$/);
|
|
84
|
+
if (m === null)
|
|
85
|
+
throw new Error(`invalid audio device URL "${url}"`);
|
|
86
|
+
const [, type, name] = m;
|
|
87
|
+
/* determine audio API */
|
|
88
|
+
const apis = naudiodon_1.default.getHostAPIs();
|
|
89
|
+
const api = apis.HostAPIs.find((api) => api.type.toLowerCase() === type.toLowerCase());
|
|
90
|
+
if (!api)
|
|
91
|
+
throw new Error(`invalid audio API type "${type}"`);
|
|
92
|
+
/* determine device of audio API */
|
|
93
|
+
const devices = naudiodon_1.default.getDevices();
|
|
94
|
+
for (const device of devices)
|
|
95
|
+
this.log("info", `found audio device "${device.name}" ` +
|
|
96
|
+
`(inputs: ${device.maxInputChannels}, outputs: ${device.maxOutputChannels}`);
|
|
97
|
+
const device = devices.find((device) => {
|
|
98
|
+
return (((mode === "r" && device.maxInputChannels > 0)
|
|
99
|
+
|| (mode === "w" && device.maxOutputChannels > 0)
|
|
100
|
+
|| (mode === "rw" && device.maxInputChannels > 0 && device.maxOutputChannels > 0)
|
|
101
|
+
|| (mode === "any" && (device.maxInputChannels > 0 || device.maxOutputChannels > 0)))
|
|
102
|
+
&& device.name.match(name)
|
|
103
|
+
&& device.hostAPIName === api.name);
|
|
104
|
+
});
|
|
105
|
+
if (!device)
|
|
106
|
+
throw new Error(`invalid audio device "${name}" (of audio API type "${type}")`);
|
|
107
|
+
return device;
|
|
108
|
+
}
|
|
109
|
+
/* open node */
|
|
110
|
+
async open() {
|
|
111
|
+
if (this.params.device === "")
|
|
112
|
+
throw new Error("required parameter \"device\" has to be given");
|
|
113
|
+
/* determine device */
|
|
114
|
+
const device = this.audioDeviceFromURL(this.params.mode, this.params.device);
|
|
115
|
+
/* sanity check sample rate compatibility
|
|
116
|
+
(we still do not resample in input/output for simplification reasons) */
|
|
117
|
+
if (device.defaultSampleRate !== this.config.audioSampleRate)
|
|
118
|
+
throw new Error(`audio device sample rate ${device.defaultSampleRate} is ` +
|
|
119
|
+
`incompatible with required sample rate ${this.config.audioSampleRate}`);
|
|
120
|
+
/* determine how many bytes we need per chunk when
|
|
121
|
+
the chunk should be the requested duration */
|
|
122
|
+
const highwaterMark = (this.config.audioSampleRate *
|
|
123
|
+
(this.config.audioBitDepth / 8)) / (1000 / this.params.chunk);
|
|
124
|
+
/* establish device connection
|
|
125
|
+
Notice: "naudion" actually implements Stream.{Readable,Writable,Duplex}, but
|
|
126
|
+
declares just its sub-interface NodeJS.{Readable,Writable,Duplex}Stream,
|
|
127
|
+
so it is correct to cast it back to Stream.{Readable,Writable,Duplex} */
|
|
128
|
+
/* FIXME: the underlying PortAudio outputs verbose/debugging messages */
|
|
129
|
+
if (this.params.mode === "rw") {
|
|
130
|
+
/* input/output device */
|
|
131
|
+
if (device.maxInputChannels === 0)
|
|
132
|
+
throw new Error(`device "${device.id}" does not have any input channels (required by read/write mode)`);
|
|
133
|
+
if (device.maxOutputChannels === 0)
|
|
134
|
+
throw new Error(`device "${device.id}" does not have any output channels (required by read/write mode)`);
|
|
135
|
+
this.log("info", `resolved "${this.params.device}" to duplex device "${device.id}"`);
|
|
136
|
+
this.io = naudiodon_1.default.AudioIO({
|
|
137
|
+
inOptions: {
|
|
138
|
+
deviceId: device.id,
|
|
139
|
+
channelCount: this.config.audioChannels,
|
|
140
|
+
sampleRate: this.config.audioSampleRate,
|
|
141
|
+
sampleFormat: this.config.audioBitDepth,
|
|
142
|
+
highwaterMark
|
|
143
|
+
},
|
|
144
|
+
outOptions: {
|
|
145
|
+
deviceId: device.id,
|
|
146
|
+
channelCount: this.config.audioChannels,
|
|
147
|
+
sampleRate: this.config.audioSampleRate,
|
|
148
|
+
sampleFormat: this.config.audioBitDepth,
|
|
149
|
+
highwaterMark
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
this.stream = this.io;
|
|
153
|
+
/* convert regular stream into object-mode stream */
|
|
154
|
+
const wrapper1 = utils.createTransformStreamForWritableSide();
|
|
155
|
+
const wrapper2 = utils.createTransformStreamForReadableSide("audio", () => this.timeZero);
|
|
156
|
+
this.stream = node_stream_1.default.compose(wrapper1, this.stream, wrapper2);
|
|
157
|
+
}
|
|
158
|
+
else if (this.params.mode === "r") {
|
|
159
|
+
/* input device */
|
|
160
|
+
if (device.maxInputChannels === 0)
|
|
161
|
+
throw new Error(`device "${device.id}" does not have any input channels (required by read mode)`);
|
|
162
|
+
this.log("info", `resolved "${this.params.device}" to input device "${device.id}"`);
|
|
163
|
+
this.io = naudiodon_1.default.AudioIO({
|
|
164
|
+
inOptions: {
|
|
165
|
+
deviceId: device.id,
|
|
166
|
+
channelCount: this.config.audioChannels,
|
|
167
|
+
sampleRate: this.config.audioSampleRate,
|
|
168
|
+
sampleFormat: this.config.audioBitDepth,
|
|
169
|
+
highwaterMark
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
this.stream = this.io;
|
|
173
|
+
/* convert regular stream into object-mode stream */
|
|
174
|
+
const wrapper = utils.createTransformStreamForReadableSide("audio", () => this.timeZero);
|
|
175
|
+
this.stream = node_stream_1.default.compose(this.stream, wrapper);
|
|
176
|
+
}
|
|
177
|
+
else if (this.params.mode === "w") {
|
|
178
|
+
/* output device */
|
|
179
|
+
if (device.maxOutputChannels === 0)
|
|
180
|
+
throw new Error(`device "${device.id}" does not have any output channels (required by write mode)`);
|
|
181
|
+
this.log("info", `resolved "${this.params.device}" to output device "${device.id}"`);
|
|
182
|
+
this.io = naudiodon_1.default.AudioIO({
|
|
183
|
+
outOptions: {
|
|
184
|
+
deviceId: device.id,
|
|
185
|
+
channelCount: this.config.audioChannels,
|
|
186
|
+
sampleRate: this.config.audioSampleRate,
|
|
187
|
+
sampleFormat: this.config.audioBitDepth,
|
|
188
|
+
highwaterMark
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
this.stream = this.io;
|
|
192
|
+
/* convert regular stream into object-mode stream */
|
|
193
|
+
const wrapper = utils.createTransformStreamForWritableSide();
|
|
194
|
+
this.stream = node_stream_1.default.compose(wrapper, this.stream);
|
|
195
|
+
}
|
|
196
|
+
else
|
|
197
|
+
throw new Error(`device "${device.id}" does not have any input or output channels`);
|
|
198
|
+
/* pass-through PortAudio errors */
|
|
199
|
+
this.io.on("error", (err) => {
|
|
200
|
+
this.emit("error", err);
|
|
201
|
+
});
|
|
202
|
+
/* start PortAudio */
|
|
203
|
+
this.io.start();
|
|
204
|
+
}
|
|
205
|
+
/* close node */
|
|
206
|
+
async close() {
|
|
207
|
+
/* shutdown PortAudio */
|
|
208
|
+
if (this.io !== null) {
|
|
209
|
+
await new Promise((resolve, reject) => {
|
|
210
|
+
this.io.abort((err) => {
|
|
211
|
+
if (err)
|
|
212
|
+
reject(err);
|
|
213
|
+
else
|
|
214
|
+
resolve();
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
await new Promise((resolve, reject) => {
|
|
218
|
+
this.io.quit((err) => {
|
|
219
|
+
if (err)
|
|
220
|
+
reject(err);
|
|
221
|
+
else
|
|
222
|
+
resolve();
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
this.io = null;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
exports.default = SpeechFlowNodeDevice;
|
|
230
|
+
//# sourceMappingURL=speechflow-node-xio-device.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"speechflow-node-xio-device.js","sourceRoot":"","sources":["../src/speechflow-node-xio-device.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,6BAA6B;AAC7B,8DAA0C;AAE1C,6BAA6B;AAC7B,iEAA+C;A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K,CAAC,CAAC,GAAW,EAAE,EAAE;oBAC3B,IAAI,GAAG;wBACH,MAAM,CAAC,GAAG,CAAC,CAAA;;wBAEX,OAAO,EAAE,CAAA;gBACjB,CAAC,CAAC,CAAA;YACN,CAAC,CAAC,CAAA;YACF,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACxC,IAAI,CAAC,EAAG,CAAC,IAAI,CAAC,CAAC,GAAW,EAAE,EAAE;oBAC1B,IAAI,GAAG;wBACH,MAAM,CAAC,GAAG,CAAC,CAAA;;wBAEX,OAAO,EAAE,CAAA;gBACjB,CAAC,CAAC,CAAA;YACN,CAAC,CAAC,CAAA;YACF,IAAI,CAAC,EAAE,GAAG,IAAI,CAAA;QAClB,CAAC;IACL,CAAC;;AAxML,uCAyMC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import SpeechFlowNode from "./speechflow-node";
|
|
2
|
+
export default class SpeechFlowNodeFile extends SpeechFlowNode {
|
|
3
|
+
static name: string;
|
|
4
|
+
constructor(id: string, cfg: {
|
|
5
|
+
[id: string]: any;
|
|
6
|
+
}, opts: {
|
|
7
|
+
[id: string]: any;
|
|
8
|
+
}, args: any[]);
|
|
9
|
+
open(): Promise<void>;
|
|
10
|
+
close(): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
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, reject) => {
|
|
198
|
+
if (this.stream instanceof node_stream_1.default.Writable || this.stream instanceof node_stream_1.default.Duplex) {
|
|
199
|
+
this.stream.end((err) => {
|
|
200
|
+
if (err)
|
|
201
|
+
reject(err);
|
|
202
|
+
else
|
|
203
|
+
resolve();
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
else
|
|
207
|
+
resolve();
|
|
208
|
+
});
|
|
209
|
+
if (this.params.path !== "-")
|
|
210
|
+
this.stream.destroy();
|
|
211
|
+
this.stream = null;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
exports.default = SpeechFlowNodeFile;
|
|
216
|
+
//# sourceMappingURL=speechflow-node-xio-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"speechflow-node-xio-file.js","sourceRoot":"","sources":["../src/speechflow-node-xio-file.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,6BAA6B;AAC7B,sDAAsC;AACtC,8DAA0C;AAE1C,6BAA6B;AAC7B,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,I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MAAM,CAAC,GAAG,CAAC,CAAA;;4BAEX,OAAO,EAAE,CAAA;oBACjB,CAAC,CAAC,CAAA;gBACN,CAAC;;oBAEG,OAAO,EAAE,CAAA;YACjB,CAAC,CAAC,CAAA;YACF,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,GAAG;gBACxB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAA;YACzB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QACtB,CAAC;IACL,CAAC;;AArLL,qCAsLC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
}
|