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
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/*
|
|
2
|
+
** SpeechFlow - Speech Processing Flow Graph
|
|
3
|
+
** Copyright (c) 2024-2025 Dr. Ralf S. Engelschall <rse@engelschall.com>
|
|
4
|
+
** Licensed under GPL 3.0 <https://spdx.org/licenses/GPL-3.0-only>
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/* standard dependencies */
|
|
8
|
+
import Stream from "node:stream"
|
|
9
|
+
|
|
10
|
+
/* external dependencies */
|
|
11
|
+
import { DateTime, Duration } from "luxon"
|
|
12
|
+
import * as CBOR from "cbor2"
|
|
13
|
+
|
|
14
|
+
/* internal dependencies */
|
|
15
|
+
import { SpeechFlowChunk } from "./speechflow-node"
|
|
16
|
+
import * as util from "./speechflow-util"
|
|
17
|
+
|
|
18
|
+
/* create a Duplex/Transform stream which has
|
|
19
|
+
object-mode on Writable side and buffer/string-mode on Readable side */
|
|
20
|
+
export function createTransformStreamForWritableSide () {
|
|
21
|
+
return new Stream.Transform({
|
|
22
|
+
readableObjectMode: true,
|
|
23
|
+
writableObjectMode: true,
|
|
24
|
+
decodeStrings: false,
|
|
25
|
+
highWaterMark: 1,
|
|
26
|
+
transform (chunk: SpeechFlowChunk, encoding, callback) {
|
|
27
|
+
this.push(chunk.payload)
|
|
28
|
+
callback()
|
|
29
|
+
},
|
|
30
|
+
final (callback) {
|
|
31
|
+
this.push(null)
|
|
32
|
+
callback()
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* create a Duplex/Transform stream which has
|
|
38
|
+
object-mode on Readable side and buffer/string-mode on Writable side */
|
|
39
|
+
export function createTransformStreamForReadableSide (type: "text" | "audio", getTimeZero: () => DateTime) {
|
|
40
|
+
return new Stream.Transform({
|
|
41
|
+
readableObjectMode: true,
|
|
42
|
+
writableObjectMode: true,
|
|
43
|
+
decodeStrings: false,
|
|
44
|
+
highWaterMark: (type === "audio" ? 19200 : 65536), /* audio: 400ms @ 48kHz/16bit/mono, text: 64KB */
|
|
45
|
+
transform (chunk: Buffer | string, encoding, callback) {
|
|
46
|
+
if (chunk === null) {
|
|
47
|
+
this.push(null)
|
|
48
|
+
callback()
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
const timeZero = getTimeZero()
|
|
52
|
+
const start = DateTime.now().diff(timeZero)
|
|
53
|
+
let end = start
|
|
54
|
+
if (type === "audio") {
|
|
55
|
+
const duration = util.audioBufferDuration(chunk as Buffer)
|
|
56
|
+
end = start.plus(duration * 1000)
|
|
57
|
+
}
|
|
58
|
+
const payload = ensureStreamChunk(type, chunk) as Buffer | string
|
|
59
|
+
const obj = new SpeechFlowChunk(start, end, "final", type, payload)
|
|
60
|
+
this.push(obj)
|
|
61
|
+
callback()
|
|
62
|
+
},
|
|
63
|
+
final (callback) {
|
|
64
|
+
this.push(null)
|
|
65
|
+
callback()
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* ensure a chunk is of a certain type and format */
|
|
71
|
+
export function ensureStreamChunk (type: "audio" | "text", chunk: SpeechFlowChunk | Buffer | string) {
|
|
72
|
+
if (chunk instanceof SpeechFlowChunk) {
|
|
73
|
+
if (chunk.type !== type)
|
|
74
|
+
throw new Error(`invalid payload chunk (expected ${type} type, received ${chunk.type} type)`)
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
if (type === "text" && Buffer.isBuffer(chunk))
|
|
78
|
+
chunk = chunk.toString("utf8")
|
|
79
|
+
else if (type === "audio" && !Buffer.isBuffer(chunk))
|
|
80
|
+
chunk = Buffer.from(chunk)
|
|
81
|
+
}
|
|
82
|
+
return chunk
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* type of a serialized SpeechFlow chunk */
|
|
86
|
+
type SpeechFlowChunkSerialized = {
|
|
87
|
+
timestampStart: number,
|
|
88
|
+
timestampEnd: number,
|
|
89
|
+
kind: string,
|
|
90
|
+
type: string,
|
|
91
|
+
payload: Uint8Array
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* encode/serialize chunk of data */
|
|
95
|
+
export function streamChunkEncode (chunk: SpeechFlowChunk) {
|
|
96
|
+
let payload: Uint8Array
|
|
97
|
+
if (Buffer.isBuffer(chunk.payload))
|
|
98
|
+
payload = new Uint8Array(chunk.payload)
|
|
99
|
+
else {
|
|
100
|
+
const encoder = new TextEncoder()
|
|
101
|
+
payload = encoder.encode(chunk.payload)
|
|
102
|
+
}
|
|
103
|
+
const data = {
|
|
104
|
+
timestampStart: chunk.timestampStart.toMillis(),
|
|
105
|
+
timestampEnd: chunk.timestampEnd.toMillis(),
|
|
106
|
+
kind: chunk.kind,
|
|
107
|
+
type: chunk.type,
|
|
108
|
+
payload
|
|
109
|
+
} satisfies SpeechFlowChunkSerialized
|
|
110
|
+
const _data = CBOR.encode(data)
|
|
111
|
+
return _data
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/* decode/unserialize chunk of data */
|
|
115
|
+
export function streamChunkDecode (_data: Uint8Array) {
|
|
116
|
+
let data: SpeechFlowChunkSerialized
|
|
117
|
+
try {
|
|
118
|
+
data = CBOR.decode<SpeechFlowChunkSerialized>(_data)
|
|
119
|
+
}
|
|
120
|
+
catch (err: unknown) {
|
|
121
|
+
throw util.ensureError(err, "CBOR decoding failed")
|
|
122
|
+
}
|
|
123
|
+
let payload: Buffer | string
|
|
124
|
+
if (data.type === "audio")
|
|
125
|
+
payload = Buffer.from(data.payload)
|
|
126
|
+
else
|
|
127
|
+
payload = (new TextDecoder()).decode(data.payload)
|
|
128
|
+
const chunk = new SpeechFlowChunk(
|
|
129
|
+
Duration.fromMillis(data.timestampStart),
|
|
130
|
+
Duration.fromMillis(data.timestampEnd),
|
|
131
|
+
data.kind as "intermediate" | "final",
|
|
132
|
+
data.type as "audio" | "text",
|
|
133
|
+
payload
|
|
134
|
+
)
|
|
135
|
+
return chunk
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/* utility class for wrapping a custom stream into a regular Transform stream */
|
|
139
|
+
export class StreamWrapper extends Stream.Transform {
|
|
140
|
+
private foreignStream: any
|
|
141
|
+
private onData = (chunk: any) => { this.push(chunk) }
|
|
142
|
+
private onError = (err: Error) => { this.emit("error", err) }
|
|
143
|
+
private onEnd = () => { this.push(null) }
|
|
144
|
+
constructor (foreignStream: any, options: Stream.TransformOptions = {}) {
|
|
145
|
+
options.readableObjectMode = true
|
|
146
|
+
options.writableObjectMode = true
|
|
147
|
+
super(options)
|
|
148
|
+
this.foreignStream = foreignStream
|
|
149
|
+
if (typeof this.foreignStream.on === "function") {
|
|
150
|
+
this.foreignStream.on("data", this.onData)
|
|
151
|
+
this.foreignStream.on("error", this.onError)
|
|
152
|
+
this.foreignStream.on("end", this.onEnd)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
_transform (chunk: any, encoding: BufferEncoding, callback: Stream.TransformCallback): void {
|
|
156
|
+
if (this.destroyed) {
|
|
157
|
+
callback(new Error("stream already destroyed"))
|
|
158
|
+
return
|
|
159
|
+
}
|
|
160
|
+
try {
|
|
161
|
+
if (typeof this.foreignStream.write === "function") {
|
|
162
|
+
const canContinue = this.foreignStream.write(chunk)
|
|
163
|
+
if (canContinue)
|
|
164
|
+
callback()
|
|
165
|
+
else
|
|
166
|
+
this.foreignStream.once("drain", callback)
|
|
167
|
+
}
|
|
168
|
+
else
|
|
169
|
+
throw new Error("foreign stream lacks write method")
|
|
170
|
+
}
|
|
171
|
+
catch (err: unknown) {
|
|
172
|
+
callback(util.ensureError(err))
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
_flush (callback: Stream.TransformCallback): void {
|
|
176
|
+
if (this.destroyed) {
|
|
177
|
+
callback(new Error("stream already destroyed"))
|
|
178
|
+
return
|
|
179
|
+
}
|
|
180
|
+
try {
|
|
181
|
+
if (typeof this.foreignStream.end === "function")
|
|
182
|
+
this.foreignStream.end()
|
|
183
|
+
callback()
|
|
184
|
+
}
|
|
185
|
+
catch (err: unknown) {
|
|
186
|
+
callback(util.ensureError(err))
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
_destroy (error: Error | null, callback: Stream.TransformCallback): void {
|
|
190
|
+
if (typeof this.foreignStream.removeListener === "function") {
|
|
191
|
+
this.foreignStream.removeListener("data", this.onData)
|
|
192
|
+
this.foreignStream.removeListener("error", this.onError)
|
|
193
|
+
this.foreignStream.removeListener("end", this.onEnd)
|
|
194
|
+
}
|
|
195
|
+
super._destroy(error, callback)
|
|
196
|
+
}
|
|
197
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
** SpeechFlow - Speech Processing Flow Graph
|
|
3
|
+
** Copyright (c) 2024-2025 Dr. Ralf S. Engelschall <rse@engelschall.com>
|
|
4
|
+
** Licensed under GPL 3.0 <https://spdx.org/licenses/GPL-3.0-only>
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export * from "./speechflow-util-audio"
|
|
8
|
+
export * from "./speechflow-util-error"
|
|
9
|
+
export * from "./speechflow-util-stream"
|
|
10
|
+
export * from "./speechflow-util-queue"
|