speechflow 1.4.5 → 1.5.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 +28 -0
- package/README.md +220 -7
- package/etc/claude.md +70 -0
- package/etc/speechflow.yaml +5 -3
- package/etc/stx.conf +7 -0
- package/package.json +7 -6
- package/speechflow-cli/dst/speechflow-node-a2a-compressor-wt.d.ts +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-compressor-wt.js +155 -0
- package/speechflow-cli/dst/speechflow-node-a2a-compressor-wt.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-compressor.d.ts +15 -0
- package/speechflow-cli/dst/speechflow-node-a2a-compressor.js +287 -0
- package/speechflow-cli/dst/speechflow-node-a2a-compressor.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-dynamics-wt.d.ts +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-dynamics-wt.js +208 -0
- package/speechflow-cli/dst/speechflow-node-a2a-dynamics-wt.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-dynamics.d.ts +15 -0
- package/speechflow-cli/dst/speechflow-node-a2a-dynamics.js +312 -0
- package/speechflow-cli/dst/speechflow-node-a2a-dynamics.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-expander-wt.d.ts +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-expander-wt.js +161 -0
- package/speechflow-cli/dst/speechflow-node-a2a-expander-wt.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-expander.d.ts +13 -0
- package/speechflow-cli/dst/speechflow-node-a2a-expander.js +208 -0
- package/speechflow-cli/dst/speechflow-node-a2a-expander.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-ffmpeg.js +13 -3
- package/speechflow-cli/dst/speechflow-node-a2a-ffmpeg.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-filler.d.ts +14 -0
- package/speechflow-cli/dst/speechflow-node-a2a-filler.js +233 -0
- package/speechflow-cli/dst/speechflow-node-a2a-filler.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-gain.d.ts +12 -0
- package/speechflow-cli/dst/speechflow-node-a2a-gain.js +125 -0
- package/speechflow-cli/dst/speechflow-node-a2a-gain.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-gender.d.ts +0 -1
- package/speechflow-cli/dst/speechflow-node-a2a-gender.js +28 -12
- package/speechflow-cli/dst/speechflow-node-a2a-gender.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-meter.d.ts +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-meter.js +12 -8
- package/speechflow-cli/dst/speechflow-node-a2a-meter.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-mute.js +2 -1
- package/speechflow-cli/dst/speechflow-node-a2a-mute.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-rnnoise-wt.d.ts +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-rnnoise-wt.js +55 -0
- package/speechflow-cli/dst/speechflow-node-a2a-rnnoise-wt.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-rnnoise.d.ts +14 -0
- package/speechflow-cli/dst/speechflow-node-a2a-rnnoise.js +184 -0
- package/speechflow-cli/dst/speechflow-node-a2a-rnnoise.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-speex.d.ts +14 -0
- package/speechflow-cli/dst/speechflow-node-a2a-speex.js +156 -0
- package/speechflow-cli/dst/speechflow-node-a2a-speex.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-vad.js +3 -3
- package/speechflow-cli/dst/speechflow-node-a2a-vad.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-wav.js +22 -17
- package/speechflow-cli/dst/speechflow-node-a2a-wav.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2t-awstranscribe.d.ts +18 -0
- package/speechflow-cli/dst/speechflow-node-a2t-awstranscribe.js +317 -0
- package/speechflow-cli/dst/speechflow-node-a2t-awstranscribe.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2t-deepgram.js +15 -13
- package/speechflow-cli/dst/speechflow-node-a2t-deepgram.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2t-openaitranscribe.d.ts +19 -0
- package/speechflow-cli/dst/speechflow-node-a2t-openaitranscribe.js +351 -0
- package/speechflow-cli/dst/speechflow-node-a2t-openaitranscribe.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2a-awspolly.d.ts +16 -0
- package/speechflow-cli/dst/speechflow-node-t2a-awspolly.js +171 -0
- package/speechflow-cli/dst/speechflow-node-t2a-awspolly.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2a-elevenlabs.js +19 -14
- package/speechflow-cli/dst/speechflow-node-t2a-elevenlabs.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2a-kokoro.js +11 -6
- package/speechflow-cli/dst/speechflow-node-t2a-kokoro.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-awstranslate.d.ts +13 -0
- package/speechflow-cli/dst/speechflow-node-t2t-awstranslate.js +141 -0
- package/speechflow-cli/dst/speechflow-node-t2t-awstranslate.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2t-deepl.js +13 -15
- package/speechflow-cli/dst/speechflow-node-t2t-deepl.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-format.js +10 -15
- package/speechflow-cli/dst/speechflow-node-t2t-format.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-ollama.js +44 -31
- package/speechflow-cli/dst/speechflow-node-t2t-ollama.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-openai.js +44 -45
- package/speechflow-cli/dst/speechflow-node-t2t-openai.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-sentence.js +8 -8
- package/speechflow-cli/dst/speechflow-node-t2t-sentence.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-subtitle.js +10 -12
- package/speechflow-cli/dst/speechflow-node-t2t-subtitle.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-transformers.js +22 -27
- package/speechflow-cli/dst/speechflow-node-t2t-transformers.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-x2x-filter.d.ts +1 -0
- package/speechflow-cli/dst/speechflow-node-x2x-filter.js +50 -15
- package/speechflow-cli/dst/speechflow-node-x2x-filter.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-x2x-trace.js +17 -18
- package/speechflow-cli/dst/speechflow-node-x2x-trace.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-xio-device.js +13 -21
- package/speechflow-cli/dst/speechflow-node-xio-device.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-xio-mqtt.d.ts +1 -0
- package/speechflow-cli/dst/speechflow-node-xio-mqtt.js +22 -16
- package/speechflow-cli/dst/speechflow-node-xio-mqtt.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-xio-websocket.js +19 -19
- package/speechflow-cli/dst/speechflow-node-xio-websocket.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node.d.ts +6 -3
- package/speechflow-cli/dst/speechflow-node.js +13 -2
- package/speechflow-cli/dst/speechflow-node.js.map +1 -1
- package/speechflow-cli/dst/speechflow-utils-audio-wt.d.ts +1 -0
- package/speechflow-cli/dst/speechflow-utils-audio-wt.js +124 -0
- package/speechflow-cli/dst/speechflow-utils-audio-wt.js.map +1 -0
- package/speechflow-cli/dst/speechflow-utils-audio.d.ts +13 -0
- package/speechflow-cli/dst/speechflow-utils-audio.js +137 -0
- package/speechflow-cli/dst/speechflow-utils-audio.js.map +1 -0
- package/speechflow-cli/dst/speechflow-utils.d.ts +18 -0
- package/speechflow-cli/dst/speechflow-utils.js +123 -35
- package/speechflow-cli/dst/speechflow-utils.js.map +1 -1
- package/speechflow-cli/dst/speechflow.js +69 -14
- package/speechflow-cli/dst/speechflow.js.map +1 -1
- package/speechflow-cli/etc/oxlint.jsonc +112 -11
- package/speechflow-cli/etc/stx.conf +2 -2
- package/speechflow-cli/etc/tsconfig.json +1 -1
- package/speechflow-cli/package.d/@shiguredo+rnnoise-wasm+2025.1.5.patch +25 -0
- package/speechflow-cli/package.json +102 -94
- package/speechflow-cli/src/lib.d.ts +24 -0
- package/speechflow-cli/src/speechflow-node-a2a-compressor-wt.ts +151 -0
- package/speechflow-cli/src/speechflow-node-a2a-compressor.ts +303 -0
- package/speechflow-cli/src/speechflow-node-a2a-expander-wt.ts +158 -0
- package/speechflow-cli/src/speechflow-node-a2a-expander.ts +212 -0
- package/speechflow-cli/src/speechflow-node-a2a-ffmpeg.ts +13 -3
- package/speechflow-cli/src/speechflow-node-a2a-filler.ts +223 -0
- package/speechflow-cli/src/speechflow-node-a2a-gain.ts +98 -0
- package/speechflow-cli/src/speechflow-node-a2a-gender.ts +31 -17
- package/speechflow-cli/src/speechflow-node-a2a-meter.ts +13 -9
- package/speechflow-cli/src/speechflow-node-a2a-mute.ts +3 -2
- package/speechflow-cli/src/speechflow-node-a2a-rnnoise-wt.ts +62 -0
- package/speechflow-cli/src/speechflow-node-a2a-rnnoise.ts +164 -0
- package/speechflow-cli/src/speechflow-node-a2a-speex.ts +137 -0
- package/speechflow-cli/src/speechflow-node-a2a-vad.ts +3 -3
- package/speechflow-cli/src/speechflow-node-a2a-wav.ts +20 -13
- package/speechflow-cli/src/speechflow-node-a2t-awstranscribe.ts +308 -0
- package/speechflow-cli/src/speechflow-node-a2t-deepgram.ts +15 -13
- package/speechflow-cli/src/speechflow-node-a2t-openaitranscribe.ts +337 -0
- package/speechflow-cli/src/speechflow-node-t2a-awspolly.ts +187 -0
- package/speechflow-cli/src/speechflow-node-t2a-elevenlabs.ts +19 -14
- package/speechflow-cli/src/speechflow-node-t2a-kokoro.ts +12 -7
- package/speechflow-cli/src/speechflow-node-t2t-awstranslate.ts +152 -0
- package/speechflow-cli/src/speechflow-node-t2t-deepl.ts +13 -15
- package/speechflow-cli/src/speechflow-node-t2t-format.ts +10 -15
- package/speechflow-cli/src/speechflow-node-t2t-ollama.ts +55 -42
- package/speechflow-cli/src/speechflow-node-t2t-openai.ts +58 -58
- package/speechflow-cli/src/speechflow-node-t2t-sentence.ts +10 -10
- package/speechflow-cli/src/speechflow-node-t2t-subtitle.ts +15 -16
- package/speechflow-cli/src/speechflow-node-t2t-transformers.ts +27 -32
- package/speechflow-cli/src/speechflow-node-x2x-filter.ts +20 -16
- package/speechflow-cli/src/speechflow-node-x2x-trace.ts +20 -19
- package/speechflow-cli/src/speechflow-node-xio-device.ts +15 -23
- package/speechflow-cli/src/speechflow-node-xio-mqtt.ts +23 -16
- package/speechflow-cli/src/speechflow-node-xio-websocket.ts +19 -19
- package/speechflow-cli/src/speechflow-node.ts +21 -8
- package/speechflow-cli/src/speechflow-utils-audio-wt.ts +172 -0
- package/speechflow-cli/src/speechflow-utils-audio.ts +147 -0
- package/speechflow-cli/src/speechflow-utils.ts +125 -32
- package/speechflow-cli/src/speechflow.ts +74 -17
- package/speechflow-ui-db/dst/index.js +31 -31
- package/speechflow-ui-db/etc/eslint.mjs +0 -1
- package/speechflow-ui-db/etc/tsc-client.json +3 -3
- package/speechflow-ui-db/package.json +11 -10
- package/speechflow-ui-db/src/app.vue +20 -6
- package/speechflow-ui-st/dst/index.js +26 -26
- package/speechflow-ui-st/etc/eslint.mjs +0 -1
- package/speechflow-ui-st/etc/tsc-client.json +3 -3
- package/speechflow-ui-st/package.json +11 -10
- package/speechflow-ui-st/src/app.vue +5 -12
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
** SpeechFlow - Speech Processing Flow Graph
|
|
4
|
+
** Copyright (c) 2024-2025 Dr. Ralf S. Engelschall <rse@engelschall.com>
|
|
5
|
+
** Licensed under GPL 3.0 <https://spdx.org/licenses/GPL-3.0-only>
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
|
+
};
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
/* standard dependencies */
|
|
45
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
46
|
+
const node_stream_1 = __importDefault(require("node:stream"));
|
|
47
|
+
/* external dependencies */
|
|
48
|
+
const node_web_audio_api_1 = require("node-web-audio-api");
|
|
49
|
+
/* internal dependencies */
|
|
50
|
+
const speechflow_node_1 = __importDefault(require("./speechflow-node"));
|
|
51
|
+
const utils = __importStar(require("./speechflow-utils"));
|
|
52
|
+
const speechflow_utils_audio_1 = require("./speechflow-utils-audio");
|
|
53
|
+
/* audio compressor class */
|
|
54
|
+
class AudioCompressor extends speechflow_utils_audio_1.WebAudio {
|
|
55
|
+
/* internal state */
|
|
56
|
+
type;
|
|
57
|
+
mode;
|
|
58
|
+
config;
|
|
59
|
+
compressorNode = null;
|
|
60
|
+
gainNode = null;
|
|
61
|
+
/* construct object */
|
|
62
|
+
constructor(sampleRate, channels, type = "standalone", mode = "compress", config = {}) {
|
|
63
|
+
super(sampleRate, channels);
|
|
64
|
+
/* store type and mode */
|
|
65
|
+
this.type = type;
|
|
66
|
+
this.mode = mode;
|
|
67
|
+
/* store configuration */
|
|
68
|
+
this.config = {
|
|
69
|
+
thresholdDb: config.thresholdDb ?? -23,
|
|
70
|
+
ratio: config.ratio ?? 4.0,
|
|
71
|
+
attackMs: config.attackMs ?? 10,
|
|
72
|
+
releaseMs: config.releaseMs ?? 50,
|
|
73
|
+
kneeDb: config.kneeDb ?? 6.0,
|
|
74
|
+
makeupDb: config.makeupDb ?? 0
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/* setup object */
|
|
78
|
+
async setup() {
|
|
79
|
+
await super.setup();
|
|
80
|
+
/* add audio worklet module */
|
|
81
|
+
const url = node_path_1.default.resolve(__dirname, "speechflow-node-a2a-compressor-wt.js");
|
|
82
|
+
await this.audioContext.audioWorklet.addModule(url);
|
|
83
|
+
/* determine operation modes */
|
|
84
|
+
const needsCompressor = (this.type === "standalone" && this.mode === "compress") ||
|
|
85
|
+
(this.type === "sidechain" && this.mode === "measure");
|
|
86
|
+
const needsGain = (this.type === "standalone" && this.mode === "compress") ||
|
|
87
|
+
(this.type === "sidechain" && this.mode === "adjust");
|
|
88
|
+
/* create compressor worklet node */
|
|
89
|
+
if (needsCompressor) {
|
|
90
|
+
this.compressorNode = new node_web_audio_api_1.AudioWorkletNode(this.audioContext, "compressor", {
|
|
91
|
+
numberOfInputs: 1,
|
|
92
|
+
numberOfOutputs: 1,
|
|
93
|
+
processorOptions: {
|
|
94
|
+
sampleRate: this.audioContext.sampleRate
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/* create gain node */
|
|
99
|
+
if (needsGain)
|
|
100
|
+
this.gainNode = this.audioContext.createGain();
|
|
101
|
+
/* connect nodes (according to type and mode) */
|
|
102
|
+
if (this.type === "standalone" && this.mode === "compress") {
|
|
103
|
+
this.sourceNode.connect(this.compressorNode);
|
|
104
|
+
this.compressorNode.connect(this.gainNode);
|
|
105
|
+
this.gainNode.connect(this.captureNode);
|
|
106
|
+
}
|
|
107
|
+
else if (this.type === "sidechain" && this.mode === "measure") {
|
|
108
|
+
this.sourceNode.connect(this.compressorNode);
|
|
109
|
+
}
|
|
110
|
+
else if (this.type === "sidechain" && this.mode === "adjust") {
|
|
111
|
+
this.sourceNode.connect(this.gainNode);
|
|
112
|
+
this.gainNode.connect(this.captureNode);
|
|
113
|
+
}
|
|
114
|
+
/* configure compressor worklet node */
|
|
115
|
+
const currentTime = this.audioContext.currentTime;
|
|
116
|
+
if (needsCompressor) {
|
|
117
|
+
const node = this.compressorNode;
|
|
118
|
+
const params = node.parameters;
|
|
119
|
+
params.get("threshold").setValueAtTime(this.config.thresholdDb, currentTime);
|
|
120
|
+
params.get("ratio").setValueAtTime(this.config.ratio, currentTime);
|
|
121
|
+
params.get("attack").setValueAtTime(this.config.attackMs / 1000, currentTime);
|
|
122
|
+
params.get("release").setValueAtTime(this.config.releaseMs / 1000, currentTime);
|
|
123
|
+
params.get("knee").setValueAtTime(this.config.kneeDb, currentTime);
|
|
124
|
+
params.get("makeup").setValueAtTime(this.config.makeupDb, currentTime);
|
|
125
|
+
}
|
|
126
|
+
/* configure gain node */
|
|
127
|
+
if (needsGain) {
|
|
128
|
+
const gain = Math.pow(10, this.config.makeupDb / 20);
|
|
129
|
+
this.gainNode.gain.setValueAtTime(gain, currentTime);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/* get the current gain reduction */
|
|
133
|
+
getGainReduction() {
|
|
134
|
+
const processor = this.compressorNode?.port?.processor;
|
|
135
|
+
return processor?.reduction ?? 0;
|
|
136
|
+
}
|
|
137
|
+
/* set the current gain */
|
|
138
|
+
setGain(decibel) {
|
|
139
|
+
const gain = Math.pow(10, decibel / 20);
|
|
140
|
+
this.gainNode?.gain.setTargetAtTime(gain, this.audioContext.currentTime, 0.002);
|
|
141
|
+
}
|
|
142
|
+
/* destroy the compressor */
|
|
143
|
+
async destroy() {
|
|
144
|
+
await super.destroy();
|
|
145
|
+
/* destroy nodes */
|
|
146
|
+
if (this.compressorNode !== null) {
|
|
147
|
+
this.compressorNode.disconnect();
|
|
148
|
+
this.compressorNode = null;
|
|
149
|
+
}
|
|
150
|
+
if (this.gainNode !== null) {
|
|
151
|
+
this.gainNode.disconnect();
|
|
152
|
+
this.gainNode = null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/* SpeechFlow node for compression in audio-to-audio passing */
|
|
157
|
+
class SpeechFlowNodeCompressor extends speechflow_node_1.default {
|
|
158
|
+
/* declare official node name */
|
|
159
|
+
static name = "compressor";
|
|
160
|
+
/* internal state */
|
|
161
|
+
destroyed = false;
|
|
162
|
+
compressor = null;
|
|
163
|
+
bus = null;
|
|
164
|
+
intervalId = null;
|
|
165
|
+
/* construct node */
|
|
166
|
+
constructor(id, cfg, opts, args) {
|
|
167
|
+
super(id, cfg, opts, args);
|
|
168
|
+
/* declare node configuration parameters */
|
|
169
|
+
this.configure({
|
|
170
|
+
type: { type: "string", val: "standalone", match: /^(?:standalone|sidechain)$/ },
|
|
171
|
+
mode: { type: "string", val: "compress", match: /^(?:compress|measure|adjust)$/ },
|
|
172
|
+
bus: { type: "string", val: "compressor", match: /^.+$/ },
|
|
173
|
+
thresholdDb: { type: "number", val: -23, match: (n) => n <= 0 && n >= -100 },
|
|
174
|
+
ratio: { type: "number", val: 4.0, match: (n) => n >= 1 && n <= 20 },
|
|
175
|
+
attackMs: { type: "number", val: 10, match: (n) => n >= 0 && n <= 1000 },
|
|
176
|
+
releaseMs: { type: "number", val: 50, match: (n) => n >= 0 && n <= 1000 },
|
|
177
|
+
kneeDb: { type: "number", val: 6.0, match: (n) => n >= 0 && n <= 40 },
|
|
178
|
+
makeupDb: { type: "number", val: 0, match: (n) => n >= -24 && n <= 24 }
|
|
179
|
+
});
|
|
180
|
+
/* sanity check mode and role */
|
|
181
|
+
if (this.params.type === "standalone" && this.params.mode !== "compress")
|
|
182
|
+
throw new Error("type \"standalone\" implies mode \"compress\"");
|
|
183
|
+
if (this.params.type === "sidechain" && this.params.mode === "compress")
|
|
184
|
+
throw new Error("type \"sidechain\" implies mode \"measure\" or \"adjust\"");
|
|
185
|
+
/* declare node input/output format */
|
|
186
|
+
this.input = "audio";
|
|
187
|
+
this.output = "audio";
|
|
188
|
+
}
|
|
189
|
+
/* open node */
|
|
190
|
+
async open() {
|
|
191
|
+
/* clear destruction flag */
|
|
192
|
+
this.destroyed = false;
|
|
193
|
+
/* setup compressor */
|
|
194
|
+
this.compressor = new AudioCompressor(this.config.audioSampleRate, this.config.audioChannels, this.params.type, this.params.mode, {
|
|
195
|
+
thresholdDb: this.params.thresholdDb,
|
|
196
|
+
ratio: this.params.ratio,
|
|
197
|
+
attackMs: this.params.attackMs,
|
|
198
|
+
releaseMs: this.params.releaseMs,
|
|
199
|
+
kneeDb: this.params.kneeDb,
|
|
200
|
+
makeupDb: this.params.makeupDb
|
|
201
|
+
});
|
|
202
|
+
await this.compressor.setup();
|
|
203
|
+
/* optionally establish sidechain processing */
|
|
204
|
+
if (this.params.type === "sidechain") {
|
|
205
|
+
this.bus = this.accessBus(this.params.bus);
|
|
206
|
+
if (this.params.mode === "measure") {
|
|
207
|
+
this.intervalId = setInterval(() => {
|
|
208
|
+
const decibel = this.compressor?.getGainReduction();
|
|
209
|
+
this.bus?.emit("sidechain-decibel", decibel);
|
|
210
|
+
}, 10);
|
|
211
|
+
}
|
|
212
|
+
else if (this.params.mode === "adjust") {
|
|
213
|
+
this.bus.on("sidechain-decibel", (decibel) => {
|
|
214
|
+
this.compressor?.setGain(decibel);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/* establish a transform stream */
|
|
219
|
+
const self = this;
|
|
220
|
+
this.stream = new node_stream_1.default.Transform({
|
|
221
|
+
readableObjectMode: true,
|
|
222
|
+
writableObjectMode: true,
|
|
223
|
+
decodeStrings: false,
|
|
224
|
+
transform(chunk, encoding, callback) {
|
|
225
|
+
if (self.destroyed) {
|
|
226
|
+
callback(new Error("stream already destroyed"));
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
if (!Buffer.isBuffer(chunk.payload))
|
|
230
|
+
callback(new Error("invalid chunk payload type"));
|
|
231
|
+
else {
|
|
232
|
+
/* compress chunk */
|
|
233
|
+
const payload = utils.convertBufToI16(chunk.payload);
|
|
234
|
+
self.compressor?.process(payload).then((result) => {
|
|
235
|
+
if (self.destroyed)
|
|
236
|
+
throw new Error("stream already destroyed");
|
|
237
|
+
if ((self.params.type === "standalone" && self.params.mode === "compress") ||
|
|
238
|
+
(self.params.type === "sidechain" && self.params.mode === "adjust")) {
|
|
239
|
+
/* take over compressed data */
|
|
240
|
+
const payload = utils.convertI16ToBuf(result);
|
|
241
|
+
chunk.payload = payload;
|
|
242
|
+
}
|
|
243
|
+
this.push(chunk);
|
|
244
|
+
callback();
|
|
245
|
+
}).catch((error) => {
|
|
246
|
+
callback(new Error(`compression failed: ${error}`));
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
final(callback) {
|
|
251
|
+
if (self.destroyed) {
|
|
252
|
+
callback();
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
this.push(null);
|
|
256
|
+
callback();
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
/* close node */
|
|
261
|
+
async close() {
|
|
262
|
+
/* indicate destruction */
|
|
263
|
+
this.destroyed = true;
|
|
264
|
+
/* clear interval */
|
|
265
|
+
if (this.intervalId !== null) {
|
|
266
|
+
clearInterval(this.intervalId);
|
|
267
|
+
this.intervalId = null;
|
|
268
|
+
}
|
|
269
|
+
/* destroy bus */
|
|
270
|
+
if (this.bus !== null) {
|
|
271
|
+
this.bus.removeAllListeners();
|
|
272
|
+
this.bus = null;
|
|
273
|
+
}
|
|
274
|
+
/* destroy compressor */
|
|
275
|
+
if (this.compressor !== null) {
|
|
276
|
+
await this.compressor.destroy();
|
|
277
|
+
this.compressor = null;
|
|
278
|
+
}
|
|
279
|
+
/* close stream */
|
|
280
|
+
if (this.stream !== null) {
|
|
281
|
+
this.stream.destroy();
|
|
282
|
+
this.stream = null;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
exports.default = SpeechFlowNodeCompressor;
|
|
287
|
+
//# sourceMappingURL=speechflow-node-a2a-compressor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"speechflow-node-a2a-compressor.js","sourceRoot":"","sources":["../src/speechflow-node-a2a-compressor.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,6BAA6B;AAC7B,0DAAwC;AACxC,8DAA0C;AAG1C,6BAA6B;AAC7B,2DAA+D;AAE/D,6BAA6B;AAC7B,wEAAmE;AACnE,0DAAoE;AACpE,qEAA0E;AAY1E,8BAA8B;AAC9B,MAAM,eAAgB,SAAQ,iCAAQ;IAClC,sBAAsB;IACd,IAAI,CAAyC;IAC7C,IAAI,CAAgD;IACpD,MAAM,C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AClB,KAAK,CAAC,KAAK;QACP,4BAA4B;QAC5B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAA;QAErB,sBAAsB;QACtB,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI,EAAE,CAAC;YAC3B,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;YAC9B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAA;QAC1B,CAAC;QAED,mBAAmB;QACnB,IAAI,IAAI,CAAC,GAAG,KAAK,IAAI,EAAE,CAAC;YACpB,IAAI,CAAC,GAAG,CAAC,kBAAkB,EAAE,CAAA;YAC7B,IAAI,CAAC,GAAG,GAAG,IAAI,CAAA;QACnB,CAAC;QAED,0BAA0B;QAC1B,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI,EAAE,CAAC;YAC3B,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAA;YAC/B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAA;QAC1B,CAAC;QAED,oBAAoB;QACpB,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;YACvB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAA;YACrB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QACtB,CAAC;IACL,CAAC;;AAlJL,2CAmJC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
** SpeechFlow - Speech Processing Flow Graph
|
|
4
|
+
** Copyright (c) 2024-2025 Dr. Ralf S. Engelschall <rse@engelschall.com>
|
|
5
|
+
** Licensed under GPL 3.0 <https://spdx.org/licenses/GPL-3.0-only>
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
const utils = __importStar(require("./speechflow-utils"));
|
|
42
|
+
/* unified dynamics processor with compression and expansion */
|
|
43
|
+
class DynamicsProcessor extends AudioWorkletProcessor {
|
|
44
|
+
/* internal state */
|
|
45
|
+
env = [];
|
|
46
|
+
sampleRate;
|
|
47
|
+
reduction = 0;
|
|
48
|
+
/* eslint no-undef: off */
|
|
49
|
+
static get parameterDescriptors() {
|
|
50
|
+
return [
|
|
51
|
+
{ name: "mode", defaultValue: 0, minValue: 0, maxValue: 2, automationRate: "k-rate" }, // 0=compress, 1=expand, 2=both
|
|
52
|
+
{ name: "threshold", defaultValue: -23, minValue: -100, maxValue: 0, automationRate: "k-rate" }, // dBFS
|
|
53
|
+
{ name: "ratio", defaultValue: 4.0, minValue: 1.0, maxValue: 20, automationRate: "k-rate" }, // compression/expansion ratio
|
|
54
|
+
{ name: "attack", defaultValue: 0.010, minValue: 0.0, maxValue: 1, automationRate: "k-rate" }, // seconds
|
|
55
|
+
{ name: "release", defaultValue: 0.050, minValue: 0.0, maxValue: 1, automationRate: "k-rate" }, // seconds
|
|
56
|
+
{ name: "knee", defaultValue: 6.0, minValue: 0.0, maxValue: 40, automationRate: "k-rate" }, // dB
|
|
57
|
+
{ name: "makeup", defaultValue: 0.0, minValue: -24, maxValue: 24, automationRate: "k-rate" }, // dB
|
|
58
|
+
{ name: "expandThreshold", defaultValue: -45, minValue: -100, maxValue: 0, automationRate: "k-rate" }, // dBFS for expansion
|
|
59
|
+
{ name: "expandRatio", defaultValue: 4.0, minValue: 1.0, maxValue: 20, automationRate: "k-rate" }, // expansion ratio
|
|
60
|
+
{ name: "floor", defaultValue: -64, minValue: -100, maxValue: 0, automationRate: "k-rate" } // dBFS minimum output level
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
/* class constructor for custom option processing */
|
|
64
|
+
constructor(options) {
|
|
65
|
+
super();
|
|
66
|
+
const { sampleRate } = options.processorOptions;
|
|
67
|
+
this.sampleRate = sampleRate;
|
|
68
|
+
}
|
|
69
|
+
/* determine compression gain difference */
|
|
70
|
+
compressGainDBFor(levelDB, thresholdDB, ratio, kneeDB) {
|
|
71
|
+
/* short-circuit for unreasonable ratio */
|
|
72
|
+
if (ratio <= 1.0)
|
|
73
|
+
return 0;
|
|
74
|
+
/* determine thresholds */
|
|
75
|
+
const halfKnee = kneeDB * 0.5;
|
|
76
|
+
const belowThr = levelDB < thresholdDB;
|
|
77
|
+
const aboveKnee = levelDB >= (thresholdDB + halfKnee);
|
|
78
|
+
/* short-circuit for no compression (below threshold) */
|
|
79
|
+
if (belowThr)
|
|
80
|
+
return 0;
|
|
81
|
+
/* apply soft-knee */
|
|
82
|
+
if (kneeDB > 0 && !aboveKnee) {
|
|
83
|
+
const x = (levelDB - thresholdDB) / kneeDB;
|
|
84
|
+
const idealGainDB = (thresholdDB + (levelDB - thresholdDB) / ratio) - levelDB;
|
|
85
|
+
return idealGainDB * x * x;
|
|
86
|
+
}
|
|
87
|
+
/* determine target level */
|
|
88
|
+
const targetOut = thresholdDB + (levelDB - thresholdDB) / ratio;
|
|
89
|
+
/* return gain difference */
|
|
90
|
+
return targetOut - levelDB;
|
|
91
|
+
}
|
|
92
|
+
/* determine expansion gain difference */
|
|
93
|
+
expandGainDBFor(levelDB, thresholdDB, ratio, kneeDB) {
|
|
94
|
+
/* short-circuit for unreasonable ratio */
|
|
95
|
+
if (ratio <= 1.0)
|
|
96
|
+
return 0;
|
|
97
|
+
/* determine thresholds */
|
|
98
|
+
const halfKnee = kneeDB * 0.5;
|
|
99
|
+
const belowKnee = levelDB < (thresholdDB - halfKnee);
|
|
100
|
+
const aboveThr = levelDB >= thresholdDB;
|
|
101
|
+
/* short-circuit for no expansion (above threshold) */
|
|
102
|
+
if (aboveThr)
|
|
103
|
+
return 0;
|
|
104
|
+
/* apply soft-knee */
|
|
105
|
+
if (kneeDB > 0 && !belowKnee) {
|
|
106
|
+
const x = (levelDB - (thresholdDB - halfKnee)) / kneeDB;
|
|
107
|
+
const idealGainDB = (thresholdDB + (levelDB - thresholdDB) * ratio) - levelDB;
|
|
108
|
+
return idealGainDB * x * x;
|
|
109
|
+
}
|
|
110
|
+
/* determine target level */
|
|
111
|
+
const targetOut = thresholdDB + (levelDB - thresholdDB) / ratio;
|
|
112
|
+
/* return gain difference */
|
|
113
|
+
return targetOut - levelDB;
|
|
114
|
+
}
|
|
115
|
+
/* update envelope (smoothed amplitude contour) for single channel */
|
|
116
|
+
updateEnvelopeForChannel(chan, samples, attack, release) {
|
|
117
|
+
/* fetch old envelope value */
|
|
118
|
+
if (this.env[chan] === undefined)
|
|
119
|
+
this.env[chan] = 1e-12;
|
|
120
|
+
let env = this.env[chan];
|
|
121
|
+
/* calculate attack/release alpha values */
|
|
122
|
+
const alphaA = Math.exp(-1 / (attack * this.sampleRate));
|
|
123
|
+
const alphaR = Math.exp(-1 / (release * this.sampleRate));
|
|
124
|
+
/* iterate over all samples and calculate RMS */
|
|
125
|
+
for (const s of samples) {
|
|
126
|
+
const x = Math.abs(s);
|
|
127
|
+
const det = x * x;
|
|
128
|
+
if (det > env)
|
|
129
|
+
env = alphaA * env + (1 - alphaA) * det;
|
|
130
|
+
else
|
|
131
|
+
env = alphaR * env + (1 - alphaR) * det;
|
|
132
|
+
}
|
|
133
|
+
this.env[chan] = Math.sqrt(Math.max(env, 1e-12));
|
|
134
|
+
}
|
|
135
|
+
/* process a single sample frame */
|
|
136
|
+
process(inputs, outputs, parameters) {
|
|
137
|
+
/* sanity check */
|
|
138
|
+
const input = inputs[0];
|
|
139
|
+
const output = outputs[0];
|
|
140
|
+
if (!input || input.length === 0 || !output)
|
|
141
|
+
return true;
|
|
142
|
+
/* determine number of channels */
|
|
143
|
+
const nCh = input.length;
|
|
144
|
+
/* reset envelope array if channel count changed */
|
|
145
|
+
if (nCh !== this.env.length)
|
|
146
|
+
this.env = [];
|
|
147
|
+
/* initially just copy input to output (pass-through) */
|
|
148
|
+
for (let c = 0; c < output.length; c++) {
|
|
149
|
+
if (!output[c] || !input[c])
|
|
150
|
+
continue;
|
|
151
|
+
output[c].set(input[c]);
|
|
152
|
+
}
|
|
153
|
+
/* fetch parameters */
|
|
154
|
+
const mode = Math.round(parameters["mode"][0]);
|
|
155
|
+
const thresholdDB = parameters["threshold"][0];
|
|
156
|
+
const ratio = parameters["ratio"][0];
|
|
157
|
+
const kneeDB = parameters["knee"][0];
|
|
158
|
+
const attackS = Math.max(parameters["attack"][0], 1 / this.sampleRate);
|
|
159
|
+
const releaseS = Math.max(parameters["release"][0], 1 / this.sampleRate);
|
|
160
|
+
const makeupDB = parameters["makeup"][0];
|
|
161
|
+
const expandThresholdDB = parameters["expandThreshold"][0];
|
|
162
|
+
const expandRatio = parameters["expandRatio"][0];
|
|
163
|
+
const floorDB = parameters["floor"][0];
|
|
164
|
+
/* update envelope per channel */
|
|
165
|
+
for (let ch = 0; ch < nCh; ch++)
|
|
166
|
+
this.updateEnvelopeForChannel(ch, input[ch], attackS, releaseS);
|
|
167
|
+
/* determine linear value from decibel makeup value */
|
|
168
|
+
const makeUpLin = utils.dB2lin(makeupDB);
|
|
169
|
+
/* iterate over all channels */
|
|
170
|
+
this.reduction = 0;
|
|
171
|
+
for (let ch = 0; ch < nCh; ch++) {
|
|
172
|
+
const levelDB = utils.lin2dB(this.env[ch]);
|
|
173
|
+
let totalGainDB = 0;
|
|
174
|
+
/* apply compression if needed */
|
|
175
|
+
if (mode === 0 || mode === 2) {
|
|
176
|
+
const compressGainDB = this.compressGainDBFor(levelDB, thresholdDB, ratio, kneeDB);
|
|
177
|
+
totalGainDB += compressGainDB;
|
|
178
|
+
/* on first channel, calculate reduction for compression */
|
|
179
|
+
if (ch === 0)
|
|
180
|
+
this.reduction = Math.min(0, compressGainDB);
|
|
181
|
+
}
|
|
182
|
+
/* apply expansion if needed */
|
|
183
|
+
if (mode === 1 || mode === 2) {
|
|
184
|
+
const expandGainDB = this.expandGainDBFor(levelDB, expandThresholdDB, expandRatio, kneeDB);
|
|
185
|
+
totalGainDB += expandGainDB;
|
|
186
|
+
}
|
|
187
|
+
/* calculate total gain with makeup */
|
|
188
|
+
let gainLin = utils.dB2lin(totalGainDB) * makeUpLin;
|
|
189
|
+
/* do not attenuate below floor (for expansion) */
|
|
190
|
+
if (mode === 1 || mode === 2) {
|
|
191
|
+
const expectedOutLevelDB = levelDB + totalGainDB + makeupDB;
|
|
192
|
+
if (expectedOutLevelDB < floorDB) {
|
|
193
|
+
const neededLiftDB = floorDB - expectedOutLevelDB;
|
|
194
|
+
gainLin /= utils.dB2lin(neededLiftDB);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/* apply gain change to channel */
|
|
198
|
+
const inp = input[ch];
|
|
199
|
+
const out = output[ch];
|
|
200
|
+
for (let i = 0; i < inp.length; i++)
|
|
201
|
+
out[i] = inp[i] * gainLin;
|
|
202
|
+
}
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/* register the new audio nodes */
|
|
207
|
+
registerProcessor("dynamics", DynamicsProcessor);
|
|
208
|
+
//# sourceMappingURL=speechflow-node-a2a-dynamics-wt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"speechflow-node-a2a-dynamics-wt.js","sourceRoot":"","sources":["../src/speechflow-node-a2a-dynamics-wt.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,0DAA2C;AAE3C,iEAAiE;AACjE,MAAM,iBAAkB,SAAQ,qBAAqB;IACjD,sBAAsB;IACd,GAAG,GAAa,EAAE,CAAA;IAClB,UAAU,CAAQ;IACnB,SAAS,GAAG,CAAC,CAAA;IAEpB,2BAA2B;IAC3B,MAAM,KAAK,oBAAoB;QAC3B,OAAO;YACH,EAAE,IAAI,EAAE,MAAM,EAAY,YAAY,EAAE,CAAC,EAAM,QAAQ,EAAE,CAAC,EAAO,QAAQ,EAAE,CAAC,EAAI,cAAc,EAAE,QAAQ,EAAE,EAAE,+BAA+B;YAC3I,EAAE,IAAI,EAAE,WAAW,EAAO,YAAY,EAAE,CAAC,EAAE,EAAI,QAAQ,EAAE,CAAC,GAAG,EAAI,QAAQ,EAAE,CAAC,EAAI,cAAc,EAAE,QAAQ,EAAE,EAAE,OAAO;YACnH,EAAE,IAAI,EAAE,OAAO,EAAW,YAAY,EAAE,GAAG,EAAI,QAAQ,EAAE,GAAG,EAAK,QAAQ,EAAE,EAAE,EAAG,c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OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;gBACzC,CAAC;YACL,CAAC;YAED,oCAAoC;YACpC,MAAM,GAAG,GAAG,KAAK,CAAC,EAAE,CAAC,CAAA;YACrB,MAAM,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC,CAAA;YACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE;gBAC/B,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,CAAA;QACjC,CAAC;QACD,OAAO,IAAI,CAAA;IACf,CAAC;CACJ;AAED,oCAAoC;AACpC,iBAAiB,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import SpeechFlowNode from "./speechflow-node";
|
|
2
|
+
export default class SpeechFlowNodeDynamics extends SpeechFlowNode {
|
|
3
|
+
static name: string;
|
|
4
|
+
private destroyed;
|
|
5
|
+
private dynamics;
|
|
6
|
+
private bus;
|
|
7
|
+
private intervalId;
|
|
8
|
+
constructor(id: string, cfg: {
|
|
9
|
+
[id: string]: any;
|
|
10
|
+
}, opts: {
|
|
11
|
+
[id: string]: any;
|
|
12
|
+
}, args: any[]);
|
|
13
|
+
open(): Promise<void>;
|
|
14
|
+
close(): Promise<void>;
|
|
15
|
+
}
|