speechflow 0.9.8 → 1.0.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 +18 -0
- package/LICENSE.txt +674 -0
- package/README.md +114 -17
- package/dst/speechflow-node-a2a-ffmpeg.js +1 -0
- package/dst/speechflow-node-a2a-ffmpeg.js.map +1 -0
- package/dst/{speechflow-node-deepl.d.ts → speechflow-node-a2a-meter.d.ts} +2 -2
- package/dst/speechflow-node-a2a-meter.js +147 -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-whisper.d.ts → speechflow-node-a2a-vad.d.ts} +2 -5
- package/dst/speechflow-node-a2a-vad.js +272 -0
- 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.js +2 -1
- package/dst/speechflow-node-a2t-deepgram.js.map +1 -0
- package/dst/speechflow-node-t2a-elevenlabs.js +1 -0
- package/dst/speechflow-node-t2a-elevenlabs.js.map +1 -0
- package/dst/{speechflow-node-elevenlabs.d.ts → speechflow-node-t2a-kokoro.d.ts} +2 -2
- package/dst/speechflow-node-t2a-kokoro.js +148 -0
- package/dst/speechflow-node-t2a-kokoro.js.map +1 -0
- package/dst/speechflow-node-t2t-deepl.js +1 -0
- 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-gemma.d.ts → speechflow-node-t2t-ollama.d.ts} +1 -1
- package/dst/{speechflow-node-gemma.js → speechflow-node-t2t-ollama.js} +41 -8
- package/dst/speechflow-node-t2t-ollama.js.map +1 -0
- package/dst/{speechflow-node-t2t-gemma.d.ts → speechflow-node-t2t-openai.d.ts} +2 -2
- package/dst/{speechflow-node-t2t-gemma.js → speechflow-node-t2t-openai.js} +43 -30
- 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-opus.d.ts → speechflow-node-t2t-transformers.d.ts} +3 -1
- package/dst/speechflow-node-t2t-transformers.js +264 -0
- package/dst/speechflow-node-t2t-transformers.js.map +1 -0
- package/dst/speechflow-node-x2x-trace.js +3 -2
- package/dst/speechflow-node-x2x-trace.js.map +1 -0
- package/dst/speechflow-node-xio-device.js +1 -0
- package/dst/speechflow-node-xio-device.js.map +1 -0
- package/dst/speechflow-node-xio-file.js +1 -0
- package/dst/speechflow-node-xio-file.js.map +1 -0
- package/dst/speechflow-node-xio-mqtt.js +1 -0
- package/dst/speechflow-node-xio-mqtt.js.map +1 -0
- package/dst/speechflow-node-xio-websocket.js +1 -0
- package/dst/speechflow-node-xio-websocket.js.map +1 -0
- package/dst/speechflow-node.d.ts +3 -0
- package/dst/speechflow-node.js +10 -0
- 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 +295 -46
- package/dst/speechflow.js.map +1 -0
- package/etc/speechflow.yaml +14 -5
- package/etc/stx.conf +1 -1
- package/etc/tsconfig.json +2 -2
- package/package.json +17 -10
- package/src/speechflow-node-a2a-meter.ts +125 -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 +1 -1
- package/src/speechflow-node-t2a-kokoro.ts +160 -0
- package/src/{speechflow-node-t2t-gemma.ts → speechflow-node-t2t-ollama.ts} +44 -10
- package/src/speechflow-node-t2t-openai.ts +246 -0
- package/src/speechflow-node-t2t-transformers.ts +249 -0
- package/src/speechflow-node-x2x-trace.ts +2 -2
- package/src/speechflow-node-xio-websocket.ts +5 -5
- package/src/speechflow-node.ts +12 -0
- package/src/speechflow-utils.ts +195 -0
- package/src/speechflow.ts +279 -46
- package/dst/speechflow-node-deepgram.d.ts +0 -12
- package/dst/speechflow-node-deepgram.js +0 -220
- 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.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-mqtt.d.ts +0 -13
- package/dst/speechflow-node-mqtt.js +0 -181
- 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-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.js +0 -604
- package/src/speechflow-node-t2t-opus.ts +0 -111
|
@@ -1,111 +0,0 @@
|
|
|
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 path from "node:path"
|
|
9
|
-
import Stream from "node:stream"
|
|
10
|
-
|
|
11
|
-
/* external dependencies */
|
|
12
|
-
import * as Transformers from "@huggingface/transformers"
|
|
13
|
-
|
|
14
|
-
/* internal dependencies */
|
|
15
|
-
import SpeechFlowNode, { SpeechFlowChunk } from "./speechflow-node"
|
|
16
|
-
|
|
17
|
-
/* SpeechFlow node for OPUS text-to-text translation */
|
|
18
|
-
export default class SpeechFlowNodeOPUS extends SpeechFlowNode {
|
|
19
|
-
/* declare official node name */
|
|
20
|
-
public static name = "opus"
|
|
21
|
-
|
|
22
|
-
/* internal state */
|
|
23
|
-
private translator: Transformers.TranslationPipeline | null = null
|
|
24
|
-
|
|
25
|
-
/* construct node */
|
|
26
|
-
constructor (id: string, cfg: { [ id: string ]: any }, opts: { [ id: string ]: any }, args: any[]) {
|
|
27
|
-
super(id, cfg, opts, args)
|
|
28
|
-
|
|
29
|
-
/* declare node configuration parameters */
|
|
30
|
-
this.configure({
|
|
31
|
-
src: { type: "string", pos: 0, val: "de", match: /^(?:de|en)$/ },
|
|
32
|
-
dst: { type: "string", pos: 1, val: "en", match: /^(?:de|en)$/ }
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
/* sanity check situation */
|
|
36
|
-
if (this.params.src === this.params.dst)
|
|
37
|
-
throw new Error("source and destination languages cannot be the same")
|
|
38
|
-
|
|
39
|
-
/* declare node input/output format */
|
|
40
|
-
this.input = "text"
|
|
41
|
-
this.output = "text"
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/* open node */
|
|
45
|
-
async open () {
|
|
46
|
-
/* instantiate OPUS */
|
|
47
|
-
const model = `onnx-community/opus-mt-${this.params.src}-${this.params.dst}`
|
|
48
|
-
this.translator = await Transformers.pipeline("translation", model, {
|
|
49
|
-
cache_dir: path.join(this.config.cacheDir, "opus"),
|
|
50
|
-
dtype: "q4",
|
|
51
|
-
device: "gpu"
|
|
52
|
-
})
|
|
53
|
-
if (this.translator === null)
|
|
54
|
-
throw new Error("failed to instantiate translator pipeline")
|
|
55
|
-
|
|
56
|
-
/* provide text-to-text translation */
|
|
57
|
-
const translate = async (text: string) => {
|
|
58
|
-
const result = await this.translator!(text)
|
|
59
|
-
return Array.isArray(result) ?
|
|
60
|
-
(result[0] as Transformers.TranslationSingle).translation_text :
|
|
61
|
-
(result as Transformers.TranslationSingle).translation_text
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/* establish a duplex stream and connect it to Ollama */
|
|
65
|
-
this.stream = new Stream.Transform({
|
|
66
|
-
readableObjectMode: true,
|
|
67
|
-
writableObjectMode: true,
|
|
68
|
-
decodeStrings: false,
|
|
69
|
-
transform (chunk: SpeechFlowChunk, encoding, callback) {
|
|
70
|
-
if (Buffer.isBuffer(chunk.payload))
|
|
71
|
-
callback(new Error("invalid chunk payload type"))
|
|
72
|
-
else {
|
|
73
|
-
if (chunk.payload === "") {
|
|
74
|
-
this.push(chunk)
|
|
75
|
-
callback()
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
translate(chunk.payload).then((payload) => {
|
|
79
|
-
const chunkNew = chunk.clone()
|
|
80
|
-
chunkNew.payload = payload
|
|
81
|
-
this.push(chunkNew)
|
|
82
|
-
callback()
|
|
83
|
-
}).catch((err) => {
|
|
84
|
-
callback(err)
|
|
85
|
-
})
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
final (callback) {
|
|
90
|
-
this.push(null)
|
|
91
|
-
callback()
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/* close node */
|
|
97
|
-
async close () {
|
|
98
|
-
/* close stream */
|
|
99
|
-
if (this.stream !== null) {
|
|
100
|
-
this.stream.destroy()
|
|
101
|
-
this.stream = null
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/* shutdown OPUS */
|
|
105
|
-
if (this.translator !== null) {
|
|
106
|
-
this.translator.dispose()
|
|
107
|
-
this.translator = null
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|