speechflow 1.4.3 → 1.4.4
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 +6 -0
- package/package.json +3 -3
- package/speechflow-cli/dst/speechflow-node-a2a-ffmpeg.d.ts +13 -0
- package/speechflow-cli/dst/speechflow-node-a2a-ffmpeg.js +153 -0
- package/speechflow-cli/dst/speechflow-node-a2a-ffmpeg.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-gender.d.ts +20 -0
- package/speechflow-cli/dst/speechflow-node-a2a-gender.js +349 -0
- package/speechflow-cli/dst/speechflow-node-a2a-gender.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-meter.d.ts +16 -0
- package/speechflow-cli/dst/speechflow-node-a2a-meter.js +232 -0
- package/speechflow-cli/dst/speechflow-node-a2a-meter.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-mute.d.ts +17 -0
- package/speechflow-cli/dst/speechflow-node-a2a-mute.js +117 -0
- package/speechflow-cli/dst/speechflow-node-a2a-mute.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-vad.d.ts +19 -0
- package/speechflow-cli/dst/speechflow-node-a2a-vad.js +374 -0
- package/speechflow-cli/dst/speechflow-node-a2a-vad.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2a-wav.d.ts +11 -0
- package/speechflow-cli/dst/speechflow-node-a2a-wav.js +211 -0
- package/speechflow-cli/dst/speechflow-node-a2a-wav.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-a2t-deepgram.d.ts +19 -0
- package/speechflow-cli/dst/speechflow-node-a2t-deepgram.js +328 -0
- package/speechflow-cli/dst/speechflow-node-a2t-deepgram.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2a-elevenlabs.d.ts +18 -0
- package/speechflow-cli/dst/speechflow-node-t2a-elevenlabs.js +238 -0
- package/speechflow-cli/dst/speechflow-node-t2a-elevenlabs.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2a-kokoro.d.ts +14 -0
- package/speechflow-cli/dst/speechflow-node-t2a-kokoro.js +155 -0
- package/speechflow-cli/dst/speechflow-node-t2a-kokoro.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2t-deepl.d.ts +15 -0
- package/speechflow-cli/dst/speechflow-node-t2t-deepl.js +146 -0
- package/speechflow-cli/dst/speechflow-node-t2t-deepl.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2t-format.d.ts +11 -0
- package/speechflow-cli/dst/speechflow-node-t2t-format.js +82 -0
- package/speechflow-cli/dst/speechflow-node-t2t-format.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2t-ollama.d.ts +13 -0
- package/speechflow-cli/dst/speechflow-node-t2t-ollama.js +247 -0
- package/speechflow-cli/dst/speechflow-node-t2t-ollama.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2t-openai.d.ts +13 -0
- package/speechflow-cli/dst/speechflow-node-t2t-openai.js +227 -0
- package/speechflow-cli/dst/speechflow-node-t2t-openai.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2t-sentence.d.ts +17 -0
- package/speechflow-cli/dst/speechflow-node-t2t-sentence.js +250 -0
- package/speechflow-cli/dst/speechflow-node-t2t-sentence.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2t-subtitle.d.ts +13 -0
- package/speechflow-cli/dst/speechflow-node-t2t-subtitle.js +278 -0
- package/speechflow-cli/dst/speechflow-node-t2t-subtitle.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-t2t-transformers.d.ts +14 -0
- package/speechflow-cli/dst/speechflow-node-t2t-transformers.js +265 -0
- package/speechflow-cli/dst/speechflow-node-t2t-transformers.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-x2x-filter.d.ts +11 -0
- package/speechflow-cli/dst/speechflow-node-x2x-filter.js +121 -0
- package/speechflow-cli/dst/speechflow-node-x2x-filter.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-x2x-trace.d.ts +11 -0
- package/speechflow-cli/dst/speechflow-node-x2x-trace.js +111 -0
- package/speechflow-cli/dst/speechflow-node-x2x-trace.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-xio-device.d.ts +13 -0
- package/speechflow-cli/dst/speechflow-node-xio-device.js +230 -0
- package/speechflow-cli/dst/speechflow-node-xio-device.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-xio-file.d.ts +11 -0
- package/speechflow-cli/dst/speechflow-node-xio-file.js +216 -0
- package/speechflow-cli/dst/speechflow-node-xio-file.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-xio-mqtt.d.ts +13 -0
- package/speechflow-cli/dst/speechflow-node-xio-mqtt.js +188 -0
- package/speechflow-cli/dst/speechflow-node-xio-mqtt.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node-xio-websocket.d.ts +13 -0
- package/speechflow-cli/dst/speechflow-node-xio-websocket.js +278 -0
- package/speechflow-cli/dst/speechflow-node-xio-websocket.js.map +1 -0
- package/speechflow-cli/dst/speechflow-node.d.ts +65 -0
- package/speechflow-cli/dst/speechflow-node.js +180 -0
- package/speechflow-cli/dst/speechflow-node.js.map +1 -0
- package/speechflow-cli/dst/speechflow-utils.d.ts +74 -0
- package/speechflow-cli/dst/speechflow-utils.js +519 -0
- package/speechflow-cli/dst/speechflow-utils.js.map +1 -0
- package/speechflow-cli/dst/speechflow.d.ts +7 -0
- package/speechflow-cli/dst/speechflow.js +837 -0
- package/speechflow-cli/dst/speechflow.js.map +1 -0
- package/speechflow-cli/package.json +1 -1
- package/speechflow-ui-db/dst/app-font-TypoPRO-SourceSansPro-Bold.eot +0 -0
- package/speechflow-ui-db/dst/app-font-TypoPRO-SourceSansPro-Bold.ttf +0 -0
- package/speechflow-ui-db/dst/app-font-TypoPRO-SourceSansPro-Bold.woff +0 -0
- package/speechflow-ui-db/dst/app-font-TypoPRO-SourceSansPro-Regular.eot +0 -0
- package/speechflow-ui-db/dst/app-font-TypoPRO-SourceSansPro-Regular.ttf +0 -0
- package/speechflow-ui-db/dst/app-font-TypoPRO-SourceSansPro-Regular.woff +0 -0
- package/speechflow-ui-db/dst/app-font-fa-brands-400.woff2 +0 -0
- package/speechflow-ui-db/dst/app-font-fa-regular-400.woff2 +0 -0
- package/speechflow-ui-db/dst/app-font-fa-solid-900.woff2 +0 -0
- package/speechflow-ui-db/dst/app-font-fa-v4compatibility.woff2 +0 -0
- package/speechflow-ui-db/dst/app-icon.svg +26 -0
- package/speechflow-ui-db/dst/index.css +5 -0
- package/speechflow-ui-db/dst/index.html +24 -0
- package/speechflow-ui-db/dst/index.js +616 -0
- package/speechflow-ui-st/dst/app-font-TypoPRO-SourceSansPro-Bold.eot +0 -0
- package/speechflow-ui-st/dst/app-font-TypoPRO-SourceSansPro-Bold.ttf +0 -0
- package/speechflow-ui-st/dst/app-font-TypoPRO-SourceSansPro-Bold.woff +0 -0
- package/speechflow-ui-st/dst/app-font-TypoPRO-SourceSansPro-Regular.eot +0 -0
- package/speechflow-ui-st/dst/app-font-TypoPRO-SourceSansPro-Regular.ttf +0 -0
- package/speechflow-ui-st/dst/app-font-TypoPRO-SourceSansPro-Regular.woff +0 -0
- package/speechflow-ui-st/dst/app-font-fa-brands-400.woff2 +0 -0
- package/speechflow-ui-st/dst/app-font-fa-regular-400.woff2 +0 -0
- package/speechflow-ui-st/dst/app-font-fa-solid-900.woff2 +0 -0
- package/speechflow-ui-st/dst/app-font-fa-v4compatibility.woff2 +0 -0
- package/speechflow-ui-st/dst/app-icon.svg +26 -0
- package/speechflow-ui-st/dst/index.css +5 -0
- package/speechflow-ui-st/dst/index.html +24 -0
- package/speechflow-ui-st/dst/index.js +610 -0
|
@@ -0,0 +1,328 @@
|
|
|
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_stream_1 = __importDefault(require("node:stream"));
|
|
46
|
+
/* external dependencies */
|
|
47
|
+
const Deepgram = __importStar(require("@deepgram/sdk"));
|
|
48
|
+
const luxon_1 = require("luxon");
|
|
49
|
+
/* internal dependencies */
|
|
50
|
+
const speechflow_node_1 = __importStar(require("./speechflow-node"));
|
|
51
|
+
const utils = __importStar(require("./speechflow-utils"));
|
|
52
|
+
/* SpeechFlow node for Deepgram speech-to-text conversion */
|
|
53
|
+
class SpeechFlowNodeDeepgram extends speechflow_node_1.default {
|
|
54
|
+
/* declare official node name */
|
|
55
|
+
static name = "deepgram";
|
|
56
|
+
/* internal state */
|
|
57
|
+
dg = null;
|
|
58
|
+
destroyed = false;
|
|
59
|
+
initTimeout = null;
|
|
60
|
+
connectionTimeout = null;
|
|
61
|
+
queue = null;
|
|
62
|
+
/* construct node */
|
|
63
|
+
constructor(id, cfg, opts, args) {
|
|
64
|
+
super(id, cfg, opts, args);
|
|
65
|
+
/* declare node configuration parameters */
|
|
66
|
+
this.configure({
|
|
67
|
+
key: { type: "string", val: process.env.SPEECHFLOW_DEEPGRAM_KEY },
|
|
68
|
+
keyAdm: { type: "string", val: process.env.SPEECHFLOW_DEEPGRAM_KEY_ADM },
|
|
69
|
+
model: { type: "string", val: "nova-2", pos: 0 },
|
|
70
|
+
version: { type: "string", val: "latest", pos: 1 },
|
|
71
|
+
language: { type: "string", val: "multi", pos: 2 },
|
|
72
|
+
interim: { type: "boolean", val: false, pos: 3 }
|
|
73
|
+
});
|
|
74
|
+
/* declare node input/output format */
|
|
75
|
+
this.input = "audio";
|
|
76
|
+
this.output = "text";
|
|
77
|
+
}
|
|
78
|
+
/* one-time status of node */
|
|
79
|
+
async status() {
|
|
80
|
+
let balance = 0;
|
|
81
|
+
try {
|
|
82
|
+
const deepgram = Deepgram.createClient(this.params.keyAdm);
|
|
83
|
+
const response = await deepgram.manage.getProjects();
|
|
84
|
+
if (response !== null && response.error === null) {
|
|
85
|
+
for (const project of response.result.projects) {
|
|
86
|
+
const response = await deepgram.manage.getProjectBalances(project.project_id);
|
|
87
|
+
if (response !== null && response.error === null)
|
|
88
|
+
balance += response.result.balances[0]?.amount ?? 0;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
this.log("warning", `failed to fetch balance: ${error}`);
|
|
94
|
+
}
|
|
95
|
+
return { balance: balance.toFixed(2) };
|
|
96
|
+
}
|
|
97
|
+
/* open node */
|
|
98
|
+
async open() {
|
|
99
|
+
/* sanity check situation */
|
|
100
|
+
if (this.config.audioBitDepth !== 16 || !this.config.audioLittleEndian)
|
|
101
|
+
throw new Error("Deepgram node currently supports PCM-S16LE audio only");
|
|
102
|
+
/* clear destruction flag */
|
|
103
|
+
this.destroyed = false;
|
|
104
|
+
/* create queue for results */
|
|
105
|
+
this.queue = new utils.SingleQueue();
|
|
106
|
+
/* create a store for the meta information */
|
|
107
|
+
const metastore = new utils.TimeStore();
|
|
108
|
+
/* connect to Deepgram API */
|
|
109
|
+
const deepgram = Deepgram.createClient(this.params.key);
|
|
110
|
+
let language = "en";
|
|
111
|
+
if (this.params.model.match(/^nova-2/) && this.params.language !== "en")
|
|
112
|
+
language = this.params.language;
|
|
113
|
+
else if (this.params.model.match(/^nova-3/) && this.params.language !== "en")
|
|
114
|
+
language = "multi";
|
|
115
|
+
this.dg = deepgram.listen.live({
|
|
116
|
+
mip_opt_out: true,
|
|
117
|
+
model: this.params.model,
|
|
118
|
+
version: this.params.version,
|
|
119
|
+
language,
|
|
120
|
+
channels: this.config.audioChannels,
|
|
121
|
+
sample_rate: this.config.audioSampleRate,
|
|
122
|
+
encoding: "linear16",
|
|
123
|
+
multichannel: false,
|
|
124
|
+
endpointing: false,
|
|
125
|
+
interim_results: this.params.interim,
|
|
126
|
+
smart_format: true,
|
|
127
|
+
punctuate: true,
|
|
128
|
+
filler_words: true,
|
|
129
|
+
numerals: true,
|
|
130
|
+
diarize: false,
|
|
131
|
+
profanity_filter: false,
|
|
132
|
+
redact: false
|
|
133
|
+
});
|
|
134
|
+
/* hook onto Deepgram API events */
|
|
135
|
+
this.dg.on(Deepgram.LiveTranscriptionEvents.Transcript, async (data) => {
|
|
136
|
+
if (this.destroyed || this.queue === null)
|
|
137
|
+
return;
|
|
138
|
+
const text = (data.channel?.alternatives[0]?.transcript ?? "");
|
|
139
|
+
const words = (data.channel?.alternatives[0]?.words ?? []);
|
|
140
|
+
const isFinal = (data.is_final ?? false);
|
|
141
|
+
if (text === "")
|
|
142
|
+
this.log("info", `empty/dummy text received (start: ${data.start}s, duration: ${data.duration.toFixed(2)}s)`);
|
|
143
|
+
else {
|
|
144
|
+
this.log("info", `text received (start: ${data.start}s, duration: ${data.duration.toFixed(2)}s): "${text}"`);
|
|
145
|
+
const start = luxon_1.Duration.fromMillis(data.start * 1000).plus(this.timeZeroOffset);
|
|
146
|
+
const end = start.plus({ seconds: data.duration });
|
|
147
|
+
const metas = metastore.fetch(start, end);
|
|
148
|
+
const meta = metas.reduce((prev, curr) => {
|
|
149
|
+
curr.forEach((val, key) => { prev.set(key, val); });
|
|
150
|
+
return prev;
|
|
151
|
+
}, new Map());
|
|
152
|
+
metastore.prune(start);
|
|
153
|
+
meta.set("words", words.map((word) => {
|
|
154
|
+
const start = luxon_1.Duration.fromMillis(word.start * 1000).plus(this.timeZeroOffset);
|
|
155
|
+
const end = luxon_1.Duration.fromMillis(word.end * 1000).plus(this.timeZeroOffset);
|
|
156
|
+
return { word: word.punctuated_word ?? word.word, start, end };
|
|
157
|
+
}));
|
|
158
|
+
const chunk = new speechflow_node_1.SpeechFlowChunk(start, end, isFinal ? "final" : "intermediate", "text", text, meta);
|
|
159
|
+
this.queue.write(chunk);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
this.dg.on(Deepgram.LiveTranscriptionEvents.SpeechStarted, (data) => {
|
|
163
|
+
this.log("info", "speech started", data);
|
|
164
|
+
});
|
|
165
|
+
this.dg.on(Deepgram.LiveTranscriptionEvents.UtteranceEnd, (data) => {
|
|
166
|
+
this.log("info", "utterance end received", data);
|
|
167
|
+
});
|
|
168
|
+
this.dg.on(Deepgram.LiveTranscriptionEvents.Metadata, (data) => {
|
|
169
|
+
this.log("info", "metadata received");
|
|
170
|
+
});
|
|
171
|
+
this.dg.on(Deepgram.LiveTranscriptionEvents.Close, () => {
|
|
172
|
+
this.log("info", "connection close");
|
|
173
|
+
if (!this.destroyed && this.queue !== null)
|
|
174
|
+
this.queue.write(null);
|
|
175
|
+
});
|
|
176
|
+
this.dg.on(Deepgram.LiveTranscriptionEvents.Error, (error) => {
|
|
177
|
+
this.log("error", `error: ${error.message}`);
|
|
178
|
+
if (!this.destroyed && this.queue !== null)
|
|
179
|
+
this.queue.write(null);
|
|
180
|
+
this.emit("error");
|
|
181
|
+
});
|
|
182
|
+
/* wait for Deepgram API to be available */
|
|
183
|
+
await new Promise((resolve, reject) => {
|
|
184
|
+
this.connectionTimeout = setTimeout(() => {
|
|
185
|
+
if (this.connectionTimeout !== null) {
|
|
186
|
+
this.connectionTimeout = null;
|
|
187
|
+
reject(new Error("Deepgram: timeout waiting for connection open"));
|
|
188
|
+
}
|
|
189
|
+
}, 8000);
|
|
190
|
+
this.dg.once(Deepgram.LiveTranscriptionEvents.Open, () => {
|
|
191
|
+
this.log("info", "connection open");
|
|
192
|
+
if (this.connectionTimeout !== null) {
|
|
193
|
+
clearTimeout(this.connectionTimeout);
|
|
194
|
+
this.connectionTimeout = null;
|
|
195
|
+
}
|
|
196
|
+
resolve(true);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
/* remember opening time to receive time zero offset */
|
|
200
|
+
this.timeOpen = luxon_1.DateTime.now();
|
|
201
|
+
/* provide Duplex stream and internally attach to Deepgram API */
|
|
202
|
+
const self = this;
|
|
203
|
+
this.stream = new node_stream_1.default.Duplex({
|
|
204
|
+
writableObjectMode: true,
|
|
205
|
+
readableObjectMode: true,
|
|
206
|
+
decodeStrings: false,
|
|
207
|
+
highWaterMark: 1,
|
|
208
|
+
write(chunk, encoding, callback) {
|
|
209
|
+
if (self.destroyed || self.dg === null) {
|
|
210
|
+
callback(new Error("stream already destroyed"));
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (chunk.type !== "audio")
|
|
214
|
+
callback(new Error("expected audio input chunk"));
|
|
215
|
+
else if (!Buffer.isBuffer(chunk.payload))
|
|
216
|
+
callback(new Error("expected Buffer input chunk"));
|
|
217
|
+
else {
|
|
218
|
+
if (chunk.payload.byteLength > 0) {
|
|
219
|
+
self.log("debug", `send data (${chunk.payload.byteLength} bytes)`);
|
|
220
|
+
if (chunk.meta.size > 0)
|
|
221
|
+
metastore.store(chunk.timestampStart, chunk.timestampEnd, chunk.meta);
|
|
222
|
+
try {
|
|
223
|
+
self.dg.send(chunk.payload.buffer); /* intentionally discard all time information */
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
callback(error instanceof Error ? error : new Error("failed to send to Deepgram"));
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
callback();
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
read(size) {
|
|
234
|
+
if (self.destroyed || self.queue === null) {
|
|
235
|
+
this.push(null);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
let readTimeout = setTimeout(() => {
|
|
239
|
+
if (readTimeout !== null) {
|
|
240
|
+
readTimeout = null;
|
|
241
|
+
if (!self.destroyed) {
|
|
242
|
+
self.log("warning", "read timeout - pushing null to prevent hanging");
|
|
243
|
+
this.push(null);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}, 30 * 1000);
|
|
247
|
+
self.queue.read().then((chunk) => {
|
|
248
|
+
if (readTimeout !== null) {
|
|
249
|
+
clearTimeout(readTimeout);
|
|
250
|
+
readTimeout = null;
|
|
251
|
+
}
|
|
252
|
+
if (self.destroyed) {
|
|
253
|
+
this.push(null);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
if (chunk === null) {
|
|
257
|
+
self.log("info", "received EOF signal");
|
|
258
|
+
this.push(null);
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
self.log("debug", `received data (${chunk.payload.length} bytes)`);
|
|
262
|
+
this.push(chunk, self.config.textEncoding);
|
|
263
|
+
}
|
|
264
|
+
}).catch((error) => {
|
|
265
|
+
if (readTimeout !== null) {
|
|
266
|
+
clearTimeout(readTimeout);
|
|
267
|
+
readTimeout = null;
|
|
268
|
+
}
|
|
269
|
+
if (!self.destroyed) {
|
|
270
|
+
self.log("error", `queue read error: ${error.message}`);
|
|
271
|
+
this.push(null);
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
},
|
|
275
|
+
final(callback) {
|
|
276
|
+
if (self.destroyed || self.dg === null) {
|
|
277
|
+
callback();
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
try {
|
|
281
|
+
self.dg.requestClose();
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
self.log("warning", `error closing Deepgram connection: ${error}`);
|
|
285
|
+
}
|
|
286
|
+
/* NOTICE: do not push null here -- let the Deepgram close event handle it */
|
|
287
|
+
callback();
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
/* close node */
|
|
292
|
+
async close() {
|
|
293
|
+
/* indicate destruction first to stop all async operations */
|
|
294
|
+
this.destroyed = true;
|
|
295
|
+
/* cleanup all timers */
|
|
296
|
+
if (this.initTimeout !== null) {
|
|
297
|
+
clearTimeout(this.initTimeout);
|
|
298
|
+
this.initTimeout = null;
|
|
299
|
+
}
|
|
300
|
+
if (this.connectionTimeout !== null) {
|
|
301
|
+
clearTimeout(this.connectionTimeout);
|
|
302
|
+
this.connectionTimeout = null;
|
|
303
|
+
}
|
|
304
|
+
/* close stream */
|
|
305
|
+
if (this.stream !== null) {
|
|
306
|
+
this.stream.destroy();
|
|
307
|
+
this.stream = null;
|
|
308
|
+
}
|
|
309
|
+
/* close Deepgram connection and remove listeners */
|
|
310
|
+
if (this.dg !== null) {
|
|
311
|
+
try {
|
|
312
|
+
this.dg.removeAllListeners();
|
|
313
|
+
this.dg.requestClose();
|
|
314
|
+
}
|
|
315
|
+
catch (error) {
|
|
316
|
+
this.log("warning", `error during Deepgram cleanup: ${error}`);
|
|
317
|
+
}
|
|
318
|
+
this.dg = null;
|
|
319
|
+
}
|
|
320
|
+
/* signal EOF to any pending read operations */
|
|
321
|
+
if (this.queue !== null) {
|
|
322
|
+
this.queue.write(null);
|
|
323
|
+
this.queue = null;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
exports.default = SpeechFlowNodeDeepgram;
|
|
328
|
+
//# sourceMappingURL=speechflow-node-a2t-deepgram.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"speechflow-node-a2t-deepgram.js","sourceRoot":"","sources":["../src/speechflow-node-a2t-deepgram.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,6BAA6B;AAC7B,8DAAgC;AAEhC,6BAA6B;AAC7B,wDAAkD;AAClD,iCAA0C;AAE1C,6BAA6B;AAC7B,qEAAmE;AACnE,0DAAoE;AAEpE,8DAA8D;AAC9D,MAAqB,sBAAuB,SAAQ,yBAAc;IAC9D,kCAAkC;IAC3B,MAAM,CAAC,IAAI,GAAG,UAAU,CAAA;IAE/B,sBAAsB;IACd,EAAE,GAAoE,IAAI,CAAA;IAC1E,SAAS,GAA6D,KAAK,CAAA;IAC3E,WAAW,GAA2D,IAAI,CAAA;IAC1E,iBAAiB,GAAqD,IAAI,CAAA;IAC1E,KAAK,GAAiE,IAAI,CAAA;IAElF,sBAAsB;IACtB,YAAa,EAAU,EAAE,GAA4B,EAAE,IAA6B,EAAE,IAAW;QAC7F,KAAK,CA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A;YACtB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACrB,CAAC;IACL,CAAC;;AArSL,yCAsSC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import SpeechFlowNode from "./speechflow-node";
|
|
2
|
+
export default class SpeechFlowNodeElevenlabs extends SpeechFlowNode {
|
|
3
|
+
static name: string;
|
|
4
|
+
private elevenlabs;
|
|
5
|
+
private static speexInitialized;
|
|
6
|
+
private destroyed;
|
|
7
|
+
private resampler;
|
|
8
|
+
constructor(id: string, cfg: {
|
|
9
|
+
[id: string]: any;
|
|
10
|
+
}, opts: {
|
|
11
|
+
[id: string]: any;
|
|
12
|
+
}, args: any[]);
|
|
13
|
+
status(): Promise<{
|
|
14
|
+
usage: string;
|
|
15
|
+
}>;
|
|
16
|
+
open(): Promise<void>;
|
|
17
|
+
close(): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
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_stream_1 = __importDefault(require("node:stream"));
|
|
46
|
+
/* external dependencies */
|
|
47
|
+
const ElevenLabs = __importStar(require("@elevenlabs/elevenlabs-js"));
|
|
48
|
+
const get_stream_1 = require("get-stream");
|
|
49
|
+
const speex_resampler_1 = __importDefault(require("speex-resampler"));
|
|
50
|
+
/* internal dependencies */
|
|
51
|
+
const speechflow_node_1 = __importDefault(require("./speechflow-node"));
|
|
52
|
+
/* SpeechFlow node for Elevenlabs text-to-speech conversion */
|
|
53
|
+
class SpeechFlowNodeElevenlabs extends speechflow_node_1.default {
|
|
54
|
+
/* declare official node name */
|
|
55
|
+
static name = "elevenlabs";
|
|
56
|
+
/* internal state */
|
|
57
|
+
elevenlabs = null;
|
|
58
|
+
static speexInitialized = false;
|
|
59
|
+
destroyed = false;
|
|
60
|
+
resampler = null;
|
|
61
|
+
/* construct node */
|
|
62
|
+
constructor(id, cfg, opts, args) {
|
|
63
|
+
super(id, cfg, opts, args);
|
|
64
|
+
/* declare node configuration parameters */
|
|
65
|
+
this.configure({
|
|
66
|
+
key: { type: "string", val: process.env.SPEECHFLOW_ELEVENLABS_KEY },
|
|
67
|
+
voice: { type: "string", val: "Brian", pos: 0, match: /^(?:Brittney|Cassidy|Leonie|Mark|Brian)$/ },
|
|
68
|
+
language: { type: "string", val: "en", pos: 1, match: /^(?:de|en)$/ },
|
|
69
|
+
speed: { type: "number", val: 1.00, pos: 2, match: (n) => n >= 0.7 && n <= 1.2 },
|
|
70
|
+
stability: { type: "number", val: 0.5, pos: 3, match: (n) => n >= 0.0 && n <= 1.0 },
|
|
71
|
+
similarity: { type: "number", val: 0.75, pos: 4, match: (n) => n >= 0.0 && n <= 1.0 },
|
|
72
|
+
optimize: { type: "string", val: "latency", pos: 5, match: /^(?:latency|quality)$/ }
|
|
73
|
+
});
|
|
74
|
+
/* sanity check parameters */
|
|
75
|
+
if (!this.params.key)
|
|
76
|
+
throw new Error("ElevenLabs API key not configured");
|
|
77
|
+
/* declare node input/output format */
|
|
78
|
+
this.input = "text";
|
|
79
|
+
this.output = "audio";
|
|
80
|
+
}
|
|
81
|
+
/* one-time status of node */
|
|
82
|
+
async status() {
|
|
83
|
+
const elevenlabs = new ElevenLabs.ElevenLabsClient({ apiKey: this.params.key });
|
|
84
|
+
const subscription = await elevenlabs.user.subscription.get();
|
|
85
|
+
const percent = subscription.characterCount / subscription.characterLimit;
|
|
86
|
+
return { usage: `${percent.toFixed(2)}%` };
|
|
87
|
+
}
|
|
88
|
+
/* open node */
|
|
89
|
+
async open() {
|
|
90
|
+
/* clear destruction flag */
|
|
91
|
+
this.destroyed = false;
|
|
92
|
+
/* establish ElevenLabs API connection */
|
|
93
|
+
this.elevenlabs = new ElevenLabs.ElevenLabsClient({
|
|
94
|
+
apiKey: this.params.key
|
|
95
|
+
});
|
|
96
|
+
/* determine maximum sample rate of ElevenLabs tier */
|
|
97
|
+
const maxSampleRates = {
|
|
98
|
+
"free": 16000,
|
|
99
|
+
"starter": 22050,
|
|
100
|
+
"creator": 24000,
|
|
101
|
+
"independent_publisher": 44100,
|
|
102
|
+
"growing_business": 44100,
|
|
103
|
+
"enterprise": 44100
|
|
104
|
+
};
|
|
105
|
+
const sub = await this.elevenlabs.user.subscription.get();
|
|
106
|
+
const tier = (sub.tier ?? "free");
|
|
107
|
+
this.log("info", `determined ElevenLabs tier: "${tier}"`);
|
|
108
|
+
let maxSampleRate = 16000;
|
|
109
|
+
if (maxSampleRates[tier] !== undefined)
|
|
110
|
+
maxSampleRate = maxSampleRates[tier];
|
|
111
|
+
this.log("info", `determined maximum audio sample rate: ${maxSampleRate}`);
|
|
112
|
+
/* determine voice for text-to-speech operation
|
|
113
|
+
(for details see https://elevenlabs.io/text-to-speech) */
|
|
114
|
+
const voices = await this.elevenlabs.voices.getAll();
|
|
115
|
+
let voice = voices.voices.find((voice) => voice.name === this.params.voice);
|
|
116
|
+
if (voice === undefined) {
|
|
117
|
+
voice = voices.voices.find((voice) => voice.name.startsWith(this.params.voice));
|
|
118
|
+
if (voice === undefined)
|
|
119
|
+
throw new Error(`invalid ElevenLabs voice "${this.params.voice}"`);
|
|
120
|
+
}
|
|
121
|
+
const info = Object.keys(voice.labels ?? {}).length > 0 ?
|
|
122
|
+
(", " + Object.entries(voice.labels)
|
|
123
|
+
.map(([key, val]) => `${key}: "${val}"`).join(", ")) : "";
|
|
124
|
+
this.log("info", `selected voice: name: "${voice.name}"${info}`);
|
|
125
|
+
/* perform text-to-speech operation with Elevenlabs API */
|
|
126
|
+
const model = this.params.optimize === "quality" ?
|
|
127
|
+
"eleven_turbo_v2_5" :
|
|
128
|
+
"eleven_flash_v2_5";
|
|
129
|
+
const speechStream = (text) => {
|
|
130
|
+
this.log("info", `ElevenLabs: send text "${text}"`);
|
|
131
|
+
return this.elevenlabs.textToSpeech.convert(voice.voiceId, {
|
|
132
|
+
text,
|
|
133
|
+
modelId: model,
|
|
134
|
+
languageCode: this.params.language,
|
|
135
|
+
outputFormat: `pcm_${maxSampleRate}`,
|
|
136
|
+
seed: 815, /* arbitrary, but fixated by us */
|
|
137
|
+
voiceSettings: {
|
|
138
|
+
speed: this.params.speed,
|
|
139
|
+
stability: this.params.stability,
|
|
140
|
+
similarityBoost: this.params.similarity
|
|
141
|
+
}
|
|
142
|
+
}, {
|
|
143
|
+
timeoutInSeconds: 30,
|
|
144
|
+
maxRetries: 10
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
/* establish resampler from ElevenLabs's maximum 24Khz
|
|
148
|
+
output to our standard audio sample rate (48KHz) */
|
|
149
|
+
if (!SpeechFlowNodeElevenlabs.speexInitialized) {
|
|
150
|
+
/* at least once initialize resampler */
|
|
151
|
+
await speex_resampler_1.default.initPromise;
|
|
152
|
+
SpeechFlowNodeElevenlabs.speexInitialized = true;
|
|
153
|
+
}
|
|
154
|
+
this.resampler = new speex_resampler_1.default(1, maxSampleRate, this.config.audioSampleRate, 7);
|
|
155
|
+
/* create transform stream and connect it to the ElevenLabs API */
|
|
156
|
+
const self = this;
|
|
157
|
+
this.stream = new node_stream_1.default.Transform({
|
|
158
|
+
writableObjectMode: true,
|
|
159
|
+
readableObjectMode: true,
|
|
160
|
+
decodeStrings: false,
|
|
161
|
+
highWaterMark: 1,
|
|
162
|
+
transform(chunk, encoding, callback) {
|
|
163
|
+
if (self.destroyed) {
|
|
164
|
+
callback(new Error("stream already destroyed"));
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (Buffer.isBuffer(chunk.payload))
|
|
168
|
+
callback(new Error("invalid chunk payload type"));
|
|
169
|
+
else {
|
|
170
|
+
(async () => {
|
|
171
|
+
let processTimeout = setTimeout(() => {
|
|
172
|
+
processTimeout = null;
|
|
173
|
+
callback(new Error("ElevenLabs API timeout"));
|
|
174
|
+
}, 60 * 1000);
|
|
175
|
+
const clearProcessTimeout = () => {
|
|
176
|
+
if (processTimeout !== null) {
|
|
177
|
+
clearTimeout(processTimeout);
|
|
178
|
+
processTimeout = null;
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
try {
|
|
182
|
+
const stream = await speechStream(chunk.payload);
|
|
183
|
+
if (self.destroyed) {
|
|
184
|
+
clearProcessTimeout();
|
|
185
|
+
callback(new Error("stream destroyed during processing"));
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const buffer = await (0, get_stream_1.getStreamAsBuffer)(stream);
|
|
189
|
+
if (self.destroyed) {
|
|
190
|
+
clearProcessTimeout();
|
|
191
|
+
callback(new Error("stream destroyed during processing"));
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const bufferResampled = self.resampler.processChunk(buffer);
|
|
195
|
+
self.log("info", `ElevenLabs: received audio (buffer length: ${buffer.byteLength})`);
|
|
196
|
+
const chunkNew = chunk.clone();
|
|
197
|
+
chunkNew.type = "audio";
|
|
198
|
+
chunkNew.payload = bufferResampled;
|
|
199
|
+
clearProcessTimeout();
|
|
200
|
+
this.push(chunkNew);
|
|
201
|
+
callback();
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
clearProcessTimeout();
|
|
205
|
+
callback(error instanceof Error ? error : new Error("ElevenLabs processing failed"));
|
|
206
|
+
}
|
|
207
|
+
})();
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
final(callback) {
|
|
211
|
+
if (self.destroyed) {
|
|
212
|
+
callback();
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
this.push(null);
|
|
216
|
+
callback();
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
/* close node */
|
|
221
|
+
async close() {
|
|
222
|
+
/* indicate destruction */
|
|
223
|
+
this.destroyed = true;
|
|
224
|
+
/* destroy stream */
|
|
225
|
+
if (this.stream !== null) {
|
|
226
|
+
this.stream.destroy();
|
|
227
|
+
this.stream = null;
|
|
228
|
+
}
|
|
229
|
+
/* destroy resampler */
|
|
230
|
+
if (this.resampler !== null)
|
|
231
|
+
this.resampler = null;
|
|
232
|
+
/* destroy ElevenLabs API */
|
|
233
|
+
if (this.elevenlabs !== null)
|
|
234
|
+
this.elevenlabs = null;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
exports.default = SpeechFlowNodeElevenlabs;
|
|
238
|
+
//# sourceMappingURL=speechflow-node-t2a-elevenlabs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"speechflow-node-t2a-elevenlabs.js","sourceRoot":"","sources":["../src/speechflow-node-t2a-elevenlabs.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,6BAA6B;AAC7B,8DAAgC;AAEhC,6BAA6B;AAC7B,sEAA6D;AAC7D,2CAA8C;AAC9C,sEAAmD;AAEnD,6BAA6B;AAC7B,wEAAmE;AAEnE,gEAAgE;AAChE,MAAqB,wBAAyB,SAAQ,yBAAc;IAChE,kCAAkC;IAC3B,MAAM,CAAC,IAAI,GAAG,YAAY,CAAA;IAEjC,sBAAsB;IACd,UAAU,GAAuC,IAAI,CAAA;IACrD,MAAM,CAAC,gBAAgB,GAAG,KAAK,CAAA;IAC/B,SAAS,GAAG,KAAK,CAAA;IACjB,SAAS,GAA0B,IAAI,CAAA;IAE/C,sBAAsB;IACtB,YAAa,EAAU,EAAE,GAA4B,EAAE,IAA6B,EAAE,IAAW;QAC7F,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;QAE1B,6CAA6C;QAC7C,IAAI,CAAC,SAAS,CAAC;YACX,GAAG,EAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB,EAAE;YAC1E,KAAK,E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IAAI,CAAC,UAAU,KAAK,IAAI;YACxB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAA;IAC9B,CAAC;;AAvML,2CAwMC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import SpeechFlowNode from "./speechflow-node";
|
|
2
|
+
export default class SpeechFlowNodeKokoro extends SpeechFlowNode {
|
|
3
|
+
static name: string;
|
|
4
|
+
private kokoro;
|
|
5
|
+
private resampler;
|
|
6
|
+
private static speexInitialized;
|
|
7
|
+
constructor(id: string, cfg: {
|
|
8
|
+
[id: string]: any;
|
|
9
|
+
}, opts: {
|
|
10
|
+
[id: string]: any;
|
|
11
|
+
}, args: any[]);
|
|
12
|
+
open(): Promise<void>;
|
|
13
|
+
close(): Promise<void>;
|
|
14
|
+
}
|