speechflow 1.6.0 → 1.6.2
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 +12 -0
- package/README.md +1 -1
- package/etc/claude.md +9 -4
- package/etc/keyfiles.txt +19 -0
- package/etc/speechflow.yaml +4 -4
- package/package.json +3 -3
- package/speechflow-cli/dst/speechflow-main-api.d.ts +12 -0
- package/speechflow-cli/dst/speechflow-main-api.js +319 -0
- package/speechflow-cli/dst/speechflow-main-api.js.map +1 -0
- package/speechflow-cli/dst/speechflow-main-cli.d.ts +28 -0
- package/speechflow-cli/dst/speechflow-main-cli.js +271 -0
- package/speechflow-cli/dst/speechflow-main-cli.js.map +1 -0
- package/speechflow-cli/dst/speechflow-main-config.d.ts +9 -0
- package/speechflow-cli/dst/speechflow-main-config.js +27 -0
- package/speechflow-cli/dst/speechflow-main-config.js.map +1 -0
- package/speechflow-cli/dst/speechflow-main-graph.d.ts +34 -0
- package/speechflow-cli/dst/speechflow-main-graph.js +365 -0
- package/speechflow-cli/dst/speechflow-main-graph.js.map +1 -0
- package/speechflow-cli/dst/speechflow-main-nodes.d.ts +10 -0
- package/speechflow-cli/dst/speechflow-main-nodes.js +60 -0
- package/speechflow-cli/dst/speechflow-main-nodes.js.map +1 -0
- package/speechflow-cli/dst/speechflow-main-status.d.ts +11 -0
- package/speechflow-cli/dst/speechflow-main-status.js +60 -0
- package/speechflow-cli/dst/speechflow-main-status.js.map +1 -0
- package/speechflow-cli/dst/speechflow-main.d.ts +7 -0
- package/speechflow-cli/dst/speechflow-main.js +127 -0
- package/speechflow-cli/dst/speechflow-main.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-compressor-wt.js +4 -4
- package/speechflow-cli/dst/speechflow-node-a2a-compressor-wt.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-compressor.js +5 -6
- package/speechflow-cli/dst/speechflow-node-a2a-compressor.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-expander-wt.js +5 -5
- package/speechflow-cli/dst/speechflow-node-a2a-expander-wt.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-expander.js +5 -6
- package/speechflow-cli/dst/speechflow-node-a2a-expander.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-ffmpeg.js +5 -5
- package/speechflow-cli/dst/speechflow-node-a2a-ffmpeg.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-filler.js +3 -3
- package/speechflow-cli/dst/speechflow-node-a2a-filler.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-gain.js +2 -2
- package/speechflow-cli/dst/speechflow-node-a2a-gain.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-gender.js +4 -4
- package/speechflow-cli/dst/speechflow-node-a2a-gender.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-meter.js +2 -2
- package/speechflow-cli/dst/speechflow-node-a2a-meter.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-rnnoise.js +4 -4
- package/speechflow-cli/dst/speechflow-node-a2a-rnnoise.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-speex.js +4 -4
- package/speechflow-cli/dst/speechflow-node-a2a-speex.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-vad.js +4 -4
- package/speechflow-cli/dst/speechflow-node-a2a-vad.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2t-amazon.js +6 -6
- package/speechflow-cli/dst/speechflow-node-a2t-amazon.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2t-deepgram.js +4 -4
- package/speechflow-cli/dst/speechflow-node-a2t-deepgram.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2t-openai.js +4 -4
- package/speechflow-cli/dst/speechflow-node-a2t-openai.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2a-amazon.js +2 -2
- package/speechflow-cli/dst/speechflow-node-t2a-amazon.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2a-kokoro.js +2 -2
- package/speechflow-cli/dst/speechflow-node-t2a-kokoro.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-amazon.js +2 -2
- package/speechflow-cli/dst/speechflow-node-t2t-amazon.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-deepl.js +2 -2
- package/speechflow-cli/dst/speechflow-node-t2t-deepl.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-google.js +5 -5
- package/speechflow-cli/dst/speechflow-node-t2t-google.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-modify.js +2 -2
- package/speechflow-cli/dst/speechflow-node-t2t-modify.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-ollama.js +2 -2
- package/speechflow-cli/dst/speechflow-node-t2t-ollama.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-openai.js +2 -2
- package/speechflow-cli/dst/speechflow-node-t2t-openai.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-sentence.js +2 -2
- package/speechflow-cli/dst/speechflow-node-t2t-sentence.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-subtitle.js +2 -2
- package/speechflow-cli/dst/speechflow-node-t2t-subtitle.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-transformers.js +2 -2
- package/speechflow-cli/dst/speechflow-node-t2t-transformers.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-x2x-filter.js +2 -2
- package/speechflow-cli/dst/speechflow-node-x2x-filter.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-xio-device.js +5 -5
- package/speechflow-cli/dst/speechflow-node-xio-device.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-xio-file.js +27 -27
- package/speechflow-cli/dst/speechflow-node-xio-file.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-xio-mqtt.js +4 -4
- package/speechflow-cli/dst/speechflow-node-xio-mqtt.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-xio-websocket.js +7 -7
- package/speechflow-cli/dst/speechflow-node-xio-websocket.js.map +1 -1
- package/speechflow-cli/dst/{speechflow-utils-audio-wt.js → speechflow-util-audio-wt.js} +1 -1
- package/speechflow-cli/dst/speechflow-util-audio-wt.js.map +1 -0
- package/speechflow-cli/dst/speechflow-util-audio.d.ts +22 -0
- package/speechflow-cli/dst/speechflow-util-audio.js +251 -0
- package/speechflow-cli/dst/speechflow-util-audio.js.map +1 -0
- package/speechflow-cli/dst/speechflow-util-error.d.ts +14 -0
- package/speechflow-cli/dst/speechflow-util-error.js +131 -0
- package/speechflow-cli/dst/speechflow-util-error.js.map +1 -0
- package/speechflow-cli/dst/speechflow-util-queue.d.ts +68 -0
- package/speechflow-cli/dst/speechflow-util-queue.js +338 -0
- package/speechflow-cli/dst/speechflow-util-queue.js.map +1 -0
- package/speechflow-cli/dst/speechflow-util-stream.d.ts +18 -0
- package/speechflow-cli/dst/speechflow-util-stream.js +219 -0
- package/speechflow-cli/dst/speechflow-util-stream.js.map +1 -0
- package/speechflow-cli/dst/speechflow-util-webaudio-wt.js +124 -0
- package/speechflow-cli/dst/speechflow-util-webaudio-wt.js.map +1 -0
- package/speechflow-cli/dst/{speechflow-utils-audio.js → speechflow-util-webaudio.js} +2 -2
- package/speechflow-cli/dst/speechflow-util-webaudio.js.map +1 -0
- package/speechflow-cli/dst/speechflow-util.d.ts +4 -0
- package/speechflow-cli/dst/speechflow-util.js +26 -0
- package/speechflow-cli/dst/speechflow-util.js.map +1 -0
- package/speechflow-cli/dst/speechflow.js +3 -912
- package/speechflow-cli/dst/speechflow.js.map +1 -1
- package/speechflow-cli/etc/oxlint.jsonc +4 -1
- package/speechflow-cli/package.json +1 -0
- package/speechflow-cli/src/lib.d.ts +2 -0
- package/speechflow-cli/src/speechflow-main-api.ts +315 -0
- package/speechflow-cli/src/speechflow-main-cli.ts +259 -0
- package/speechflow-cli/src/speechflow-main-config.ts +17 -0
- package/speechflow-cli/src/speechflow-main-graph.ts +370 -0
- package/speechflow-cli/src/speechflow-main-nodes.ts +61 -0
- package/speechflow-cli/src/speechflow-main-status.ts +70 -0
- package/speechflow-cli/src/speechflow-main.ts +106 -0
- package/speechflow-cli/src/speechflow-node-a2a-compressor-wt.ts +4 -4
- package/speechflow-cli/src/speechflow-node-a2a-compressor.ts +5 -6
- package/speechflow-cli/src/speechflow-node-a2a-expander-wt.ts +5 -5
- package/speechflow-cli/src/speechflow-node-a2a-expander.ts +5 -6
- package/speechflow-cli/src/speechflow-node-a2a-ffmpeg.ts +5 -5
- package/speechflow-cli/src/speechflow-node-a2a-filler.ts +4 -4
- package/speechflow-cli/src/speechflow-node-a2a-gain.ts +2 -2
- package/speechflow-cli/src/speechflow-node-a2a-gender.ts +4 -4
- package/speechflow-cli/src/speechflow-node-a2a-meter.ts +2 -2
- package/speechflow-cli/src/speechflow-node-a2a-rnnoise.ts +4 -4
- package/speechflow-cli/src/speechflow-node-a2a-speex.ts +4 -4
- package/speechflow-cli/src/speechflow-node-a2a-vad.ts +4 -4
- package/speechflow-cli/src/speechflow-node-a2t-amazon.ts +7 -7
- package/speechflow-cli/src/speechflow-node-a2t-deepgram.ts +5 -5
- package/speechflow-cli/src/speechflow-node-a2t-openai.ts +5 -5
- package/speechflow-cli/src/speechflow-node-t2a-amazon.ts +2 -2
- package/speechflow-cli/src/speechflow-node-t2a-kokoro.ts +2 -2
- package/speechflow-cli/src/speechflow-node-t2t-amazon.ts +2 -2
- package/speechflow-cli/src/speechflow-node-t2t-deepl.ts +2 -2
- package/speechflow-cli/src/speechflow-node-t2t-google.ts +5 -5
- package/speechflow-cli/src/speechflow-node-t2t-modify.ts +2 -2
- package/speechflow-cli/src/speechflow-node-t2t-ollama.ts +2 -2
- package/speechflow-cli/src/speechflow-node-t2t-openai.ts +2 -2
- package/speechflow-cli/src/speechflow-node-t2t-sentence.ts +2 -2
- package/speechflow-cli/src/speechflow-node-t2t-subtitle.ts +2 -2
- package/speechflow-cli/src/speechflow-node-t2t-transformers.ts +2 -2
- package/speechflow-cli/src/speechflow-node-x2x-filter.ts +2 -2
- package/speechflow-cli/src/speechflow-node-xio-device.ts +5 -5
- package/speechflow-cli/src/speechflow-node-xio-file.ts +9 -10
- package/speechflow-cli/src/speechflow-node-xio-mqtt.ts +5 -5
- package/speechflow-cli/src/speechflow-node-xio-websocket.ts +7 -7
- package/speechflow-cli/src/{speechflow-utils-audio.ts → speechflow-util-audio.ts} +131 -1
- package/speechflow-cli/src/speechflow-util-error.ts +184 -0
- package/speechflow-cli/src/speechflow-util-queue.ts +320 -0
- package/speechflow-cli/src/speechflow-util-stream.ts +197 -0
- package/speechflow-cli/src/speechflow-util.ts +10 -0
- package/speechflow-cli/src/speechflow.ts +3 -953
- package/speechflow-ui-db/dst/index.js +1 -1
- package/speechflow-ui-db/etc/vite-client.mts +0 -2
- package/speechflow-ui-db/src/app.vue +20 -19
- package/speechflow-ui-st/dst/index.js +1 -1
- package/speechflow-ui-st/etc/vite-client.mts +0 -2
- package/speechflow-ui-st/src/app.vue +10 -6
- package/speechflow-cli/dst/speechflow-node-a2a-dynamics-wt.js +0 -208
- package/speechflow-cli/dst/speechflow-node-a2a-dynamics-wt.js.map +0 -1
- package/speechflow-cli/dst/speechflow-node-a2a-dynamics.d.ts +0 -15
- package/speechflow-cli/dst/speechflow-node-a2a-dynamics.js +0 -312
- package/speechflow-cli/dst/speechflow-node-a2a-dynamics.js.map +0 -1
- package/speechflow-cli/dst/speechflow-node-a2t-awstranscribe.d.ts +0 -18
- package/speechflow-cli/dst/speechflow-node-a2t-awstranscribe.js +0 -312
- package/speechflow-cli/dst/speechflow-node-a2t-awstranscribe.js.map +0 -1
- package/speechflow-cli/dst/speechflow-node-a2t-openaitranscribe.d.ts +0 -19
- package/speechflow-cli/dst/speechflow-node-a2t-openaitranscribe.js +0 -351
- package/speechflow-cli/dst/speechflow-node-a2t-openaitranscribe.js.map +0 -1
- package/speechflow-cli/dst/speechflow-node-t2a-awspolly.d.ts +0 -16
- package/speechflow-cli/dst/speechflow-node-t2a-awspolly.js +0 -204
- package/speechflow-cli/dst/speechflow-node-t2a-awspolly.js.map +0 -1
- package/speechflow-cli/dst/speechflow-node-t2t-awstranslate.d.ts +0 -13
- package/speechflow-cli/dst/speechflow-node-t2t-awstranslate.js +0 -175
- package/speechflow-cli/dst/speechflow-node-t2t-awstranslate.js.map +0 -1
- package/speechflow-cli/dst/speechflow-utils-audio-wt.js.map +0 -1
- package/speechflow-cli/dst/speechflow-utils-audio.js.map +0 -1
- package/speechflow-cli/dst/speechflow-utils.d.ts +0 -108
- package/speechflow-cli/dst/speechflow-utils.js +0 -746
- package/speechflow-cli/dst/speechflow-utils.js.map +0 -1
- package/speechflow-cli/src/speechflow-utils.ts +0 -810
- /package/speechflow-cli/dst/{speechflow-node-a2a-dynamics-wt.d.ts → speechflow-util-audio-wt.d.ts} +0 -0
- /package/speechflow-cli/dst/{speechflow-utils-audio-wt.d.ts → speechflow-util-webaudio-wt.d.ts} +0 -0
- /package/speechflow-cli/dst/{speechflow-utils-audio.d.ts → speechflow-util-webaudio.d.ts} +0 -0
- /package/speechflow-cli/src/{speechflow-utils-audio-wt.ts → speechflow-util-audio-wt.ts} +0 -0
|
@@ -19,7 +19,7 @@ import { DateTime, Duration } from "luxon"
|
|
|
19
19
|
|
|
20
20
|
/* internal dependencies */
|
|
21
21
|
import SpeechFlowNode, { SpeechFlowChunk } from "./speechflow-node"
|
|
22
|
-
import * as
|
|
22
|
+
import * as util from "./speechflow-util"
|
|
23
23
|
|
|
24
24
|
/* helper class for an asynchronous queue */
|
|
25
25
|
class AsyncQueue<T> {
|
|
@@ -73,7 +73,7 @@ export default class SpeechFlowNodeA2TAmazon extends SpeechFlowNode {
|
|
|
73
73
|
private destroyed = false
|
|
74
74
|
private initTimeout: ReturnType<typeof setTimeout> | null = null
|
|
75
75
|
private connectionTimeout: ReturnType<typeof setTimeout> | null = null
|
|
76
|
-
private queue:
|
|
76
|
+
private queue: util.SingleQueue<SpeechFlowChunk | null> | null = null
|
|
77
77
|
|
|
78
78
|
/* construct node */
|
|
79
79
|
constructor (id: string, cfg: { [ id: string ]: any }, opts: { [ id: string ]: any }, args: any[]) {
|
|
@@ -114,10 +114,10 @@ export default class SpeechFlowNodeA2TAmazon extends SpeechFlowNode {
|
|
|
114
114
|
this.destroyed = false
|
|
115
115
|
|
|
116
116
|
/* create queue for results */
|
|
117
|
-
this.queue = new
|
|
117
|
+
this.queue = new util.SingleQueue<SpeechFlowChunk | null>()
|
|
118
118
|
|
|
119
119
|
/* create a store for the meta information */
|
|
120
|
-
const metastore = new
|
|
120
|
+
const metastore = new util.TimeStore<Map<string, any>>()
|
|
121
121
|
|
|
122
122
|
/* connect to Amazon Transcribe API */
|
|
123
123
|
this.client = new TranscribeStreamingClient({
|
|
@@ -225,7 +225,7 @@ export default class SpeechFlowNodeA2TAmazon extends SpeechFlowNode {
|
|
|
225
225
|
metastore.store(chunk.timestampStart, chunk.timestampEnd, chunk.meta)
|
|
226
226
|
audioQueue.push(new Uint8Array(chunk.payload)) /* intentionally discard all time information */
|
|
227
227
|
ensureAudioStreamActive().catch((error: unknown) => {
|
|
228
|
-
self.log("error", `failed to start audio stream: ${
|
|
228
|
+
self.log("error", `failed to start audio stream: ${util.ensureError(error).message}`)
|
|
229
229
|
})
|
|
230
230
|
}
|
|
231
231
|
callback()
|
|
@@ -251,7 +251,7 @@ export default class SpeechFlowNodeA2TAmazon extends SpeechFlowNode {
|
|
|
251
251
|
}
|
|
252
252
|
}).catch((error: unknown) => {
|
|
253
253
|
if (!self.destroyed)
|
|
254
|
-
self.log("error", `queue read error: ${
|
|
254
|
+
self.log("error", `queue read error: ${util.ensureError(error).message}`)
|
|
255
255
|
})
|
|
256
256
|
},
|
|
257
257
|
final (callback) {
|
|
@@ -259,7 +259,7 @@ export default class SpeechFlowNodeA2TAmazon extends SpeechFlowNode {
|
|
|
259
259
|
callback()
|
|
260
260
|
return
|
|
261
261
|
}
|
|
262
|
-
|
|
262
|
+
util.run(
|
|
263
263
|
() => self.client!.destroy(),
|
|
264
264
|
(error: Error) => self.log("warning", `error closing Amazon Transcribe connection: ${error}`)
|
|
265
265
|
)
|
|
@@ -13,7 +13,7 @@ import { DateTime, Duration } from "luxon"
|
|
|
13
13
|
|
|
14
14
|
/* internal dependencies */
|
|
15
15
|
import SpeechFlowNode, { SpeechFlowChunk } from "./speechflow-node"
|
|
16
|
-
import * as
|
|
16
|
+
import * as util from "./speechflow-util"
|
|
17
17
|
|
|
18
18
|
/* SpeechFlow node for Deepgram speech-to-text conversion */
|
|
19
19
|
export default class SpeechFlowNodeA2TDeepgram extends SpeechFlowNode {
|
|
@@ -25,7 +25,7 @@ export default class SpeechFlowNodeA2TDeepgram extends SpeechFlowNode {
|
|
|
25
25
|
private destroyed = false
|
|
26
26
|
private initTimeout: ReturnType<typeof setTimeout> | null = null
|
|
27
27
|
private connectionTimeout: ReturnType<typeof setTimeout> | null = null
|
|
28
|
-
private queue:
|
|
28
|
+
private queue: util.SingleQueue<SpeechFlowChunk | null> | null = null
|
|
29
29
|
|
|
30
30
|
/* construct node */
|
|
31
31
|
constructor (id: string, cfg: { [ id: string ]: any }, opts: { [ id: string ]: any }, args: any[]) {
|
|
@@ -78,10 +78,10 @@ export default class SpeechFlowNodeA2TDeepgram extends SpeechFlowNode {
|
|
|
78
78
|
this.destroyed = false
|
|
79
79
|
|
|
80
80
|
/* create queue for results */
|
|
81
|
-
this.queue = new
|
|
81
|
+
this.queue = new util.SingleQueue<SpeechFlowChunk | null>()
|
|
82
82
|
|
|
83
83
|
/* create a store for the meta information */
|
|
84
|
-
const metastore = new
|
|
84
|
+
const metastore = new util.TimeStore<Map<string, any>>()
|
|
85
85
|
|
|
86
86
|
/* connect to Deepgram API */
|
|
87
87
|
const deepgram = Deepgram.createClient(this.params.key)
|
|
@@ -234,7 +234,7 @@ export default class SpeechFlowNodeA2TDeepgram extends SpeechFlowNode {
|
|
|
234
234
|
}
|
|
235
235
|
}).catch((error: unknown) => {
|
|
236
236
|
if (!self.destroyed)
|
|
237
|
-
self.log("error", `queue read error: ${
|
|
237
|
+
self.log("error", `queue read error: ${util.ensureError(error).message}`)
|
|
238
238
|
})
|
|
239
239
|
},
|
|
240
240
|
final (callback) {
|
|
@@ -15,7 +15,7 @@ import ws from "ws"
|
|
|
15
15
|
|
|
16
16
|
/* internal dependencies */
|
|
17
17
|
import SpeechFlowNode, { SpeechFlowChunk } from "./speechflow-node"
|
|
18
|
-
import * as
|
|
18
|
+
import * as util from "./speechflow-util"
|
|
19
19
|
|
|
20
20
|
/* SpeechFlow node for OpenAI speech-to-text conversion */
|
|
21
21
|
export default class SpeechFlowNodeA2TOpenAI extends SpeechFlowNode {
|
|
@@ -26,7 +26,7 @@ export default class SpeechFlowNodeA2TOpenAI extends SpeechFlowNode {
|
|
|
26
26
|
private static speexInitialized = false
|
|
27
27
|
private openai: OpenAI | null = null
|
|
28
28
|
private ws: ws.WebSocket | null = null
|
|
29
|
-
private queue:
|
|
29
|
+
private queue: util.SingleQueue<SpeechFlowChunk | null> | null = null
|
|
30
30
|
private resampler: SpeexResampler | null = null
|
|
31
31
|
private destroyed = false
|
|
32
32
|
private connectionTimeout: ReturnType<typeof setTimeout> | null = null
|
|
@@ -64,10 +64,10 @@ export default class SpeechFlowNodeA2TOpenAI extends SpeechFlowNode {
|
|
|
64
64
|
this.destroyed = false
|
|
65
65
|
|
|
66
66
|
/* create queue for results */
|
|
67
|
-
this.queue = new
|
|
67
|
+
this.queue = new util.SingleQueue<SpeechFlowChunk | null>()
|
|
68
68
|
|
|
69
69
|
/* create a store for the meta information */
|
|
70
|
-
const metastore = new
|
|
70
|
+
const metastore = new util.TimeStore<Map<string, any>>()
|
|
71
71
|
|
|
72
72
|
/* establish resampler from our standard audio sample rate (48Khz)
|
|
73
73
|
to OpenAI's maximum 24Khz input sample rate */
|
|
@@ -281,7 +281,7 @@ export default class SpeechFlowNodeA2TOpenAI extends SpeechFlowNode {
|
|
|
281
281
|
}
|
|
282
282
|
}).catch((error: unknown) => {
|
|
283
283
|
if (!self.destroyed)
|
|
284
|
-
self.log("error", `queue read error: ${
|
|
284
|
+
self.log("error", `queue read error: ${util.ensureError(error).message}`)
|
|
285
285
|
})
|
|
286
286
|
},
|
|
287
287
|
final (callback) {
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
|
|
18
18
|
/* internal dependencies */
|
|
19
19
|
import SpeechFlowNode, { SpeechFlowChunk } from "./speechflow-node"
|
|
20
|
-
import * as
|
|
20
|
+
import * as util from "./speechflow-util"
|
|
21
21
|
|
|
22
22
|
/* SpeechFlow node for Amazon Polly text-to-speech conversion */
|
|
23
23
|
export default class SpeechFlowNodeT2AAmazon extends SpeechFlowNode {
|
|
@@ -146,7 +146,7 @@ export default class SpeechFlowNodeT2AAmazon extends SpeechFlowNode {
|
|
|
146
146
|
this.push(chunkNew)
|
|
147
147
|
callback()
|
|
148
148
|
}).catch((error: unknown) => {
|
|
149
|
-
callback(
|
|
149
|
+
callback(util.ensureError(error, "failed to send to AWS Polly"))
|
|
150
150
|
})
|
|
151
151
|
}
|
|
152
152
|
else
|
|
@@ -13,7 +13,7 @@ import SpeexResampler from "speex-resampler"
|
|
|
13
13
|
|
|
14
14
|
/* internal dependencies */
|
|
15
15
|
import SpeechFlowNode, { SpeechFlowChunk } from "./speechflow-node"
|
|
16
|
-
import * as
|
|
16
|
+
import * as util from "./speechflow-util"
|
|
17
17
|
|
|
18
18
|
/* SpeechFlow node for Kokoro text-to-speech conversion */
|
|
19
19
|
export default class SpeechFlowNodeT2AKokoro extends SpeechFlowNode {
|
|
@@ -143,7 +143,7 @@ export default class SpeechFlowNodeT2AKokoro extends SpeechFlowNode {
|
|
|
143
143
|
this.push(chunk)
|
|
144
144
|
callback()
|
|
145
145
|
}).catch((error: unknown) => {
|
|
146
|
-
callback(
|
|
146
|
+
callback(util.ensureError(error))
|
|
147
147
|
})
|
|
148
148
|
}
|
|
149
149
|
},
|
|
@@ -12,7 +12,7 @@ import { TranslateClient, TranslateTextCommand } from "@aws-sdk/client-translate
|
|
|
12
12
|
|
|
13
13
|
/* internal dependencies */
|
|
14
14
|
import SpeechFlowNode, { SpeechFlowChunk } from "./speechflow-node"
|
|
15
|
-
import * as
|
|
15
|
+
import * as util from "./speechflow-util"
|
|
16
16
|
|
|
17
17
|
/* SpeechFlow node for Amazon Translate text-to-text translations */
|
|
18
18
|
export default class SpeechFlowNodeT2TAmazon extends SpeechFlowNode {
|
|
@@ -124,7 +124,7 @@ export default class SpeechFlowNodeT2TAmazon extends SpeechFlowNode {
|
|
|
124
124
|
this.push(chunkNew)
|
|
125
125
|
callback()
|
|
126
126
|
}).catch((error: unknown) => {
|
|
127
|
-
callback(
|
|
127
|
+
callback(util.ensureError(error))
|
|
128
128
|
})
|
|
129
129
|
}
|
|
130
130
|
},
|
|
@@ -12,7 +12,7 @@ import * as DeepL from "deepl-node"
|
|
|
12
12
|
|
|
13
13
|
/* internal dependencies */
|
|
14
14
|
import SpeechFlowNode, { SpeechFlowChunk } from "./speechflow-node"
|
|
15
|
-
import * as
|
|
15
|
+
import * as util from "./speechflow-util"
|
|
16
16
|
|
|
17
17
|
/* SpeechFlow node for DeepL text-to-text translations */
|
|
18
18
|
export default class SpeechFlowNodeT2TDeepL extends SpeechFlowNode {
|
|
@@ -95,7 +95,7 @@ export default class SpeechFlowNodeT2TDeepL extends SpeechFlowNode {
|
|
|
95
95
|
this.push(chunkNew)
|
|
96
96
|
callback()
|
|
97
97
|
}).catch((error: unknown) => {
|
|
98
|
-
callback(
|
|
98
|
+
callback(util.ensureError(error))
|
|
99
99
|
})
|
|
100
100
|
}
|
|
101
101
|
},
|
|
@@ -13,7 +13,7 @@ import * as arktype from "arktype"
|
|
|
13
13
|
|
|
14
14
|
/* internal dependencies */
|
|
15
15
|
import SpeechFlowNode, { SpeechFlowChunk } from "./speechflow-node"
|
|
16
|
-
import * as
|
|
16
|
+
import * as util from "./speechflow-util"
|
|
17
17
|
|
|
18
18
|
/* SpeechFlow node for Google Translate text-to-text translations */
|
|
19
19
|
export default class SpeechFlowNodeT2TGoogle extends SpeechFlowNode {
|
|
@@ -55,9 +55,9 @@ export default class SpeechFlowNodeT2TGoogle extends SpeechFlowNode {
|
|
|
55
55
|
/* open node */
|
|
56
56
|
async open () {
|
|
57
57
|
/* instantiate Google Translate client */
|
|
58
|
-
const data =
|
|
58
|
+
const data = util.run("Google Cloud API credentials key", () =>
|
|
59
59
|
JSON.parse(this.params.key))
|
|
60
|
-
const credentials =
|
|
60
|
+
const credentials = util.importObject("Google Cloud API credentials key",
|
|
61
61
|
data,
|
|
62
62
|
arktype.type({
|
|
63
63
|
project_id: "string",
|
|
@@ -74,7 +74,7 @@ export default class SpeechFlowNodeT2TGoogle extends SpeechFlowNode {
|
|
|
74
74
|
})
|
|
75
75
|
|
|
76
76
|
/* provide text-to-text translation */
|
|
77
|
-
const translate =
|
|
77
|
+
const translate = util.runner("Google Translate API", async (text: string) => {
|
|
78
78
|
const [ response ] = await this.client!.translateText({
|
|
79
79
|
parent: `projects/${credentials.project_id}/locations/global`,
|
|
80
80
|
contents: [ text ],
|
|
@@ -105,7 +105,7 @@ export default class SpeechFlowNodeT2TGoogle extends SpeechFlowNode {
|
|
|
105
105
|
this.push(chunkNew)
|
|
106
106
|
callback()
|
|
107
107
|
}).catch((error: unknown) => {
|
|
108
|
-
callback(
|
|
108
|
+
callback(util.ensureError(error))
|
|
109
109
|
})
|
|
110
110
|
}
|
|
111
111
|
},
|
|
@@ -9,7 +9,7 @@ import Stream from "node:stream"
|
|
|
9
9
|
|
|
10
10
|
/* internal dependencies */
|
|
11
11
|
import SpeechFlowNode, { SpeechFlowChunk } from "./speechflow-node"
|
|
12
|
-
import * as
|
|
12
|
+
import * as util from "./speechflow-util"
|
|
13
13
|
|
|
14
14
|
/* SpeechFlow node for text-to-text modification via regex */
|
|
15
15
|
export default class SpeechFlowNodeT2TModify extends SpeechFlowNode {
|
|
@@ -38,7 +38,7 @@ export default class SpeechFlowNodeT2TModify extends SpeechFlowNode {
|
|
|
38
38
|
throw new Error("match parameter cannot be empty")
|
|
39
39
|
|
|
40
40
|
/* compile regex pattern */
|
|
41
|
-
const regex =
|
|
41
|
+
const regex = util.run("compiling regex pattern",
|
|
42
42
|
() => new RegExp(this.params.match, "g"))
|
|
43
43
|
|
|
44
44
|
/* apply regex-based modification */
|
|
@@ -12,7 +12,7 @@ import { Ollama, type ListResponse } from "ollama"
|
|
|
12
12
|
|
|
13
13
|
/* internal dependencies */
|
|
14
14
|
import SpeechFlowNode, { SpeechFlowChunk } from "./speechflow-node"
|
|
15
|
-
import * as
|
|
15
|
+
import * as util from "./speechflow-util"
|
|
16
16
|
|
|
17
17
|
/* internal utility types */
|
|
18
18
|
type ConfigEntry = { systemPrompt: string, chat: Array<{ role: string, content: string }> }
|
|
@@ -252,7 +252,7 @@ export default class SpeechFlowNodeT2TOllama extends SpeechFlowNode {
|
|
|
252
252
|
this.push(chunkNew)
|
|
253
253
|
callback()
|
|
254
254
|
}).catch((error: unknown) => {
|
|
255
|
-
callback(
|
|
255
|
+
callback(util.ensureError(error))
|
|
256
256
|
})
|
|
257
257
|
}
|
|
258
258
|
}
|
|
@@ -12,7 +12,7 @@ import OpenAI from "openai"
|
|
|
12
12
|
|
|
13
13
|
/* internal dependencies */
|
|
14
14
|
import SpeechFlowNode, { SpeechFlowChunk } from "./speechflow-node"
|
|
15
|
-
import * as
|
|
15
|
+
import * as util from "./speechflow-util"
|
|
16
16
|
|
|
17
17
|
/* internal utility types */
|
|
18
18
|
type ConfigEntry = { systemPrompt: string, chat: OpenAI.ChatCompletionMessageParam[] }
|
|
@@ -221,7 +221,7 @@ export default class SpeechFlowNodeT2TOpenAI extends SpeechFlowNode {
|
|
|
221
221
|
this.push(chunkNew)
|
|
222
222
|
callback()
|
|
223
223
|
}).catch((error: unknown) => {
|
|
224
|
-
callback(
|
|
224
|
+
callback(util.ensureError(error))
|
|
225
225
|
})
|
|
226
226
|
}
|
|
227
227
|
},
|
|
@@ -12,7 +12,7 @@ import { Duration } from "luxon"
|
|
|
12
12
|
|
|
13
13
|
/* internal dependencies */
|
|
14
14
|
import SpeechFlowNode, { SpeechFlowChunk } from "./speechflow-node"
|
|
15
|
-
import * as
|
|
15
|
+
import * as util from "./speechflow-util"
|
|
16
16
|
|
|
17
17
|
/* text stream queue element */
|
|
18
18
|
type TextQueueElement = {
|
|
@@ -29,7 +29,7 @@ export default class SpeechFlowNodeT2TSentence extends SpeechFlowNode {
|
|
|
29
29
|
public static name = "t2t-sentence"
|
|
30
30
|
|
|
31
31
|
/* internal state */
|
|
32
|
-
private queue = new
|
|
32
|
+
private queue = new util.Queue<TextQueueElement>()
|
|
33
33
|
private queueRecv = this.queue.pointerUse("recv")
|
|
34
34
|
private queueSplit = this.queue.pointerUse("split")
|
|
35
35
|
private queueSend = this.queue.pointerUse("send")
|
|
@@ -18,7 +18,7 @@ import HAPIWebSocket from "hapi-plugin-websocket"
|
|
|
18
18
|
|
|
19
19
|
/* internal dependencies */
|
|
20
20
|
import SpeechFlowNode, { SpeechFlowChunk } from "./speechflow-node"
|
|
21
|
-
import * as
|
|
21
|
+
import * as util from "./speechflow-util"
|
|
22
22
|
|
|
23
23
|
type wsPeerCtx = {
|
|
24
24
|
peer: string
|
|
@@ -147,7 +147,7 @@ export default class SpeechFlowNodeT2TSubtitle extends SpeechFlowNode {
|
|
|
147
147
|
this.push(chunkNew)
|
|
148
148
|
callback()
|
|
149
149
|
}).catch((error: unknown) => {
|
|
150
|
-
callback(
|
|
150
|
+
callback(util.ensureError(error))
|
|
151
151
|
})
|
|
152
152
|
}
|
|
153
153
|
}
|
|
@@ -13,7 +13,7 @@ import * as Transformers from "@huggingface/transformers"
|
|
|
13
13
|
|
|
14
14
|
/* internal dependencies */
|
|
15
15
|
import SpeechFlowNode, { SpeechFlowChunk } from "./speechflow-node"
|
|
16
|
-
import * as
|
|
16
|
+
import * as util from "./speechflow-util"
|
|
17
17
|
|
|
18
18
|
/* internal utility types */
|
|
19
19
|
type ConfigEntry = { systemPrompt: string, chat: Array<{ role: string, content: string }> }
|
|
@@ -214,7 +214,7 @@ export default class SpeechFlowNodeT2TTransformers extends SpeechFlowNode {
|
|
|
214
214
|
this.push(chunk)
|
|
215
215
|
callback()
|
|
216
216
|
}).catch((error: unknown) => {
|
|
217
|
-
callback(
|
|
217
|
+
callback(util.ensureError(error))
|
|
218
218
|
})
|
|
219
219
|
}
|
|
220
220
|
},
|
|
@@ -9,7 +9,7 @@ import Stream from "node:stream"
|
|
|
9
9
|
|
|
10
10
|
/* internal dependencies */
|
|
11
11
|
import SpeechFlowNode, { SpeechFlowChunk } from "./speechflow-node"
|
|
12
|
-
import * as
|
|
12
|
+
import * as util from "./speechflow-util"
|
|
13
13
|
|
|
14
14
|
/* SpeechFlow node for data flow filtering (based on meta information) */
|
|
15
15
|
export default class SpeechFlowNodeX2XFilter extends SpeechFlowNode {
|
|
@@ -17,7 +17,7 @@ export default class SpeechFlowNodeX2XFilter extends SpeechFlowNode {
|
|
|
17
17
|
public static name = "x2x-filter"
|
|
18
18
|
|
|
19
19
|
/* cached regular expression instance */
|
|
20
|
-
private cachedRegExp = new
|
|
20
|
+
private cachedRegExp = new util.CachedRegExp()
|
|
21
21
|
|
|
22
22
|
/* construct node */
|
|
23
23
|
constructor (id: string, cfg: { [ id: string ]: any }, opts: { [ id: string ]: any }, args: any[]) {
|
|
@@ -12,7 +12,7 @@ import PortAudio from "@gpeng/naudiodon"
|
|
|
12
12
|
|
|
13
13
|
/* internal dependencies */
|
|
14
14
|
import SpeechFlowNode from "./speechflow-node"
|
|
15
|
-
import * as
|
|
15
|
+
import * as util from "./speechflow-util"
|
|
16
16
|
|
|
17
17
|
/* SpeechFlow node for device access */
|
|
18
18
|
export default class SpeechFlowNodeXIODevice extends SpeechFlowNode {
|
|
@@ -135,8 +135,8 @@ export default class SpeechFlowNodeXIODevice extends SpeechFlowNode {
|
|
|
135
135
|
this.stream = this.io as unknown as Stream.Duplex
|
|
136
136
|
|
|
137
137
|
/* convert regular stream into object-mode stream */
|
|
138
|
-
const wrapper1 =
|
|
139
|
-
const wrapper2 =
|
|
138
|
+
const wrapper1 = util.createTransformStreamForWritableSide()
|
|
139
|
+
const wrapper2 = util.createTransformStreamForReadableSide("audio", () => this.timeZero)
|
|
140
140
|
this.stream = Stream.compose(wrapper1, this.stream, wrapper2)
|
|
141
141
|
}
|
|
142
142
|
else if (this.params.mode === "r") {
|
|
@@ -156,7 +156,7 @@ export default class SpeechFlowNodeXIODevice extends SpeechFlowNode {
|
|
|
156
156
|
this.stream = this.io as unknown as Stream.Readable
|
|
157
157
|
|
|
158
158
|
/* convert regular stream into object-mode stream */
|
|
159
|
-
const wrapper =
|
|
159
|
+
const wrapper = util.createTransformStreamForReadableSide("audio", () => this.timeZero)
|
|
160
160
|
this.stream = Stream.compose(this.stream, wrapper)
|
|
161
161
|
}
|
|
162
162
|
else if (this.params.mode === "w") {
|
|
@@ -176,7 +176,7 @@ export default class SpeechFlowNodeXIODevice extends SpeechFlowNode {
|
|
|
176
176
|
this.stream = this.io as unknown as Stream.Writable
|
|
177
177
|
|
|
178
178
|
/* convert regular stream into object-mode stream */
|
|
179
|
-
const wrapper =
|
|
179
|
+
const wrapper = util.createTransformStreamForWritableSide()
|
|
180
180
|
this.stream = Stream.compose(wrapper, this.stream)
|
|
181
181
|
}
|
|
182
182
|
else
|
|
@@ -10,7 +10,7 @@ import Stream from "node:stream"
|
|
|
10
10
|
|
|
11
11
|
/* internal dependencies */
|
|
12
12
|
import SpeechFlowNode from "./speechflow-node"
|
|
13
|
-
import * as
|
|
13
|
+
import * as util from "./speechflow-util"
|
|
14
14
|
|
|
15
15
|
/* SpeechFlow node for file access */
|
|
16
16
|
export default class SpeechFlowNodeXIOFile extends SpeechFlowNode {
|
|
@@ -64,8 +64,8 @@ export default class SpeechFlowNodeXIOFile extends SpeechFlowNode {
|
|
|
64
64
|
This ensures the writable side of the composed stream below
|
|
65
65
|
properly signals completion while keeping process.stdout open
|
|
66
66
|
(as it's a global stream that shouldn't be closed by individual nodes). */
|
|
67
|
-
const createStdoutChunker = () =>
|
|
68
|
-
|
|
67
|
+
const createStdoutChunker = () =>
|
|
68
|
+
new Stream.Writable({
|
|
69
69
|
highWaterMark: this.params.type === "audio" ?
|
|
70
70
|
highWaterMarkAudio : highWaterMarkText,
|
|
71
71
|
write (chunk: Buffer | string, encoding, callback) {
|
|
@@ -79,7 +79,6 @@ export default class SpeechFlowNodeXIOFile extends SpeechFlowNode {
|
|
|
79
79
|
callback()
|
|
80
80
|
}
|
|
81
81
|
})
|
|
82
|
-
}
|
|
83
82
|
|
|
84
83
|
/* dispatch according to mode and path */
|
|
85
84
|
if (this.params.mode === "rw") {
|
|
@@ -129,8 +128,8 @@ export default class SpeechFlowNodeXIOFile extends SpeechFlowNode {
|
|
|
129
128
|
}
|
|
130
129
|
|
|
131
130
|
/* convert regular stream into object-mode stream */
|
|
132
|
-
const wrapper1 =
|
|
133
|
-
const wrapper2 =
|
|
131
|
+
const wrapper1 = util.createTransformStreamForWritableSide()
|
|
132
|
+
const wrapper2 = util.createTransformStreamForReadableSide(
|
|
134
133
|
this.params.type, () => this.timeZero)
|
|
135
134
|
this.stream = Stream.compose(wrapper1, this.stream, wrapper2)
|
|
136
135
|
}
|
|
@@ -146,7 +145,7 @@ export default class SpeechFlowNodeXIOFile extends SpeechFlowNode {
|
|
|
146
145
|
process.stdin.setEncoding(this.config.textEncoding)
|
|
147
146
|
chunker = new Stream.PassThrough({ highWaterMark: highWaterMarkText })
|
|
148
147
|
}
|
|
149
|
-
const wrapper =
|
|
148
|
+
const wrapper = util.createTransformStreamForReadableSide(
|
|
150
149
|
this.params.type, () => this.timeZero)
|
|
151
150
|
this.stream = Stream.compose(process.stdin, chunker, wrapper)
|
|
152
151
|
}
|
|
@@ -159,7 +158,7 @@ export default class SpeechFlowNodeXIOFile extends SpeechFlowNode {
|
|
|
159
158
|
else
|
|
160
159
|
readable = fs.createReadStream(this.params.path,
|
|
161
160
|
{ highWaterMark: highWaterMarkText, encoding: this.config.textEncoding })
|
|
162
|
-
const wrapper =
|
|
161
|
+
const wrapper = util.createTransformStreamForReadableSide(
|
|
163
162
|
this.params.type, () => this.timeZero)
|
|
164
163
|
this.stream = Stream.compose(readable, wrapper)
|
|
165
164
|
}
|
|
@@ -172,7 +171,7 @@ export default class SpeechFlowNodeXIOFile extends SpeechFlowNode {
|
|
|
172
171
|
else
|
|
173
172
|
process.stdout.setEncoding(this.config.textEncoding)
|
|
174
173
|
const chunker = createStdoutChunker()
|
|
175
|
-
const wrapper =
|
|
174
|
+
const wrapper = util.createTransformStreamForWritableSide()
|
|
176
175
|
this.stream = Stream.compose(wrapper, chunker)
|
|
177
176
|
}
|
|
178
177
|
else {
|
|
@@ -184,7 +183,7 @@ export default class SpeechFlowNodeXIOFile extends SpeechFlowNode {
|
|
|
184
183
|
else
|
|
185
184
|
writable = fs.createWriteStream(this.params.path,
|
|
186
185
|
{ highWaterMark: highWaterMarkText, encoding: this.config.textEncoding })
|
|
187
|
-
const wrapper =
|
|
186
|
+
const wrapper = util.createTransformStreamForWritableSide()
|
|
188
187
|
this.stream = Stream.compose(wrapper, writable)
|
|
189
188
|
}
|
|
190
189
|
}
|
|
@@ -13,7 +13,7 @@ import UUID from "pure-uuid"
|
|
|
13
13
|
|
|
14
14
|
/* internal dependencies */
|
|
15
15
|
import SpeechFlowNode, { SpeechFlowChunk } from "./speechflow-node"
|
|
16
|
-
import * as
|
|
16
|
+
import * as util from "./speechflow-util"
|
|
17
17
|
|
|
18
18
|
/* SpeechFlow node for MQTT networking */
|
|
19
19
|
export default class SpeechFlowNodeXIOMQTT extends SpeechFlowNode {
|
|
@@ -23,7 +23,7 @@ export default class SpeechFlowNodeXIOMQTT extends SpeechFlowNode {
|
|
|
23
23
|
/* internal state */
|
|
24
24
|
private broker: MQTT.MqttClient | null = null
|
|
25
25
|
private clientId: string = (new UUID(1)).format()
|
|
26
|
-
private chunkQueue:
|
|
26
|
+
private chunkQueue: util.SingleQueue<SpeechFlowChunk> | null = null
|
|
27
27
|
|
|
28
28
|
/* construct node */
|
|
29
29
|
constructor (id: string, cfg: { [ id: string ]: any }, opts: { [ id: string ]: any }, args: any[]) {
|
|
@@ -99,12 +99,12 @@ export default class SpeechFlowNodeXIOMQTT extends SpeechFlowNode {
|
|
|
99
99
|
this.broker.on("disconnect", (packet: MQTT.IDisconnectPacket) => {
|
|
100
100
|
this.log("info", `connection closed to MQTT ${this.params.url}`)
|
|
101
101
|
})
|
|
102
|
-
this.chunkQueue = new
|
|
102
|
+
this.chunkQueue = new util.SingleQueue<SpeechFlowChunk>()
|
|
103
103
|
this.broker.on("message", (topic: string, payload: Buffer, packet: MQTT.IPublishPacket) => {
|
|
104
104
|
if (topic !== this.params.topicRead || this.params.mode === "w")
|
|
105
105
|
return
|
|
106
106
|
try {
|
|
107
|
-
const chunk =
|
|
107
|
+
const chunk = util.streamChunkDecode(payload)
|
|
108
108
|
this.chunkQueue!.write(chunk)
|
|
109
109
|
}
|
|
110
110
|
catch (_err: any) {
|
|
@@ -125,7 +125,7 @@ export default class SpeechFlowNodeXIOMQTT extends SpeechFlowNode {
|
|
|
125
125
|
else if (!self.broker!.connected)
|
|
126
126
|
callback(new Error("still no MQTT connection available"))
|
|
127
127
|
else {
|
|
128
|
-
const data = Buffer.from(
|
|
128
|
+
const data = Buffer.from(util.streamChunkEncode(chunk))
|
|
129
129
|
self.broker!.publish(self.params.topicWrite, data, { qos: 2, retain: false }, (err) => {
|
|
130
130
|
if (err)
|
|
131
131
|
callback(new Error(`failed to publish to MQTT topic "${self.params.topicWrite}": ${err}`))
|
|
@@ -13,7 +13,7 @@ import ReconnWebSocket, { ErrorEvent } from "@opensumi/reconnecting-websocket"
|
|
|
13
13
|
|
|
14
14
|
/* internal dependencies */
|
|
15
15
|
import SpeechFlowNode, { SpeechFlowChunk } from "./speechflow-node"
|
|
16
|
-
import * as
|
|
16
|
+
import * as util from "./speechflow-util"
|
|
17
17
|
|
|
18
18
|
/* SpeechFlow node for Websocket networking */
|
|
19
19
|
export default class SpeechFlowNodeXIOWebSocket extends SpeechFlowNode {
|
|
@@ -63,7 +63,7 @@ export default class SpeechFlowNodeXIOWebSocket extends SpeechFlowNode {
|
|
|
63
63
|
/* listen locally on a Websocket port */
|
|
64
64
|
const url = new URL(this.params.listen)
|
|
65
65
|
const websockets = new Set<ws.WebSocket>()
|
|
66
|
-
const chunkQueue = new
|
|
66
|
+
const chunkQueue = new util.SingleQueue<SpeechFlowChunk>()
|
|
67
67
|
this.server = new ws.WebSocketServer({
|
|
68
68
|
host: url.hostname,
|
|
69
69
|
port: Number.parseInt(url.port, 10),
|
|
@@ -101,7 +101,7 @@ export default class SpeechFlowNodeXIOWebSocket extends SpeechFlowNode {
|
|
|
101
101
|
buffer = Buffer.from(data)
|
|
102
102
|
else
|
|
103
103
|
buffer = Buffer.concat(data)
|
|
104
|
-
const chunk =
|
|
104
|
+
const chunk = util.streamChunkDecode(buffer)
|
|
105
105
|
chunkQueue.write(chunk)
|
|
106
106
|
})
|
|
107
107
|
})
|
|
@@ -122,7 +122,7 @@ export default class SpeechFlowNodeXIOWebSocket extends SpeechFlowNode {
|
|
|
122
122
|
else if (websockets.size === 0)
|
|
123
123
|
callback(new Error("still no Websocket connections available"))
|
|
124
124
|
else {
|
|
125
|
-
const data =
|
|
125
|
+
const data = util.streamChunkEncode(chunk)
|
|
126
126
|
const results: Promise<void>[] = []
|
|
127
127
|
for (const websocket of websockets.values()) {
|
|
128
128
|
results.push(new Promise<void>((resolve, reject) => {
|
|
@@ -172,7 +172,7 @@ export default class SpeechFlowNodeXIOWebSocket extends SpeechFlowNode {
|
|
|
172
172
|
this.client.addEventListener("error", (ev: ErrorEvent) => {
|
|
173
173
|
this.log("error", `error of connection on URL ${this.params.connect}: ${ev.error.message}`)
|
|
174
174
|
})
|
|
175
|
-
const chunkQueue = new
|
|
175
|
+
const chunkQueue = new util.SingleQueue<SpeechFlowChunk>()
|
|
176
176
|
this.client.addEventListener("message", (ev: MessageEvent) => {
|
|
177
177
|
if (this.params.mode === "w") {
|
|
178
178
|
this.log("warning", `connection to URL ${this.params.connect}: ` +
|
|
@@ -185,7 +185,7 @@ export default class SpeechFlowNodeXIOWebSocket extends SpeechFlowNode {
|
|
|
185
185
|
return
|
|
186
186
|
}
|
|
187
187
|
const buffer = Buffer.from(ev.data)
|
|
188
|
-
const chunk =
|
|
188
|
+
const chunk = util.streamChunkDecode(buffer)
|
|
189
189
|
chunkQueue.write(chunk)
|
|
190
190
|
})
|
|
191
191
|
this.client.binaryType = "arraybuffer"
|
|
@@ -203,7 +203,7 @@ export default class SpeechFlowNodeXIOWebSocket extends SpeechFlowNode {
|
|
|
203
203
|
else if (!self.client!.OPEN)
|
|
204
204
|
callback(new Error("still no Websocket connection available"))
|
|
205
205
|
else {
|
|
206
|
-
const data =
|
|
206
|
+
const data = util.streamChunkEncode(chunk)
|
|
207
207
|
self.client!.send(data)
|
|
208
208
|
callback()
|
|
209
209
|
}
|