speechflow 2.0.1 → 2.0.3
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 +15 -0
- package/etc/claude.md +1 -1
- package/package.json +4 -4
- package/speechflow-cli/dst/speechflow-main-api.js.map +1 -1
- package/speechflow-cli/dst/speechflow-main-graph.js +4 -4
- package/speechflow-cli/dst/speechflow-main-graph.js.map +1 -1
- package/speechflow-cli/dst/speechflow-main.js +1 -1
- package/speechflow-cli/dst/speechflow-main.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-compressor.js +6 -6
- package/speechflow-cli/dst/speechflow-node-a2a-compressor.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-filler.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-mute.js +2 -2
- package/speechflow-cli/dst/speechflow-node-a2a-mute.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-rnnoise.js +1 -1
- package/speechflow-cli/dst/speechflow-node-a2t-amazon.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2t-google.js +8 -8
- package/speechflow-cli/dst/speechflow-node-a2t-google.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2a-elevenlabs.js +9 -9
- package/speechflow-cli/dst/speechflow-node-t2a-elevenlabs.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2a-google.js +3 -3
- package/speechflow-cli/dst/speechflow-node-t2a-google.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2a-supertonic.d.ts +2 -3
- package/speechflow-cli/dst/speechflow-node-t2a-supertonic.js +93 -466
- package/speechflow-cli/dst/speechflow-node-t2a-supertonic.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-amazon.js +4 -4
- package/speechflow-cli/dst/speechflow-node-t2t-amazon.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-deepl.js +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-deepl.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-format.js +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-format.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-google.js +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-google.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-modify.js +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-modify.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-opus.js +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-opus.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-punctuation.js +1 -2
- package/speechflow-cli/dst/speechflow-node-t2t-punctuation.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-spellcheck.js +1 -2
- package/speechflow-cli/dst/speechflow-node-t2t-spellcheck.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-summary.js +3 -4
- package/speechflow-cli/dst/speechflow-node-t2t-summary.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-translate.js +1 -2
- package/speechflow-cli/dst/speechflow-node-t2t-translate.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-x2x-filter.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-xio-exec.js +2 -2
- package/speechflow-cli/dst/speechflow-node-xio-exec.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-xio-file.js +2 -2
- package/speechflow-cli/dst/speechflow-node-xio-file.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-xio-vban.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-xio-webrtc.js +1 -1
- package/speechflow-cli/dst/speechflow-util-audio.d.ts +1 -0
- package/speechflow-cli/dst/speechflow-util-audio.js +10 -3
- package/speechflow-cli/dst/speechflow-util-audio.js.map +1 -1
- package/speechflow-cli/dst/speechflow-util-llm.d.ts +0 -1
- package/speechflow-cli/dst/speechflow-util-llm.js +4 -8
- package/speechflow-cli/dst/speechflow-util-llm.js.map +1 -1
- package/speechflow-cli/dst/speechflow-util-queue.js.map +1 -1
- package/speechflow-cli/dst/speechflow-util-stream.js +4 -5
- package/speechflow-cli/dst/speechflow-util-stream.js.map +1 -1
- package/speechflow-cli/etc/eslint.mjs +1 -3
- package/speechflow-cli/etc/oxlint.jsonc +4 -1
- package/speechflow-cli/etc/stx.conf +0 -1
- package/speechflow-cli/package.json +16 -19
- package/speechflow-cli/src/lib.d.ts +5 -1
- package/speechflow-cli/src/speechflow-main-api.ts +4 -4
- package/speechflow-cli/src/speechflow-main-cli.ts +1 -1
- package/speechflow-cli/src/speechflow-main-graph.ts +16 -16
- package/speechflow-cli/src/speechflow-main-nodes.ts +1 -1
- package/speechflow-cli/src/speechflow-main-status.ts +2 -2
- package/speechflow-cli/src/speechflow-main.ts +1 -1
- package/speechflow-cli/src/speechflow-node-a2a-compressor-wt.ts +3 -3
- package/speechflow-cli/src/speechflow-node-a2a-compressor.ts +6 -6
- package/speechflow-cli/src/speechflow-node-a2a-expander-wt.ts +2 -2
- package/speechflow-cli/src/speechflow-node-a2a-filler.ts +4 -4
- package/speechflow-cli/src/speechflow-node-a2a-gender.ts +1 -1
- package/speechflow-cli/src/speechflow-node-a2a-mute.ts +2 -2
- package/speechflow-cli/src/speechflow-node-a2a-pitch.ts +1 -1
- package/speechflow-cli/src/speechflow-node-a2a-rnnoise-wt.ts +2 -2
- package/speechflow-cli/src/speechflow-node-a2a-rnnoise.ts +1 -1
- package/speechflow-cli/src/speechflow-node-a2t-amazon.ts +2 -2
- package/speechflow-cli/src/speechflow-node-a2t-google.ts +8 -8
- package/speechflow-cli/src/speechflow-node-t2a-elevenlabs.ts +9 -9
- package/speechflow-cli/src/speechflow-node-t2a-google.ts +3 -3
- package/speechflow-cli/src/speechflow-node-t2a-supertonic.ts +103 -577
- package/speechflow-cli/src/speechflow-node-t2t-amazon.ts +4 -4
- package/speechflow-cli/src/speechflow-node-t2t-deepl.ts +1 -1
- package/speechflow-cli/src/speechflow-node-t2t-format.ts +1 -1
- package/speechflow-cli/src/speechflow-node-t2t-google.ts +2 -2
- package/speechflow-cli/src/speechflow-node-t2t-modify.ts +2 -2
- package/speechflow-cli/src/speechflow-node-t2t-opus.ts +1 -1
- package/speechflow-cli/src/speechflow-node-t2t-punctuation.ts +1 -2
- package/speechflow-cli/src/speechflow-node-t2t-spellcheck.ts +1 -2
- package/speechflow-cli/src/speechflow-node-t2t-subtitle.ts +2 -2
- package/speechflow-cli/src/speechflow-node-t2t-summary.ts +3 -4
- package/speechflow-cli/src/speechflow-node-t2t-translate.ts +1 -2
- package/speechflow-cli/src/speechflow-node-x2x-filter.ts +4 -4
- package/speechflow-cli/src/speechflow-node-xio-exec.ts +2 -2
- package/speechflow-cli/src/speechflow-node-xio-file.ts +2 -2
- package/speechflow-cli/src/speechflow-node-xio-vban.ts +4 -2
- package/speechflow-cli/src/speechflow-node-xio-webrtc.ts +1 -1
- package/speechflow-cli/src/speechflow-util-audio.ts +11 -3
- package/speechflow-cli/src/speechflow-util-llm.ts +4 -9
- package/speechflow-cli/src/speechflow-util-queue.ts +1 -1
- package/speechflow-cli/src/speechflow-util-stream.ts +4 -5
- package/speechflow-ui-db/dst/index.js +13 -13
- package/speechflow-ui-db/etc/oxlint.jsonc +137 -0
- package/speechflow-ui-db/etc/stx.conf +4 -3
- package/speechflow-ui-db/package.json +9 -6
- package/speechflow-ui-st/dst/index.js +27 -27
- package/speechflow-ui-st/etc/oxlint.jsonc +137 -0
- package/speechflow-ui-st/etc/stx.conf +4 -3
- package/speechflow-ui-st/package.json +9 -6
- package/speechflow-cli/etc/biome.jsonc +0 -46
- package/speechflow-ui-db/src/lib.d.ts +0 -9
- package/speechflow-ui-st/src/lib.d.ts +0 -9
|
@@ -91,9 +91,9 @@ export default class SpeechFlowNodeT2TAmazon extends SpeechFlowNode {
|
|
|
91
91
|
|
|
92
92
|
/* simple backoff for transient errors */
|
|
93
93
|
const retriable =
|
|
94
|
-
e?.name === "ThrottlingException"
|
|
95
|
-
e?.name === "ServiceUnavailableException"
|
|
96
|
-
e?.$retryable === true
|
|
94
|
+
e?.name === "ThrottlingException"
|
|
95
|
+
|| e?.name === "ServiceUnavailableException"
|
|
96
|
+
|| e?.$retryable === true
|
|
97
97
|
if (!retriable || attempt >= maxRetries)
|
|
98
98
|
break
|
|
99
99
|
const delayMs = Math.min(1000 * Math.pow(2, attempt - 1), 5000)
|
|
@@ -103,7 +103,7 @@ export default class SpeechFlowNodeT2TAmazon extends SpeechFlowNode {
|
|
|
103
103
|
throw util.ensureError(lastError)
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
/* establish a
|
|
106
|
+
/* establish a transform stream and connect it to AWS Translate */
|
|
107
107
|
this.stream = new Stream.Transform({
|
|
108
108
|
readableObjectMode: true,
|
|
109
109
|
writableObjectMode: true,
|
|
@@ -75,7 +75,7 @@ export default class SpeechFlowNodeT2TDeepL extends SpeechFlowNode {
|
|
|
75
75
|
return (result?.text ?? text)
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
/* establish a
|
|
78
|
+
/* establish a transform stream and connect it to DeepL translation */
|
|
79
79
|
this.stream = new Stream.Transform({
|
|
80
80
|
readableObjectMode: true,
|
|
81
81
|
writableObjectMode: true,
|
|
@@ -42,7 +42,7 @@ export default class SpeechFlowNodeT2TFormat extends SpeechFlowNode {
|
|
|
42
42
|
return text
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
/* establish a
|
|
45
|
+
/* establish a transform stream and connect it to text formatting */
|
|
46
46
|
this.stream = new Stream.Transform({
|
|
47
47
|
readableObjectMode: true,
|
|
48
48
|
writableObjectMode: true,
|
|
@@ -85,7 +85,7 @@ export default class SpeechFlowNodeT2TGoogle extends SpeechFlowNode {
|
|
|
85
85
|
return response.translations?.[0]?.translatedText ?? text
|
|
86
86
|
})
|
|
87
87
|
|
|
88
|
-
/* establish a
|
|
88
|
+
/* establish a transform stream and connect it to Google Translate */
|
|
89
89
|
this.stream = new Stream.Transform({
|
|
90
90
|
readableObjectMode: true,
|
|
91
91
|
writableObjectMode: true,
|
|
@@ -129,4 +129,4 @@ export default class SpeechFlowNodeT2TGoogle extends SpeechFlowNode {
|
|
|
129
129
|
this.client = null
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
}
|
|
132
|
+
}
|
|
@@ -45,7 +45,7 @@ export default class SpeechFlowNodeT2TModify extends SpeechFlowNode {
|
|
|
45
45
|
const modify = (text: string): string =>
|
|
46
46
|
text.replace(regex, this.params.replace)
|
|
47
47
|
|
|
48
|
-
/* establish a
|
|
48
|
+
/* establish a transform stream and connect it to text modification */
|
|
49
49
|
this.stream = new Stream.Transform({
|
|
50
50
|
readableObjectMode: true,
|
|
51
51
|
writableObjectMode: true,
|
|
@@ -80,4 +80,4 @@ export default class SpeechFlowNodeT2TModify extends SpeechFlowNode {
|
|
|
80
80
|
this.stream = null
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
}
|
|
83
|
+
}
|
|
@@ -89,7 +89,7 @@ export default class SpeechFlowNodeT2TOPUS extends SpeechFlowNode {
|
|
|
89
89
|
return (single as Transformers.TranslationSingle).translation_text
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
/* establish a
|
|
92
|
+
/* establish a transform stream and connect it to Transformers */
|
|
93
93
|
this.stream = new Stream.Transform({
|
|
94
94
|
readableObjectMode: true,
|
|
95
95
|
writableObjectMode: true,
|
|
@@ -133,8 +133,7 @@ export default class SpeechFlowNodeT2TPunctuation extends SpeechFlowNode {
|
|
|
133
133
|
api: this.params.api,
|
|
134
134
|
model: this.params.model,
|
|
135
135
|
key: this.params.key,
|
|
136
|
-
temperature: 0.7
|
|
137
|
-
topP: 0.5
|
|
136
|
+
temperature: 0.7
|
|
138
137
|
})
|
|
139
138
|
this.llm.on("log", (level: string, message: string) => {
|
|
140
139
|
this.log(level as "info" | "warning" | "error", message)
|
|
@@ -120,8 +120,7 @@ export default class SpeechFlowNodeT2TSpellcheck extends SpeechFlowNode {
|
|
|
120
120
|
api: this.params.api,
|
|
121
121
|
model: this.params.model,
|
|
122
122
|
key: this.params.key,
|
|
123
|
-
temperature: 0.7
|
|
124
|
-
topP: 0.5
|
|
123
|
+
temperature: 0.7
|
|
125
124
|
})
|
|
126
125
|
this.llm.on("log", (level: string, message: string) => {
|
|
127
126
|
this.log(level as "info" | "warning" | "error", message)
|
|
@@ -124,7 +124,7 @@ export default class SpeechFlowNodeT2TSubtitle extends SpeechFlowNode {
|
|
|
124
124
|
return output
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
/* establish a
|
|
127
|
+
/* establish a transform stream */
|
|
128
128
|
const self = this
|
|
129
129
|
let headerEmitted = false
|
|
130
130
|
this.stream = new Stream.Transform({
|
|
@@ -264,7 +264,7 @@ export default class SpeechFlowNodeT2TSubtitle extends SpeechFlowNode {
|
|
|
264
264
|
/* buffer for accumulating input */
|
|
265
265
|
let buffer = ""
|
|
266
266
|
|
|
267
|
-
/* establish a
|
|
267
|
+
/* establish a transform stream */
|
|
268
268
|
const self = this
|
|
269
269
|
this.stream = new Stream.Transform({
|
|
270
270
|
readableObjectMode: true,
|
|
@@ -119,8 +119,7 @@ export default class SpeechFlowNodeT2TSummary extends SpeechFlowNode {
|
|
|
119
119
|
api: this.params.api,
|
|
120
120
|
model: this.params.model,
|
|
121
121
|
key: this.params.key,
|
|
122
|
-
temperature: 0.7
|
|
123
|
-
topP: 0.5
|
|
122
|
+
temperature: 0.7
|
|
124
123
|
})
|
|
125
124
|
this.llm.on("log", (level: string, message: string) => {
|
|
126
125
|
this.log(level as "info" | "warning" | "error", message)
|
|
@@ -169,7 +168,7 @@ export default class SpeechFlowNodeT2TSummary extends SpeechFlowNode {
|
|
|
169
168
|
/* check if we should generate a summary */
|
|
170
169
|
if (self.sentencesSinceLastSummary >= self.params.trigger) {
|
|
171
170
|
self.sentencesSinceLastSummary = 0
|
|
172
|
-
self.log("info",
|
|
171
|
+
self.log("info", "generating summary of accumulated text")
|
|
173
172
|
const textToSummarize = self.accumulatedText
|
|
174
173
|
self.accumulatedText = ""
|
|
175
174
|
summarize(textToSummarize).then((summary) => {
|
|
@@ -189,7 +188,7 @@ export default class SpeechFlowNodeT2TSummary extends SpeechFlowNode {
|
|
|
189
188
|
/* generate final summary if there is accumulated text */
|
|
190
189
|
if (self.accumulatedText.length > 0 && self.sentencesSinceLastSummary > 0) {
|
|
191
190
|
self.sentencesSinceLastSummary = 0
|
|
192
|
-
self.log("info",
|
|
191
|
+
self.log("info", "generating final summary of accumulated text")
|
|
193
192
|
const textToSummarize = self.accumulatedText
|
|
194
193
|
self.accumulatedText = ""
|
|
195
194
|
summarize(textToSummarize).then((summary) => {
|
|
@@ -112,8 +112,7 @@ export default class SpeechFlowNodeT2TTranslate extends SpeechFlowNode {
|
|
|
112
112
|
api: this.params.api,
|
|
113
113
|
model: this.params.model,
|
|
114
114
|
key: this.params.key,
|
|
115
|
-
temperature: 0.7
|
|
116
|
-
topP: 0.5
|
|
115
|
+
temperature: 0.7
|
|
117
116
|
})
|
|
118
117
|
this.llm.on("log", (level: string, message: string) => {
|
|
119
118
|
this.log(level as "info" | "warning" | "error", message)
|
|
@@ -83,10 +83,10 @@ export default class SpeechFlowNodeX2XFilter extends SpeechFlowNode {
|
|
|
83
83
|
const num2 = coerceNum(val2)
|
|
84
84
|
return (
|
|
85
85
|
op === "<" ? (num1 < num2) :
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
op === "<=" ? (num1 <= num2) :
|
|
87
|
+
op === ">=" ? (num1 >= num2) :
|
|
88
|
+
op === ">" ? (num1 > num2) :
|
|
89
|
+
false
|
|
90
90
|
)
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -151,8 +151,8 @@ export default class SpeechFlowNodeXIOExec extends SpeechFlowNode {
|
|
|
151
151
|
/* terminate subprocess */
|
|
152
152
|
if (this.subprocess !== null) {
|
|
153
153
|
/* gracefully end stdin if in write or read/write mode */
|
|
154
|
-
if ((this.params.mode === "w" || this.params.mode === "rw") && this.subprocess.stdin
|
|
155
|
-
!this.subprocess.stdin.destroyed && !this.subprocess.stdin.writableEnded) {
|
|
154
|
+
if ((this.params.mode === "w" || this.params.mode === "rw") && this.subprocess.stdin
|
|
155
|
+
&& !this.subprocess.stdin.destroyed && !this.subprocess.stdin.writableEnded) {
|
|
156
156
|
await Promise.race([
|
|
157
157
|
new Promise<void>((resolve, reject) => {
|
|
158
158
|
this.subprocess!.stdin!.end((err?: Error) => {
|
|
@@ -197,8 +197,8 @@ export default class SpeechFlowNodeXIOFile extends SpeechFlowNode {
|
|
|
197
197
|
else {
|
|
198
198
|
/* for stdio streams, just end without destroying */
|
|
199
199
|
const stream = this.stream
|
|
200
|
-
if ((stream instanceof Stream.Writable || stream instanceof Stream.Duplex)
|
|
201
|
-
(!stream.writableEnded && !stream.destroyed)) {
|
|
200
|
+
if ((stream instanceof Stream.Writable || stream instanceof Stream.Duplex)
|
|
201
|
+
&& (!stream.writableEnded && !stream.destroyed)) {
|
|
202
202
|
await Promise.race([
|
|
203
203
|
new Promise<void>((resolve, reject) => {
|
|
204
204
|
stream.end((err?: Error) => {
|
|
@@ -9,8 +9,10 @@ import Stream from "node:stream"
|
|
|
9
9
|
|
|
10
10
|
/* external dependencies */
|
|
11
11
|
import { DateTime } from "luxon"
|
|
12
|
-
import {
|
|
13
|
-
|
|
12
|
+
import {
|
|
13
|
+
VBANServer, VBANAudioPacket,
|
|
14
|
+
EBitsResolutions, ECodecs
|
|
15
|
+
} from "vban"
|
|
14
16
|
|
|
15
17
|
/* internal dependencies */
|
|
16
18
|
import SpeechFlowNode, { SpeechFlowChunk } from "./speechflow-node"
|
|
@@ -306,7 +306,7 @@ export default class SpeechFlowNodeXIOWebRTC extends SpeechFlowNode {
|
|
|
306
306
|
pc.ontrack = (event: { track: MediaStreamTrack }) => {
|
|
307
307
|
const track = event.track
|
|
308
308
|
if (track.kind === "audio") {
|
|
309
|
-
this.log("info",
|
|
309
|
+
this.log("info", "WebRTC audio track received from publisher")
|
|
310
310
|
|
|
311
311
|
/* subscribe to incoming RTP packets */
|
|
312
312
|
track.onReceiveRtp.subscribe((rtpPacket: RtpPacket) => {
|
|
@@ -168,10 +168,12 @@ export function updateEnvelopeForChannel (
|
|
|
168
168
|
return Math.sqrt(Math.max(currentEnv, 1e-12))
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
/* helper
|
|
171
|
+
/* helper function for linear to decibel conversion */
|
|
172
172
|
export function lin2dB (x: number): number {
|
|
173
173
|
return 20 * Math.log10(Math.max(x, 1e-12))
|
|
174
174
|
}
|
|
175
|
+
|
|
176
|
+
/* helper function for decibel to linear conversion */
|
|
175
177
|
export function dB2lin (db: number): number {
|
|
176
178
|
return Math.pow(10, db / 20)
|
|
177
179
|
}
|
|
@@ -187,6 +189,7 @@ export class WebAudio {
|
|
|
187
189
|
reject: (error: Error) => void
|
|
188
190
|
timeout: ReturnType<typeof setTimeout>
|
|
189
191
|
}>()
|
|
192
|
+
private captureListener: ((event: MessageEvent) => void) | null = null
|
|
190
193
|
|
|
191
194
|
/* construct object */
|
|
192
195
|
constructor (
|
|
@@ -222,7 +225,7 @@ export class WebAudio {
|
|
|
222
225
|
numberOfInputs: 1,
|
|
223
226
|
numberOfOutputs: 0
|
|
224
227
|
})
|
|
225
|
-
this.
|
|
228
|
+
this.captureListener = (event) => {
|
|
226
229
|
const { type, chunkId, data } = event.data ?? {}
|
|
227
230
|
if (type === "capture-complete") {
|
|
228
231
|
const promise = this.pendingPromises.get(chunkId)
|
|
@@ -235,7 +238,8 @@ export class WebAudio {
|
|
|
235
238
|
promise.resolve(int16Data)
|
|
236
239
|
}
|
|
237
240
|
}
|
|
238
|
-
}
|
|
241
|
+
}
|
|
242
|
+
this.captureNode.port.addEventListener("message", this.captureListener)
|
|
239
243
|
|
|
240
244
|
/* start ports */
|
|
241
245
|
this.sourceNode.port.start()
|
|
@@ -302,6 +306,10 @@ export class WebAudio {
|
|
|
302
306
|
this.sourceNode = null
|
|
303
307
|
}
|
|
304
308
|
if (this.captureNode !== null) {
|
|
309
|
+
if (this.captureListener !== null) {
|
|
310
|
+
this.captureNode.port.removeEventListener("message", this.captureListener)
|
|
311
|
+
this.captureListener = null
|
|
312
|
+
}
|
|
305
313
|
this.captureNode.disconnect()
|
|
306
314
|
this.captureNode = null
|
|
307
315
|
}
|
|
@@ -27,7 +27,6 @@ export type LLMConfig = {
|
|
|
27
27
|
timeout?: number
|
|
28
28
|
temperature?: number
|
|
29
29
|
maxTokens?: number
|
|
30
|
-
topP?: number
|
|
31
30
|
cacheDir?: string
|
|
32
31
|
}
|
|
33
32
|
export type LLMCompleteOptions = {
|
|
@@ -61,7 +60,6 @@ export class LLM extends EventEmitter {
|
|
|
61
60
|
timeout: 30 * 1000,
|
|
62
61
|
temperature: 0.7,
|
|
63
62
|
maxTokens: 1024,
|
|
64
|
-
topP: 0.5,
|
|
65
63
|
cacheDir: "",
|
|
66
64
|
...config
|
|
67
65
|
} as Required<LLMConfig>
|
|
@@ -102,7 +100,9 @@ export class LLM extends EventEmitter {
|
|
|
102
100
|
/* instantiate Anthropic API */
|
|
103
101
|
this.anthropic = new Anthropic({
|
|
104
102
|
...(this.config.api !== "" ? { baseURL: this.config.api } : {}),
|
|
105
|
-
|
|
103
|
+
...(this.config.key.match(/^sk-ant-oat/) ?
|
|
104
|
+
{ authToken: this.config.key } :
|
|
105
|
+
{ apiKey: this.config.key } ),
|
|
106
106
|
timeout: this.config.timeout
|
|
107
107
|
})
|
|
108
108
|
}
|
|
@@ -229,7 +229,6 @@ export class LLM extends EventEmitter {
|
|
|
229
229
|
model: this.config.model,
|
|
230
230
|
max_tokens: this.config.maxTokens,
|
|
231
231
|
temperature: this.config.temperature,
|
|
232
|
-
top_p: this.config.topP,
|
|
233
232
|
messages: messages as OpenAI.ChatCompletionMessageParam[]
|
|
234
233
|
}).catch((err) => {
|
|
235
234
|
throw new Error(`failed to perform OpenAI chat completion: ${err}`, { cause: err })
|
|
@@ -252,7 +251,6 @@ export class LLM extends EventEmitter {
|
|
|
252
251
|
model: this.config.model,
|
|
253
252
|
max_tokens: this.config.maxTokens,
|
|
254
253
|
temperature: this.config.temperature,
|
|
255
|
-
top_p: this.config.topP,
|
|
256
254
|
system: systemMessage?.content,
|
|
257
255
|
messages: chatMessages as Anthropic.MessageParam[]
|
|
258
256
|
}).catch((err) => {
|
|
@@ -283,7 +281,6 @@ export class LLM extends EventEmitter {
|
|
|
283
281
|
config: {
|
|
284
282
|
maxOutputTokens: this.config.maxTokens,
|
|
285
283
|
temperature: this.config.temperature,
|
|
286
|
-
topP: this.config.topP,
|
|
287
284
|
...(systemInstruction ? { systemInstruction } : {})
|
|
288
285
|
}
|
|
289
286
|
}).catch((err) => {
|
|
@@ -305,8 +302,7 @@ export class LLM extends EventEmitter {
|
|
|
305
302
|
keep_alive: "10m",
|
|
306
303
|
options: {
|
|
307
304
|
num_predict: this.config.maxTokens,
|
|
308
|
-
temperature: this.config.temperature
|
|
309
|
-
top_p: this.config.topP
|
|
305
|
+
temperature: this.config.temperature
|
|
310
306
|
}
|
|
311
307
|
}).catch((err) => {
|
|
312
308
|
throw new Error(`failed to perform Ollama chat completion: ${err}`, { cause: err })
|
|
@@ -324,7 +320,6 @@ export class LLM extends EventEmitter {
|
|
|
324
320
|
const result = await this.transformer(messages, {
|
|
325
321
|
max_new_tokens: this.config.maxTokens,
|
|
326
322
|
temperature: this.config.temperature,
|
|
327
|
-
top_p: this.config.topP,
|
|
328
323
|
do_sample: true
|
|
329
324
|
}).catch((err) => {
|
|
330
325
|
throw new Error(`failed to perform HuggingFace Transformers text generation: ${err}`, { cause: err })
|
|
@@ -16,7 +16,7 @@ import * as IntervalTree from "node-interval-tree"
|
|
|
16
16
|
import * as util from "./speechflow-util"
|
|
17
17
|
|
|
18
18
|
/* import an object with parsing and strict error handling */
|
|
19
|
-
export function importObject<T>(name: string, arg: object | string, validator: Type<T, {}>): T {
|
|
19
|
+
export function importObject<T> (name: string, arg: object | string, validator: Type<T, {}>): T {
|
|
20
20
|
const obj: object = typeof arg === "string" ?
|
|
21
21
|
util.run(`${name}: parsing JSON`, () => JSON.parse(arg)) :
|
|
22
22
|
arg
|
|
@@ -208,11 +208,10 @@ export async function destroyStream (
|
|
|
208
208
|
stream: Stream.Readable | Stream.Writable | Stream.Duplex | Stream.Transform
|
|
209
209
|
) {
|
|
210
210
|
/* signal the end for a writable stream */
|
|
211
|
-
if ((stream instanceof Stream.Duplex
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
(!stream.writableEnded &&
|
|
215
|
-
!stream.destroyed ) )
|
|
211
|
+
if (( stream instanceof Stream.Duplex
|
|
212
|
+
|| stream instanceof Stream.Transform
|
|
213
|
+
|| stream instanceof Stream.Writable )
|
|
214
|
+
&& (!stream.writableEnded && !stream.destroyed))
|
|
216
215
|
await Promise.race([
|
|
217
216
|
new Promise<void>((resolve) => {
|
|
218
217
|
stream.end(() => { resolve() })
|