speechflow 0.9.9 → 1.1.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 +16 -0
- package/README.md +57 -9
- package/dst/speechflow-node-a2a-ffmpeg.js +1 -0
- package/dst/speechflow-node-a2a-ffmpeg.js.map +1 -0
- package/dst/{speechflow-node-gemma.d.ts → speechflow-node-a2a-meter.d.ts} +2 -3
- package/dst/speechflow-node-a2a-meter.js +151 -0
- package/dst/speechflow-node-a2a-meter.js.map +1 -0
- package/dst/speechflow-node-a2a-mute.d.ts +16 -0
- package/dst/speechflow-node-a2a-mute.js +90 -0
- package/dst/speechflow-node-a2a-mute.js.map +1 -0
- package/dst/speechflow-node-a2a-vad.js +130 -289
- package/dst/speechflow-node-a2a-vad.js.map +1 -0
- package/dst/speechflow-node-a2a-wav.js +1 -0
- package/dst/speechflow-node-a2a-wav.js.map +1 -0
- package/dst/speechflow-node-a2t-deepgram.d.ts +3 -0
- package/dst/speechflow-node-a2t-deepgram.js +18 -2
- package/dst/speechflow-node-a2t-deepgram.js.map +1 -0
- package/dst/speechflow-node-t2a-elevenlabs.d.ts +3 -0
- package/dst/speechflow-node-t2a-elevenlabs.js +9 -1
- package/dst/speechflow-node-t2a-elevenlabs.js.map +1 -0
- package/dst/speechflow-node-t2a-kokoro.js +1 -0
- package/dst/speechflow-node-t2a-kokoro.js.map +1 -0
- package/dst/speechflow-node-t2t-deepl.d.ts +3 -0
- package/dst/speechflow-node-t2t-deepl.js +9 -1
- package/dst/speechflow-node-t2t-deepl.js.map +1 -0
- package/dst/speechflow-node-t2t-format.js +1 -0
- package/dst/speechflow-node-t2t-format.js.map +1 -0
- package/dst/speechflow-node-t2t-ollama.js +1 -0
- package/dst/speechflow-node-t2t-ollama.js.map +1 -0
- package/dst/speechflow-node-t2t-openai.js +2 -1
- package/dst/speechflow-node-t2t-openai.js.map +1 -0
- package/dst/speechflow-node-t2t-subtitle.js +1 -0
- package/dst/speechflow-node-t2t-subtitle.js.map +1 -0
- package/dst/speechflow-node-t2t-transformers.js +10 -6
- package/dst/speechflow-node-t2t-transformers.js.map +1 -0
- package/dst/speechflow-node-x2x-trace.js +2 -1
- package/dst/speechflow-node-x2x-trace.js.map +1 -0
- package/dst/speechflow-node-xio-device.js +4 -1
- package/dst/speechflow-node-xio-device.js.map +1 -0
- package/dst/speechflow-node-xio-file.js +4 -1
- package/dst/speechflow-node-xio-file.js.map +1 -0
- package/dst/speechflow-node-xio-mqtt.js +8 -5
- package/dst/speechflow-node-xio-mqtt.js.map +1 -0
- package/dst/speechflow-node-xio-websocket.js +6 -5
- package/dst/speechflow-node-xio-websocket.js.map +1 -0
- package/dst/speechflow-node.d.ts +8 -1
- package/dst/speechflow-node.js +18 -2
- package/dst/speechflow-node.js.map +1 -0
- package/dst/speechflow-utils.d.ts +33 -0
- package/dst/speechflow-utils.js +183 -1
- package/dst/speechflow-utils.js.map +1 -0
- package/dst/speechflow.js +259 -16
- package/dst/speechflow.js.map +1 -0
- package/etc/speechflow.yaml +9 -7
- package/etc/stx.conf +1 -1
- package/etc/tsconfig.json +2 -2
- package/package.json +19 -12
- package/src/speechflow-node-a2a-meter.ts +129 -0
- package/src/speechflow-node-a2a-mute.ts +101 -0
- package/src/speechflow-node-a2a-vad.ts +266 -0
- package/src/speechflow-node-a2t-deepgram.ts +18 -2
- package/src/speechflow-node-t2a-elevenlabs.ts +9 -1
- package/src/speechflow-node-t2t-deepl.ts +9 -1
- package/src/speechflow-node-t2t-openai.ts +1 -1
- package/src/speechflow-node-t2t-transformers.ts +12 -7
- package/src/speechflow-node-x2x-trace.ts +1 -1
- package/src/speechflow-node-xio-device.ts +4 -1
- package/src/speechflow-node-xio-file.ts +3 -1
- package/src/speechflow-node-xio-mqtt.ts +8 -6
- package/src/speechflow-node-xio-websocket.ts +11 -11
- package/src/speechflow-node.ts +21 -2
- package/src/speechflow-utils.ts +195 -0
- package/src/speechflow.ts +245 -16
- package/dst/speechflow-node-deepgram.d.ts +0 -12
- package/dst/speechflow-node-deepgram.js +0 -220
- package/dst/speechflow-node-deepl.d.ts +0 -12
- package/dst/speechflow-node-deepl.js +0 -128
- package/dst/speechflow-node-device.d.ts +0 -13
- package/dst/speechflow-node-device.js +0 -205
- package/dst/speechflow-node-elevenlabs.d.ts +0 -13
- package/dst/speechflow-node-elevenlabs.js +0 -182
- package/dst/speechflow-node-ffmpeg.d.ts +0 -13
- package/dst/speechflow-node-ffmpeg.js +0 -152
- package/dst/speechflow-node-file.d.ts +0 -11
- package/dst/speechflow-node-file.js +0 -176
- package/dst/speechflow-node-format.d.ts +0 -11
- package/dst/speechflow-node-format.js +0 -80
- package/dst/speechflow-node-gemma.js +0 -213
- package/dst/speechflow-node-mqtt.d.ts +0 -13
- package/dst/speechflow-node-mqtt.js +0 -181
- package/dst/speechflow-node-opus.d.ts +0 -12
- package/dst/speechflow-node-opus.js +0 -135
- package/dst/speechflow-node-subtitle.d.ts +0 -12
- package/dst/speechflow-node-subtitle.js +0 -96
- package/dst/speechflow-node-t2t-gemma.d.ts +0 -13
- package/dst/speechflow-node-t2t-gemma.js +0 -233
- package/dst/speechflow-node-t2t-opus.d.ts +0 -12
- package/dst/speechflow-node-t2t-opus.js +0 -135
- package/dst/speechflow-node-trace.d.ts +0 -11
- package/dst/speechflow-node-trace.js +0 -88
- package/dst/speechflow-node-wav.d.ts +0 -11
- package/dst/speechflow-node-wav.js +0 -170
- package/dst/speechflow-node-websocket.d.ts +0 -13
- package/dst/speechflow-node-websocket.js +0 -275
- package/dst/speechflow-node-whisper-common.d.ts +0 -34
- package/dst/speechflow-node-whisper-common.js +0 -7
- package/dst/speechflow-node-whisper-ggml.d.ts +0 -1
- package/dst/speechflow-node-whisper-ggml.js +0 -97
- package/dst/speechflow-node-whisper-onnx.d.ts +0 -1
- package/dst/speechflow-node-whisper-onnx.js +0 -131
- package/dst/speechflow-node-whisper-worker-ggml.d.ts +0 -1
- package/dst/speechflow-node-whisper-worker-ggml.js +0 -97
- package/dst/speechflow-node-whisper-worker-onnx.d.ts +0 -1
- package/dst/speechflow-node-whisper-worker-onnx.js +0 -131
- package/dst/speechflow-node-whisper-worker.d.ts +0 -1
- package/dst/speechflow-node-whisper-worker.js +0 -116
- package/dst/speechflow-node-whisper-worker2.d.ts +0 -1
- package/dst/speechflow-node-whisper-worker2.js +0 -82
- package/dst/speechflow-node-whisper.d.ts +0 -19
- package/dst/speechflow-node-whisper.js +0 -604
package/dst/speechflow-utils.js
CHANGED
|
@@ -8,8 +8,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
8
8
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.DoubleQueue = exports.SingleQueue = void 0;
|
|
11
|
+
exports.Queue = exports.QueuePointer = exports.DoubleQueue = exports.SingleQueue = void 0;
|
|
12
12
|
exports.audioBufferDuration = audioBufferDuration;
|
|
13
|
+
exports.audioArrayDuration = audioArrayDuration;
|
|
14
|
+
exports.convertBufToF32 = convertBufToF32;
|
|
15
|
+
exports.convertF32ToBuf = convertF32ToBuf;
|
|
13
16
|
exports.createTransformStreamForWritableSide = createTransformStreamForWritableSide;
|
|
14
17
|
exports.createTransformStreamForReadableSide = createTransformStreamForReadableSide;
|
|
15
18
|
exports.ensureStreamChunk = ensureStreamChunk;
|
|
@@ -32,6 +35,26 @@ function audioBufferDuration(buffer, sampleRate = 48000, bitDepth = 16, channels
|
|
|
32
35
|
const totalSamples = buffer.length / (bytesPerSample * channels);
|
|
33
36
|
return totalSamples / sampleRate;
|
|
34
37
|
}
|
|
38
|
+
/* calculate duration of an audio array */
|
|
39
|
+
function audioArrayDuration(arr, sampleRate = 48000, channels = 1) {
|
|
40
|
+
const totalSamples = arr.length / channels;
|
|
41
|
+
return totalSamples / sampleRate;
|
|
42
|
+
}
|
|
43
|
+
/* helper function: convert Buffer in PCM/I16 to Float32Array in PCM/F32 format */
|
|
44
|
+
function convertBufToF32(buf, littleEndian = true) {
|
|
45
|
+
const dataView = new DataView(buf.buffer);
|
|
46
|
+
const arr = new Float32Array(buf.length / 2);
|
|
47
|
+
for (let i = 0; i < arr.length; i++)
|
|
48
|
+
arr[i] = dataView.getInt16(i * 2, littleEndian) / 32768;
|
|
49
|
+
return arr;
|
|
50
|
+
}
|
|
51
|
+
/* helper function: convert Float32Array in PCM/F32 to Buffer in PCM/I16 format */
|
|
52
|
+
function convertF32ToBuf(arr) {
|
|
53
|
+
const int16Array = new Int16Array(arr.length);
|
|
54
|
+
for (let i = 0; i < arr.length; i++)
|
|
55
|
+
int16Array[i] = Math.max(-32768, Math.min(32767, Math.round(arr[i] * 32768)));
|
|
56
|
+
return Buffer.from(int16Array.buffer);
|
|
57
|
+
}
|
|
35
58
|
/* create a Duplex/Transform stream which has
|
|
36
59
|
object-mode on Writable side and buffer/string-mode on Readable side */
|
|
37
60
|
function createTransformStreamForWritableSide() {
|
|
@@ -192,3 +215,162 @@ class DoubleQueue extends node_events_1.EventEmitter {
|
|
|
192
215
|
}
|
|
193
216
|
}
|
|
194
217
|
exports.DoubleQueue = DoubleQueue;
|
|
218
|
+
/* queue pointer */
|
|
219
|
+
class QueuePointer extends node_events_1.EventEmitter {
|
|
220
|
+
name;
|
|
221
|
+
queue;
|
|
222
|
+
/* internal state */
|
|
223
|
+
index = 0;
|
|
224
|
+
/* construction */
|
|
225
|
+
constructor(name, queue) {
|
|
226
|
+
super();
|
|
227
|
+
this.name = name;
|
|
228
|
+
this.queue = queue;
|
|
229
|
+
}
|
|
230
|
+
/* positioning operations */
|
|
231
|
+
maxPosition() {
|
|
232
|
+
return this.queue.elements.length;
|
|
233
|
+
}
|
|
234
|
+
position(index) {
|
|
235
|
+
if (index !== undefined) {
|
|
236
|
+
this.index = index;
|
|
237
|
+
if (this.index < 0)
|
|
238
|
+
this.index = 0;
|
|
239
|
+
else if (this.index >= this.queue.elements.length)
|
|
240
|
+
this.index = this.queue.elements.length;
|
|
241
|
+
this.emit("position", this.index);
|
|
242
|
+
}
|
|
243
|
+
return this.index;
|
|
244
|
+
}
|
|
245
|
+
walk(num) {
|
|
246
|
+
if (num > 0) {
|
|
247
|
+
for (let i = 0; i < num && this.index < this.queue.elements.length; i++)
|
|
248
|
+
this.index++;
|
|
249
|
+
this.emit("position", { start: this.index });
|
|
250
|
+
}
|
|
251
|
+
else if (num < 0) {
|
|
252
|
+
for (let i = 0; i < Math.abs(num) && this.index > 0; i++)
|
|
253
|
+
this.index--;
|
|
254
|
+
this.emit("position", { start: this.index });
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
walkForwardUntil(type) {
|
|
258
|
+
while (this.index < this.queue.elements.length
|
|
259
|
+
&& this.queue.elements[this.index].type !== type)
|
|
260
|
+
this.index++;
|
|
261
|
+
this.emit("position", { start: this.index });
|
|
262
|
+
}
|
|
263
|
+
walkBackwardUntil(type) {
|
|
264
|
+
while (this.index > 0
|
|
265
|
+
&& this.queue.elements[this.index].type !== type)
|
|
266
|
+
this.index--;
|
|
267
|
+
this.emit("position", { start: this.index });
|
|
268
|
+
}
|
|
269
|
+
/* search operations */
|
|
270
|
+
searchForward(type) {
|
|
271
|
+
let position = this.index;
|
|
272
|
+
while (position < this.queue.elements.length
|
|
273
|
+
&& this.queue.elements[position].type !== type)
|
|
274
|
+
position++;
|
|
275
|
+
this.emit("search", { start: this.index, end: position });
|
|
276
|
+
return position;
|
|
277
|
+
}
|
|
278
|
+
searchBackward(type) {
|
|
279
|
+
let position = this.index;
|
|
280
|
+
while (position > 0
|
|
281
|
+
&& this.queue.elements[position].type !== type)
|
|
282
|
+
position--;
|
|
283
|
+
this.emit("search", { start: position, end: this.index });
|
|
284
|
+
return position;
|
|
285
|
+
}
|
|
286
|
+
/* reading operations */
|
|
287
|
+
peek(position) {
|
|
288
|
+
if (position === undefined)
|
|
289
|
+
position = this.index;
|
|
290
|
+
else {
|
|
291
|
+
if (position < 0)
|
|
292
|
+
position = 0;
|
|
293
|
+
else if (position > this.queue.elements.length)
|
|
294
|
+
position = this.queue.elements.length;
|
|
295
|
+
}
|
|
296
|
+
const element = this.queue.elements[position];
|
|
297
|
+
this.queue.emit("read", { start: position, end: position });
|
|
298
|
+
return element;
|
|
299
|
+
}
|
|
300
|
+
read() {
|
|
301
|
+
const element = this.queue.elements[this.index];
|
|
302
|
+
if (this.index < this.queue.elements.length)
|
|
303
|
+
this.index++;
|
|
304
|
+
this.queue.emit("read", { start: this.index - 1, end: this.index - 1 });
|
|
305
|
+
return element;
|
|
306
|
+
}
|
|
307
|
+
slice(size) {
|
|
308
|
+
let slice;
|
|
309
|
+
const start = this.index;
|
|
310
|
+
if (size !== undefined) {
|
|
311
|
+
if (size < 0)
|
|
312
|
+
size = 0;
|
|
313
|
+
else if (size > this.queue.elements.length - this.index)
|
|
314
|
+
size = this.queue.elements.length - this.index;
|
|
315
|
+
slice = this.queue.elements.slice(this.index, size);
|
|
316
|
+
this.index += size;
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
slice = this.queue.elements.slice(this.index);
|
|
320
|
+
this.index = this.queue.elements.length;
|
|
321
|
+
}
|
|
322
|
+
this.queue.emit("read", { start, end: this.index });
|
|
323
|
+
return slice;
|
|
324
|
+
}
|
|
325
|
+
/* writing operations */
|
|
326
|
+
touch() {
|
|
327
|
+
if (this.index >= this.queue.elements.length)
|
|
328
|
+
throw new Error("cannot touch after last element");
|
|
329
|
+
this.queue.emit("write", { start: this.index, end: this.index + 1 });
|
|
330
|
+
}
|
|
331
|
+
append(element) {
|
|
332
|
+
this.queue.elements.push(element);
|
|
333
|
+
this.index = this.queue.elements.length;
|
|
334
|
+
this.queue.emit("write", { start: this.index - 1, end: this.index - 1 });
|
|
335
|
+
}
|
|
336
|
+
insert(element) {
|
|
337
|
+
this.queue.elements.splice(this.index++, 0, element);
|
|
338
|
+
this.queue.emit("write", { start: this.index - 1, end: this.index });
|
|
339
|
+
}
|
|
340
|
+
delete() {
|
|
341
|
+
if (this.index >= this.queue.elements.length)
|
|
342
|
+
throw new Error("cannot delete after last element");
|
|
343
|
+
this.queue.elements.splice(this.index, 1);
|
|
344
|
+
this.queue.emit("write", { start: this.index, end: this.index });
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
exports.QueuePointer = QueuePointer;
|
|
348
|
+
/* queue */
|
|
349
|
+
class Queue extends node_events_1.EventEmitter {
|
|
350
|
+
elements = [];
|
|
351
|
+
pointers = new Map();
|
|
352
|
+
pointerUse(name) {
|
|
353
|
+
if (!this.pointers.has(name))
|
|
354
|
+
this.pointers.set(name, new QueuePointer(name, this));
|
|
355
|
+
return this.pointers.get(name);
|
|
356
|
+
}
|
|
357
|
+
pointerDelete(name) {
|
|
358
|
+
if (!this.pointers.has(name))
|
|
359
|
+
throw new Error("pointer not exists");
|
|
360
|
+
this.pointers.delete(name);
|
|
361
|
+
}
|
|
362
|
+
trim() {
|
|
363
|
+
/* determine minimum pointer position */
|
|
364
|
+
let min = this.elements.length;
|
|
365
|
+
for (const pointer of this.pointers.values())
|
|
366
|
+
if (min > pointer.position())
|
|
367
|
+
min = pointer.position();
|
|
368
|
+
/* trim the maximum amount of first elements */
|
|
369
|
+
this.elements.splice(0, min);
|
|
370
|
+
/* shift all pointers */
|
|
371
|
+
for (const pointer of this.pointers.values())
|
|
372
|
+
pointer.position(pointer.position() - min);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
exports.Queue = Queue;
|
|
376
|
+
//# sourceMappingURL=speechflow-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"speechflow-utils.js","sourceRoot":"","sources":["../src/speechflow-utils.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;;;;;AAYF,kDAeC;AAGD,gDAOC;AAGD,0CAMC;AAGD,0CAKC;AAID,oFAUC;AAID,oFAkBC;AAGD,8CAYC;AAYD,8CAiBC;AAGD,8CAqBC;AA5JD,6BAA6B;AAC7B,8DAAgD;AAChD,6CAA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O,CAAC,QAAQ,EAAE,GAAG,GAAG,CAAC,CAAA;IAClD,CAAC;CACJ;AA3BD,sBA2BC"}
|
package/dst/speechflow.js
CHANGED
|
@@ -5,6 +5,39 @@
|
|
|
5
5
|
** Copyright (c) 2024-2025 Dr. Ralf S. Engelschall <rse@engelschall.com>
|
|
6
6
|
** Licensed under GPL 3.0 <https://spdx.org/licenses/GPL-3.0-only>
|
|
7
7
|
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
8
41
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
42
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
43
|
};
|
|
@@ -13,6 +46,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
46
|
const node_path_1 = __importDefault(require("node:path"));
|
|
14
47
|
const node_stream_1 = __importDefault(require("node:stream"));
|
|
15
48
|
const node_events_1 = require("node:events");
|
|
49
|
+
const HAPI = __importStar(require("@hapi/hapi"));
|
|
50
|
+
const hapi_plugin_websocket_1 = __importDefault(require("hapi-plugin-websocket"));
|
|
51
|
+
const hapi_plugin_header_1 = __importDefault(require("hapi-plugin-header"));
|
|
16
52
|
/* external dependencies */
|
|
17
53
|
const luxon_1 = require("luxon");
|
|
18
54
|
const cli_io_1 = __importDefault(require("cli-io"));
|
|
@@ -24,6 +60,9 @@ const object_path_1 = __importDefault(require("object-path"));
|
|
|
24
60
|
const installed_packages_1 = __importDefault(require("installed-packages"));
|
|
25
61
|
const dotenvx_1 = __importDefault(require("@dotenvx/dotenvx"));
|
|
26
62
|
const syspath_1 = __importDefault(require("syspath"));
|
|
63
|
+
const arktype = __importStar(require("arktype"));
|
|
64
|
+
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
65
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
27
66
|
const package_json_1 = __importDefault(require("../package.json"));
|
|
28
67
|
/* central CLI context */
|
|
29
68
|
let cli = null;
|
|
@@ -41,11 +80,15 @@ let cli = null;
|
|
|
41
80
|
"[-h|--help] " +
|
|
42
81
|
"[-V|--version] " +
|
|
43
82
|
"[-v|--verbose <level>] " +
|
|
83
|
+
"[-a|--address <ip-address>] " +
|
|
84
|
+
"[-p|--port <tcp-port>] " +
|
|
44
85
|
"[-C|--cache <directory>] " +
|
|
86
|
+
"[-S|--status] " +
|
|
45
87
|
"[-e|--expression <expression>] " +
|
|
46
88
|
"[-f|--file <file>] " +
|
|
47
89
|
"[-c|--config <id>@<yaml-config-file>] " +
|
|
48
90
|
"[<argument> [...]]")
|
|
91
|
+
.version(false)
|
|
49
92
|
.option("V", {
|
|
50
93
|
alias: "version",
|
|
51
94
|
type: "boolean",
|
|
@@ -62,6 +105,24 @@ let cli = null;
|
|
|
62
105
|
nargs: 1,
|
|
63
106
|
default: "warning",
|
|
64
107
|
describe: "level for verbose logging ('none', 'error', 'warning', 'info', 'debug')"
|
|
108
|
+
})
|
|
109
|
+
.option("a", {
|
|
110
|
+
alias: "address",
|
|
111
|
+
type: "string",
|
|
112
|
+
array: false,
|
|
113
|
+
coerce,
|
|
114
|
+
nargs: 1,
|
|
115
|
+
default: "0.0.0.0",
|
|
116
|
+
describe: "IP address for REST/WebSocket API"
|
|
117
|
+
})
|
|
118
|
+
.option("p", {
|
|
119
|
+
alias: "port",
|
|
120
|
+
type: "number",
|
|
121
|
+
array: false,
|
|
122
|
+
coerce,
|
|
123
|
+
nargs: 1,
|
|
124
|
+
default: 8484,
|
|
125
|
+
describe: "TCP port for REST/WebSocket API"
|
|
65
126
|
})
|
|
66
127
|
.option("C", {
|
|
67
128
|
alias: "cache",
|
|
@@ -71,6 +132,14 @@ let cli = null;
|
|
|
71
132
|
nargs: 1,
|
|
72
133
|
default: node_path_1.default.join(dataDir, "cache"),
|
|
73
134
|
describe: "directory for cached files (primarily AI model files)"
|
|
135
|
+
})
|
|
136
|
+
.option("S", {
|
|
137
|
+
alias: "status",
|
|
138
|
+
type: "boolean",
|
|
139
|
+
array: false,
|
|
140
|
+
coerce,
|
|
141
|
+
default: false,
|
|
142
|
+
describe: "show one-time status of nodes"
|
|
74
143
|
})
|
|
75
144
|
.option("e", {
|
|
76
145
|
alias: "expression",
|
|
@@ -102,7 +171,6 @@ let cli = null;
|
|
|
102
171
|
.help("h", "show usage help")
|
|
103
172
|
.alias("h", "help")
|
|
104
173
|
.showHelpOnFail(true)
|
|
105
|
-
.version(false)
|
|
106
174
|
.strict()
|
|
107
175
|
.demand(0)
|
|
108
176
|
.parse((0, helpers_1.hideBin)(process.argv));
|
|
@@ -174,6 +242,9 @@ let cli = null;
|
|
|
174
242
|
const pkgsI = [
|
|
175
243
|
"./speechflow-node-a2a-ffmpeg.js",
|
|
176
244
|
"./speechflow-node-a2a-wav.js",
|
|
245
|
+
"./speechflow-node-a2a-mute.js",
|
|
246
|
+
"./speechflow-node-a2a-meter.js",
|
|
247
|
+
"./speechflow-node-a2a-vad.js",
|
|
177
248
|
"./speechflow-node-a2t-deepgram.js",
|
|
178
249
|
"./speechflow-node-t2a-elevenlabs.js",
|
|
179
250
|
"./speechflow-node-t2a-kokoro.js",
|
|
@@ -181,7 +252,6 @@ let cli = null;
|
|
|
181
252
|
"./speechflow-node-t2t-openai.js",
|
|
182
253
|
"./speechflow-node-t2t-ollama.js",
|
|
183
254
|
"./speechflow-node-t2t-transformers.js",
|
|
184
|
-
"./speechflow-node-t2t-opus.js",
|
|
185
255
|
"./speechflow-node-t2t-subtitle.js",
|
|
186
256
|
"./speechflow-node-t2t-format.js",
|
|
187
257
|
"./speechflow-node-x2x-trace.js",
|
|
@@ -217,15 +287,7 @@ let cli = null;
|
|
|
217
287
|
}
|
|
218
288
|
}
|
|
219
289
|
}
|
|
220
|
-
/*
|
|
221
|
-
const flowlink = new flowlink_1.default({
|
|
222
|
-
trace: (msg) => {
|
|
223
|
-
cli.log("debug", msg);
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
let nodenum = 1;
|
|
227
|
-
const variables = { argv: args._, env: process.env };
|
|
228
|
-
const graphNodes = new Set();
|
|
290
|
+
/* static configuration */
|
|
229
291
|
const cfg = {
|
|
230
292
|
audioChannels: 1,
|
|
231
293
|
audioBitDepth: 16,
|
|
@@ -234,6 +296,43 @@ let cli = null;
|
|
|
234
296
|
textEncoding: "utf8",
|
|
235
297
|
cacheDir: args.C
|
|
236
298
|
};
|
|
299
|
+
/* handle one-time status query of nodes */
|
|
300
|
+
if (args.S) {
|
|
301
|
+
const table = new cli_table3_1.default({
|
|
302
|
+
head: [
|
|
303
|
+
chalk_1.default.reset.bold("NODE"),
|
|
304
|
+
chalk_1.default.reset.bold("PROPERTY"),
|
|
305
|
+
chalk_1.default.reset.bold("VALUE")
|
|
306
|
+
],
|
|
307
|
+
colWidths: [15, 15, 50 - (2 * 2 + 2 * 3)],
|
|
308
|
+
style: { "padding-left": 1, "padding-right": 1, border: ["grey"], compact: true },
|
|
309
|
+
chars: { "left-mid": "", mid: "", "mid-mid": "", "right-mid": "" }
|
|
310
|
+
});
|
|
311
|
+
for (const name of Object.keys(nodes)) {
|
|
312
|
+
cli.log("info", `gathering status of node <${name}>`);
|
|
313
|
+
const node = new nodes[name](name, cfg, {}, []);
|
|
314
|
+
const status = await node.status();
|
|
315
|
+
if (Object.keys(status).length > 0) {
|
|
316
|
+
let first = true;
|
|
317
|
+
for (const key of Object.keys(status)) {
|
|
318
|
+
table.push([first ? chalk_1.default.bold(name) : "", key, chalk_1.default.blue(status[key])]);
|
|
319
|
+
first = false;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
const output = table.toString();
|
|
324
|
+
process.stdout.write(output + "\n");
|
|
325
|
+
process.exit(0);
|
|
326
|
+
}
|
|
327
|
+
/* graph processing: PASS 1: parse DSL and create and connect nodes */
|
|
328
|
+
const flowlink = new flowlink_1.default({
|
|
329
|
+
trace: (msg) => {
|
|
330
|
+
cli.log("debug", msg);
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
const variables = { argv: args._, env: process.env };
|
|
334
|
+
const graphNodes = new Set();
|
|
335
|
+
const nodeNums = new Map();
|
|
237
336
|
let ast;
|
|
238
337
|
try {
|
|
239
338
|
ast = flowlink.compile(config);
|
|
@@ -261,17 +360,19 @@ let cli = null;
|
|
|
261
360
|
throw new Error(`unknown node "${id}"`);
|
|
262
361
|
let node;
|
|
263
362
|
try {
|
|
264
|
-
|
|
363
|
+
let num = nodeNums.get(nodes[id]) ?? 0;
|
|
364
|
+
nodeNums.set(nodes[id], ++num);
|
|
365
|
+
const name = num === 1 ? id : `${id}:${num}`;
|
|
366
|
+
node = new nodes[id](name, cfg, opts, args);
|
|
265
367
|
}
|
|
266
368
|
catch (err) {
|
|
267
369
|
/* fatal error */
|
|
268
370
|
if (err instanceof Error)
|
|
269
|
-
cli.log("error", `creation of
|
|
371
|
+
cli.log("error", `creation of <${id}> node failed: ${err.message}`);
|
|
270
372
|
else
|
|
271
|
-
cli.log("error", `creation of
|
|
373
|
+
cli.log("error", `creation of <${id}> node failed: ${err}`);
|
|
272
374
|
process.exit(1);
|
|
273
375
|
}
|
|
274
|
-
nodenum++;
|
|
275
376
|
const params = Object.keys(node.params)
|
|
276
377
|
.map((key) => `${key}: ${JSON.stringify(node.params[key])}`).join(", ");
|
|
277
378
|
cli.log("info", `create node "${node.id}" (${params})`);
|
|
@@ -377,6 +478,144 @@ let cli = null;
|
|
|
377
478
|
}
|
|
378
479
|
});
|
|
379
480
|
}
|
|
481
|
+
/* define external request/response structure */
|
|
482
|
+
const requestValidator = arktype.type({
|
|
483
|
+
request: "string",
|
|
484
|
+
node: "string",
|
|
485
|
+
args: "unknown[]"
|
|
486
|
+
});
|
|
487
|
+
/* forward external request to target node in graph */
|
|
488
|
+
const consumeExternalRequest = async (_req) => {
|
|
489
|
+
const req = requestValidator(_req);
|
|
490
|
+
if (req instanceof arktype.type.errors)
|
|
491
|
+
throw new Error(`invalid request: ${req.summary}`);
|
|
492
|
+
if (req.request !== "COMMAND")
|
|
493
|
+
throw new Error("invalid external request (command expected)");
|
|
494
|
+
const name = req.node;
|
|
495
|
+
const args = req.args;
|
|
496
|
+
const foundNode = Array.from(graphNodes).find((node) => node.id === name);
|
|
497
|
+
if (foundNode === undefined)
|
|
498
|
+
cli.log("warning", `external request failed: no such node <${name}>`);
|
|
499
|
+
else {
|
|
500
|
+
await foundNode.receiveRequest(args).catch((err) => {
|
|
501
|
+
cli.log("warning", `external request to node <${name}> failed: ${err}`);
|
|
502
|
+
throw new Error(`external request to node <${name}> failed: ${err}`);
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
/* establish REST/WebSocket API */
|
|
507
|
+
const wsPeers = new Map();
|
|
508
|
+
const hapi = new HAPI.Server({
|
|
509
|
+
address: args.a,
|
|
510
|
+
port: args.p
|
|
511
|
+
});
|
|
512
|
+
await hapi.register({ plugin: hapi_plugin_header_1.default, options: { Server: `${package_json_1.default.name}/${package_json_1.default.version}` } });
|
|
513
|
+
await hapi.register({ plugin: hapi_plugin_websocket_1.default });
|
|
514
|
+
hapi.events.on("response", (request) => {
|
|
515
|
+
let protocol = `HTTP/${request.raw.req.httpVersion}`;
|
|
516
|
+
const ws = request.websocket();
|
|
517
|
+
if (ws.mode === "websocket") {
|
|
518
|
+
const wsVersion = ws.ws.protocolVersion ??
|
|
519
|
+
request.headers["sec-websocket-version"] ?? "13?";
|
|
520
|
+
protocol = `WebSocket/${wsVersion}+${protocol}`;
|
|
521
|
+
}
|
|
522
|
+
const msg = "remote=" + request.info.remoteAddress + ", " +
|
|
523
|
+
"method=" + request.method.toUpperCase() + ", " +
|
|
524
|
+
"url=" + request.url.pathname + ", " +
|
|
525
|
+
"protocol=" + protocol + ", " +
|
|
526
|
+
"response=" + ("statusCode" in request.response ? request.response.statusCode : "<unknown>");
|
|
527
|
+
cli.log("info", `HAPI: request: ${msg}`);
|
|
528
|
+
});
|
|
529
|
+
hapi.events.on({ name: "request", channels: ["error"] }, (request, event, tags) => {
|
|
530
|
+
if (event.error instanceof Error)
|
|
531
|
+
cli.log("error", `HAPI: request-error: ${event.error.message}`);
|
|
532
|
+
else
|
|
533
|
+
cli.log("error", `HAPI: request-error: ${event.error}`);
|
|
534
|
+
});
|
|
535
|
+
hapi.events.on("log", (event, tags) => {
|
|
536
|
+
if (tags.error) {
|
|
537
|
+
const err = event.error;
|
|
538
|
+
if (err instanceof Error)
|
|
539
|
+
cli.log("error", `HAPI: log: ${err.message}`);
|
|
540
|
+
else
|
|
541
|
+
cli.log("error", `HAPI: log: ${err}`);
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
hapi.route({
|
|
545
|
+
method: "GET",
|
|
546
|
+
path: "/api/{req}/{node}/{params*}",
|
|
547
|
+
options: {},
|
|
548
|
+
handler: (request, h) => {
|
|
549
|
+
const peer = request.info.remoteAddress;
|
|
550
|
+
const req = {
|
|
551
|
+
request: request.params.req,
|
|
552
|
+
node: request.params.node,
|
|
553
|
+
args: (request.params.params ?? "").split("/").filter((seg) => seg !== "")
|
|
554
|
+
};
|
|
555
|
+
cli.log("info", `HAPI: peer ${peer}: GET: ${JSON.stringify(req)}`);
|
|
556
|
+
return consumeExternalRequest(req).then(() => {
|
|
557
|
+
return h.response({ response: "OK" }).code(200);
|
|
558
|
+
}).catch((err) => {
|
|
559
|
+
return h.response({ response: "ERROR", data: err.message }).code(417);
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
hapi.route({
|
|
564
|
+
method: "POST",
|
|
565
|
+
path: "/api",
|
|
566
|
+
options: {
|
|
567
|
+
payload: {
|
|
568
|
+
output: "data",
|
|
569
|
+
parse: true,
|
|
570
|
+
allow: "application/json"
|
|
571
|
+
},
|
|
572
|
+
plugins: {
|
|
573
|
+
websocket: {
|
|
574
|
+
autoping: 30 * 1000,
|
|
575
|
+
connect: (args) => {
|
|
576
|
+
const ctx = args.ctx;
|
|
577
|
+
const ws = args.ws;
|
|
578
|
+
const req = args.req;
|
|
579
|
+
const peer = `${req.socket.remoteAddress}:${req.socket.remotePort}`;
|
|
580
|
+
ctx.peer = peer;
|
|
581
|
+
wsPeers.set(peer, { ctx, ws, req });
|
|
582
|
+
cli.log("info", `HAPI: WebSocket: connect: peer ${peer}`);
|
|
583
|
+
},
|
|
584
|
+
disconnect: (args) => {
|
|
585
|
+
const ctx = args.ctx;
|
|
586
|
+
const peer = ctx.peer;
|
|
587
|
+
wsPeers.delete(peer);
|
|
588
|
+
cli.log("info", `HAPI: WebSocket: disconnect: peer ${peer}`);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
},
|
|
593
|
+
handler: (request, h) => {
|
|
594
|
+
/* on WebSocket message transfer */
|
|
595
|
+
const peer = request.info.remoteAddress;
|
|
596
|
+
const req = requestValidator(request.payload);
|
|
597
|
+
if (req instanceof arktype.type.errors)
|
|
598
|
+
return h.response({ response: "ERROR", data: `invalid request: ${req.summary}` }).code(417);
|
|
599
|
+
cli.log("info", `HAPI: peer ${peer}: POST: ${JSON.stringify(req)}`);
|
|
600
|
+
return consumeExternalRequest(req).then(() => {
|
|
601
|
+
return h.response({ response: "OK" }).code(200);
|
|
602
|
+
}).catch((err) => {
|
|
603
|
+
return h.response({ response: "ERROR", data: err.message }).code(417);
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
await hapi.start();
|
|
608
|
+
cli.log("info", `HAPI: started REST/WebSocket network service: http://${args.address}:${args.port}`);
|
|
609
|
+
/* hook for sendResponse method of nodes */
|
|
610
|
+
for (const node of graphNodes) {
|
|
611
|
+
node.on("send-response", (args) => {
|
|
612
|
+
const data = JSON.stringify({ response: "NOTIFY", node: node.id, args });
|
|
613
|
+
for (const [peer, info] of wsPeers.entries()) {
|
|
614
|
+
cli.log("info", `HAPI: peer ${peer}: ${data}`);
|
|
615
|
+
info.ws.send(data);
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
}
|
|
380
619
|
/* start of internal stream processing */
|
|
381
620
|
cli.log("info", "**** everything established -- stream processing in SpeechFlow graph starts ****");
|
|
382
621
|
/* gracefully shutdown process */
|
|
@@ -389,6 +628,9 @@ let cli = null;
|
|
|
389
628
|
cli.log("info", "**** streams of all nodes finished -- shutting down service ****");
|
|
390
629
|
else
|
|
391
630
|
cli.log("warning", `**** received signal ${signal} -- shutting down service ****`);
|
|
631
|
+
/* shutdown HAPI service */
|
|
632
|
+
cli.log("info", `HAPI: stopping REST/WebSocket network service: http://${args.address}:${args.port}`);
|
|
633
|
+
await hapi.stop();
|
|
392
634
|
/* graph processing: PASS 1: disconnect node streams */
|
|
393
635
|
for (const node of graphNodes) {
|
|
394
636
|
if (node.stream === null) {
|
|
@@ -459,6 +701,7 @@ let cli = null;
|
|
|
459
701
|
if (cli !== null)
|
|
460
702
|
cli.log("error", err.message);
|
|
461
703
|
else
|
|
462
|
-
process.stderr.write(`${package_json_1.default.name}: ERROR: ${err.message}\n`);
|
|
704
|
+
process.stderr.write(`${package_json_1.default.name}: ${chalk_1.default.red("ERROR")}: ${err.message} ${err.stack}\n`);
|
|
463
705
|
process.exit(1);
|
|
464
706
|
});
|
|
707
|
+
//# sourceMappingURL=speechflow.js.map
|