@kuralle-syrinx/deepgram 4.4.0 → 4.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/dist/flux.d.ts ADDED
@@ -0,0 +1,43 @@
1
+ import { type PipelineBus, type PluginConfig, type SttReconfigure, type SttReconfigurePartial, type VoicePlugin } from "@kuralle-syrinx/core";
2
+ import type { SocketFactory } from "@kuralle-syrinx/ws";
3
+ export declare class DeepgramFluxSTTPlugin implements VoicePlugin {
4
+ private readonly socketFactory?;
5
+ readonly endpointingCapability: {
6
+ owner: "provider_stt";
7
+ disableConfig: {
8
+ emit_eos_on_final: boolean;
9
+ };
10
+ };
11
+ private bus;
12
+ private session;
13
+ private model;
14
+ private endpointUrl;
15
+ private sampleRate;
16
+ private eotThreshold;
17
+ private eagerEotThreshold;
18
+ private eotTimeoutMs;
19
+ private keyterms;
20
+ private languageHints;
21
+ private speechStartedEvents;
22
+ private encoding;
23
+ /** Open-ended Flux listen query knobs (profanity_filter, tag, mip_opt_out, …). */
24
+ private queryParams;
25
+ private apiKey;
26
+ private currentContextId;
27
+ constructor(socketFactory?: SocketFactory | undefined);
28
+ initialize(bus: PipelineBus, config: PluginConfig): Promise<void>;
29
+ /**
30
+ * Mid-stream reconfigure of keyterms / end-of-turn thresholds via the Flux v2 `Configure`
31
+ * control message — no socket restart (Deepgram "on-the-fly configuration"). Instance state is
32
+ * updated too, so a reconnect replays the current config (single source of truth with `url()`).
33
+ * `keyterms` REPLACES the list (Flux semantics), not merges. The provider acks with
34
+ * ConfigureSuccess / ConfigureFailure (surfaced as metrics in the wire protocol).
35
+ * `language` (hard switch) is ignored: Flux's model is language-specific (flux-general-en) —
36
+ * use `languageHints` to bias.
37
+ */
38
+ get sttReconfigure(): SttReconfigure;
39
+ reconfigure(partial: SttReconfigurePartial): void;
40
+ private emitError;
41
+ close(): Promise<void>;
42
+ }
43
+ //# sourceMappingURL=flux.d.ts.map
@@ -0,0 +1 @@
1
+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PDX-License-Identifier: MIT
2
+ //
3
+ // Deepgram Flux — turn-aware conversational STT (v2 listen API).
4
+ //
5
+ // One model produces transcripts AND owns turn detection, replacing the
6
+ // VAD + silence-endpointing stack. Runs on Workers (plain WebSocket), so this
7
+ // is the semantic end-of-turn path for the edge cascade, where local ONNX
8
+ // endpointers (smart-turn) cannot run.
9
+ //
10
+ // TurnInfo state machine → bus mapping (via stt-core SttEvent):
11
+ // StartOfTurn → vad.speech_started (barge-in signal; Flux recommends it)
12
+ // Update → stt.interim
13
+ // EagerEndOfTurn → eos.interim (speculative-generation trigger)
14
+ // TurnResumed → eos.retracted (cancel speculative work)
15
+ // EndOfTurn → stt.result + eos.turn_complete
16
+ //
17
+ // Eager mode is enabled by setting `eager_eot_threshold` (Deepgram: fires
18
+ // 150–250ms before EndOfTurn at the cost of extra speculative LLM calls). The
19
+ // EndOfTurn transcript exactly matches the preceding EagerEndOfTurn transcript
20
+ // when no TurnResumed intervened, so a speculative result keyed on the eager
21
+ // transcript can be committed as-is.
22
+ import { Route, categorizeSttError, isRecoverable, optionalStringConfig, readProviderRetryConfig, requireStringConfig, } from "@kuralle-syrinx/core";
23
+ import { defaultNodeSocketFactory, startStreamingSttSession, } from "@kuralle-syrinx/stt-core";
24
+ function meanWordConfidence(words) {
25
+ if (!words || words.length === 0)
26
+ return 1;
27
+ let sum = 0;
28
+ for (const w of words)
29
+ sum += w.confidence;
30
+ return sum / words.length;
31
+ }
32
+ class DeepgramFluxSttWireProtocol {
33
+ speechStartedEvents;
34
+ onMetric;
35
+ constructor(speechStartedEvents, onMetric) {
36
+ this.speechStartedEvents = speechStartedEvents;
37
+ this.onMetric = onMetric;
38
+ }
39
+ encodeFinalize(_contextId) {
40
+ return [];
41
+ }
42
+ encodeClose() {
43
+ return [JSON.stringify({ type: "CloseStream" })];
44
+ }
45
+ encodeReconfigure(partial) {
46
+ const thresholds = {};
47
+ if (partial.eotThreshold !== undefined)
48
+ thresholds["eot_threshold"] = partial.eotThreshold;
49
+ if (partial.eagerEotThreshold !== undefined) {
50
+ thresholds["eager_eot_threshold"] = partial.eagerEotThreshold;
51
+ }
52
+ if (partial.eotTimeoutMs !== undefined)
53
+ thresholds["eot_timeout_ms"] = partial.eotTimeoutMs;
54
+ const configure = { type: "Configure" };
55
+ if (Object.keys(thresholds).length > 0)
56
+ configure["thresholds"] = thresholds;
57
+ if (partial.keyterms !== undefined)
58
+ configure["keyterms"] = partial.keyterms;
59
+ if (partial.languageHints !== undefined)
60
+ configure["language_hints"] = partial.languageHints;
61
+ return [JSON.stringify(configure)];
62
+ }
63
+ decode(data, _isBinary) {
64
+ if (typeof data !== "string")
65
+ return [];
66
+ let msg;
67
+ try {
68
+ msg = JSON.parse(data);
69
+ }
70
+ catch (err) {
71
+ return [
72
+ {
73
+ type: "error",
74
+ error: new Error(`Deepgram Flux sent malformed JSON: ${err instanceof Error ? err.message : String(err)}`),
75
+ },
76
+ ];
77
+ }
78
+ if (msg["type"] === "Error") {
79
+ const description = typeof msg["description"] === "string" ? msg["description"] : JSON.stringify(msg);
80
+ return [
81
+ {
82
+ type: "error",
83
+ error: new Error(`Deepgram Flux provider error: ${description}`),
84
+ },
85
+ ];
86
+ }
87
+ // Ack/nack for a mid-stream Configure (dynamic reconfigure). Surface as metrics so the
88
+ // conversation-state biasing that actuates reconfigure can observe that it took effect.
89
+ if (msg["type"] === "ConfigureSuccess") {
90
+ this.onMetric("stt.flux.configure_success", "1");
91
+ return [];
92
+ }
93
+ if (msg["type"] === "ConfigureFailure") {
94
+ const description = typeof msg["description"] === "string" ? msg["description"] : JSON.stringify(msg);
95
+ this.onMetric("stt.flux.configure_failure", description);
96
+ return [];
97
+ }
98
+ if (msg["type"] !== "TurnInfo")
99
+ return [];
100
+ const info = msg;
101
+ const transcript = (info.transcript ?? "").trim();
102
+ switch (info.event) {
103
+ case "StartOfTurn":
104
+ if (!this.speechStartedEvents)
105
+ return [];
106
+ return [{ type: "speech_started" }];
107
+ case "Update":
108
+ if (!transcript)
109
+ return [];
110
+ return [{ type: "interim", contextId: "", text: transcript }];
111
+ case "EagerEndOfTurn":
112
+ if (!transcript)
113
+ return [];
114
+ return [{ type: "eos_interim", text: transcript }];
115
+ case "TurnResumed":
116
+ return [{ type: "eos_retracted" }];
117
+ case "EndOfTurn":
118
+ if (!transcript)
119
+ return [];
120
+ return [
121
+ {
122
+ type: "final",
123
+ contextId: "",
124
+ text: transcript,
125
+ confidence: meanWordConfidence(info.words),
126
+ language: "en",
127
+ speechFinal: true,
128
+ },
129
+ ];
130
+ default:
131
+ return [];
132
+ }
133
+ }
134
+ }
135
+ export class DeepgramFluxSTTPlugin {
136
+ socketFactory;
137
+ endpointingCapability = {
138
+ owner: "provider_stt",
139
+ disableConfig: {
140
+ emit_eos_on_final: false,
141
+ },
142
+ };
143
+ bus = null;
144
+ session = null;
145
+ model = "flux-general-en";
146
+ endpointUrl = "wss://api.deepgram.com/v2/listen";
147
+ sampleRate = 16000;
148
+ eotThreshold = 0.7;
149
+ eagerEotThreshold;
150
+ eotTimeoutMs = 5000;
151
+ keyterms = [];
152
+ languageHints = [];
153
+ speechStartedEvents = true;
154
+ encoding = "linear16";
155
+ /** Open-ended Flux listen query knobs (profanity_filter, tag, mip_opt_out, …). */
156
+ queryParams;
157
+ apiKey = "";
158
+ currentContextId = "";
159
+ constructor(socketFactory) {
160
+ this.socketFactory = socketFactory;
161
+ }
162
+ async initialize(bus, config) {
163
+ this.bus = bus;
164
+ this.apiKey = requireStringConfig(config, "api_key");
165
+ this.model = optionalStringConfig(config, "model") ?? "flux-general-en";
166
+ this.endpointUrl = optionalStringConfig(config, "endpoint_url") ?? "wss://api.deepgram.com/v2/listen";
167
+ this.sampleRate = config["sample_rate"] ?? 16000;
168
+ this.eotThreshold = config["eot_threshold"] ?? 0.7;
169
+ this.eagerEotThreshold = config["eager_eot_threshold"];
170
+ this.eotTimeoutMs = config["eot_timeout_ms"] ?? 5000;
171
+ this.speechStartedEvents = config["speech_started_events"] ?? true;
172
+ const emitEosOnFinal = config["emit_eos_on_final"] ?? true;
173
+ {
174
+ const raw = config["keyterm"];
175
+ this.keyterms = Array.isArray(raw)
176
+ ? raw.filter((t) => typeof t === "string" && t.length > 0)
177
+ : typeof raw === "string" && raw.length > 0
178
+ ? [raw]
179
+ : [];
180
+ }
181
+ {
182
+ const raw = config["language_hint"];
183
+ this.languageHints = Array.isArray(raw)
184
+ ? raw.filter((t) => typeof t === "string" && t.length > 0)
185
+ : typeof raw === "string" && raw.length > 0
186
+ ? [raw]
187
+ : [];
188
+ }
189
+ this.encoding = optionalStringConfig(config, "encoding") ?? "linear16";
190
+ this.queryParams = readPlainObject(config["query_params"]);
191
+ const audioFormat = {
192
+ encoding: "pcm_s16le",
193
+ sampleRateHz: this.sampleRate,
194
+ channels: 1,
195
+ };
196
+ this.session = await startStreamingSttSession(bus, {
197
+ protocol: new DeepgramFluxSttWireProtocol(this.speechStartedEvents, (name, value) => {
198
+ bus.push(Route.Background, {
199
+ kind: "metric.conversation",
200
+ contextId: "",
201
+ timestampMs: Date.now(),
202
+ name,
203
+ value,
204
+ });
205
+ }),
206
+ provider: { name: "deepgram", model: this.model, region: "global" },
207
+ format: audioFormat,
208
+ language: "en",
209
+ emitEosOnFinal,
210
+ url: () => {
211
+ const params = new URLSearchParams({
212
+ model: this.model,
213
+ encoding: this.encoding,
214
+ sample_rate: String(this.sampleRate),
215
+ eot_threshold: String(this.eotThreshold),
216
+ eot_timeout_ms: String(this.eotTimeoutMs),
217
+ ...(this.eagerEotThreshold !== undefined
218
+ ? { eager_eot_threshold: String(this.eagerEotThreshold) }
219
+ : {}),
220
+ });
221
+ for (const term of this.keyterms)
222
+ params.append("keyterm", term);
223
+ for (const hint of this.languageHints)
224
+ params.append("language_hint", hint);
225
+ applyQueryParams(params, this.queryParams);
226
+ const separator = this.endpointUrl.includes("?") ? "&" : "?";
227
+ return `${this.endpointUrl}${separator}${params.toString()}`;
228
+ },
229
+ headers: { Authorization: `Token ${this.apiKey}` },
230
+ socketFactory: this.socketFactory ?? (await defaultNodeSocketFactory()),
231
+ retry: readProviderRetryConfig(config),
232
+ replayBufferSize: config["replay_buffer_size"] ?? 64,
233
+ metricPrefix: "stt.flux",
234
+ });
235
+ }
236
+ /**
237
+ * Mid-stream reconfigure of keyterms / end-of-turn thresholds via the Flux v2 `Configure`
238
+ * control message — no socket restart (Deepgram "on-the-fly configuration"). Instance state is
239
+ * updated too, so a reconnect replays the current config (single source of truth with `url()`).
240
+ * `keyterms` REPLACES the list (Flux semantics), not merges. The provider acks with
241
+ * ConfigureSuccess / ConfigureFailure (surfaced as metrics in the wire protocol).
242
+ * `language` (hard switch) is ignored: Flux's model is language-specific (flux-general-en) —
243
+ * use `languageHints` to bias.
244
+ */
245
+ get sttReconfigure() {
246
+ return this;
247
+ }
248
+ reconfigure(partial) {
249
+ if (partial.keyterms !== undefined)
250
+ this.keyterms = partial.keyterms;
251
+ if (partial.eotThreshold !== undefined)
252
+ this.eotThreshold = partial.eotThreshold;
253
+ if (partial.eagerEotThreshold !== undefined)
254
+ this.eagerEotThreshold = partial.eagerEotThreshold;
255
+ if (partial.eotTimeoutMs !== undefined)
256
+ this.eotTimeoutMs = partial.eotTimeoutMs;
257
+ if (partial.languageHints !== undefined)
258
+ this.languageHints = partial.languageHints;
259
+ try {
260
+ this.session?.reconfigure(partial);
261
+ }
262
+ catch (err) {
263
+ this.emitError(err instanceof Error ? err : new Error(String(err)));
264
+ }
265
+ }
266
+ emitError(err) {
267
+ const category = categorizeSttError(err);
268
+ const packet = {
269
+ kind: "stt.error",
270
+ contextId: this.currentContextId,
271
+ timestampMs: Date.now(),
272
+ component: "stt",
273
+ category,
274
+ cause: err,
275
+ isRecoverable: isRecoverable(category),
276
+ };
277
+ this.bus?.push(Route.Critical, packet);
278
+ }
279
+ async close() {
280
+ await this.session?.dispose();
281
+ this.session = null;
282
+ this.bus = null;
283
+ }
284
+ }
285
+ function readPlainObject(value) {
286
+ if (value !== null && typeof value === "object" && !Array.isArray(value)) {
287
+ return value;
288
+ }
289
+ return undefined;
290
+ }
291
+ function applyQueryParams(params, extra) {
292
+ if (!extra)
293
+ return;
294
+ for (const [key, value] of Object.entries(extra)) {
295
+ if (value === undefined || value === null)
296
+ continue;
297
+ if (Array.isArray(value)) {
298
+ for (const item of value) {
299
+ if (item === undefined || item === null)
300
+ continue;
301
+ params.append(key, String(item));
302
+ }
303
+ continue;
304
+ }
305
+ params.set(key, String(value));
306
+ }
307
+ }
308
+ //# sourceMappingURL=flux.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flux.js","sourceRoot":"","sources":["../src/flux.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,EAAE;AACF,iEAAiE;AACjE,EAAE;AACF,wEAAwE;AACxE,8EAA8E;AAC9E,0EAA0E;AAC1E,uCAAuC;AACvC,EAAE;AACF,gEAAgE;AAChE,iFAAiF;AACjF,kCAAkC;AAClC,4EAA4E;AAC5E,qEAAqE;AACrE,qDAAqD;AACrD,EAAE;AACF,0EAA0E;AAC1E,8EAA8E;AAC9E,+EAA+E;AAC/E,6EAA6E;AAC7E,qCAAqC;AAErC,OAAO,EACL,KAAK,EACL,kBAAkB,EAClB,aAAa,EAQb,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GAIzB,MAAM,0BAA0B,CAAC;AAWlC,SAAS,kBAAkB,CAAC,KAA+B;IACzD,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAC3C,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,MAAM,CAAC,IAAI,KAAK;QAAE,GAAG,IAAI,CAAC,CAAC,UAAU,CAAC;IAC3C,OAAO,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC;AAC5B,CAAC;AAID,MAAM,2BAA2B;IAEZ;IACA;IAFnB,YACmB,mBAA4B,EAC5B,QAAoB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AAC,MAAuB,EAAE,KAA0C;IAC3F,IAAI,CAAC,KAAK;QAAE,OAAO;IACnB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,SAAS;QACpD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI;oBAAE,SAAS;gBAClD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;YACnC,CAAC;YACD,SAAS;QACX,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACjC,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./stt.js";
2
+ export * from "./flux.js";
3
+ export * from "./tts.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ // SPDX-License-Identifier: MIT
2
+ //
3
+ // Deepgram provider plugins — speech-to-text and text-to-speech in one package.
4
+ // Import from the barrel for both, or the `./stt` / `./tts` subpaths for one.
5
+ export * from "./stt.js";
6
+ export * from "./flux.js";
7
+ export * from "./tts.js";
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,EAAE;AACF,gFAAgF;AAChF,8EAA8E;AAE9E,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
package/dist/stt.d.ts ADDED
@@ -0,0 +1,49 @@
1
+ import { type PipelineBus, type PluginConfig, type SttReconfigure, type SttReconfigurePartial, type VoicePlugin } from "@kuralle-syrinx/core";
2
+ import type { SocketFactory } from "@kuralle-syrinx/ws";
3
+ export declare class DeepgramSTTPlugin implements VoicePlugin {
4
+ private readonly socketFactory?;
5
+ readonly endpointingCapability: {
6
+ owner: "provider_stt";
7
+ disableConfig: {
8
+ emit_eos_on_final: boolean;
9
+ finalize_on_speech_final: boolean;
10
+ };
11
+ };
12
+ private bus;
13
+ private session;
14
+ private protocol;
15
+ private currentContextId;
16
+ private model;
17
+ private language;
18
+ private sampleRate;
19
+ private endpointing;
20
+ private endpointUrl;
21
+ private smartFormat;
22
+ private interimResults;
23
+ private vadEvents;
24
+ private utteranceEndMs;
25
+ private keyterms;
26
+ private encoding;
27
+ private channels;
28
+ private noDelay;
29
+ private queryParams;
30
+ private disposers;
31
+ constructor(socketFactory?: SocketFactory | undefined);
32
+ initialize(bus: PipelineBus, config: PluginConfig): Promise<void>;
33
+ /**
34
+ * Per-turn reconfigure of keyterms / silence endpointing. Nova has no in-band
35
+ * Configure message — updates instance state then reconnects via `session.reset()`
36
+ * so the re-evaluated `url()` carries the new params (LiveKit Nova-3 pattern).
37
+ * Call only at a turn boundary (between utterances); reconnect is not free and
38
+ * would drop mid-utterance audio. keyterms REPLACE the list (Flux semantics).
39
+ * `language` hard-switches recognition (e.g. "es-ES" or Nova-3 "multi") — applied on
40
+ * reconnect via the rebuilt `url()`, and re-stamped onto stt.result. Flux-only fields
41
+ * (eotThreshold, eagerEotThreshold, eotTimeoutMs, contextText) are ignored.
42
+ */
43
+ get sttReconfigure(): SttReconfigure;
44
+ reconfigure(partial: SttReconfigurePartial): void;
45
+ /** Request that Deepgram flush buffered audio and return provider-final text. */
46
+ forceFinalize(contextId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