@absolutejs/voice-deepgram 0.0.14 → 0.0.16
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/index.js +38 -3
- package/package.json +6 -4
package/dist/index.js
CHANGED
|
@@ -2203,6 +2203,7 @@ function createClient(keyOrOptions, options) {
|
|
|
2203
2203
|
}
|
|
2204
2204
|
|
|
2205
2205
|
// src/deepgram.ts
|
|
2206
|
+
import WS from "ws";
|
|
2206
2207
|
var createListenerMap = () => ({
|
|
2207
2208
|
close: new Set,
|
|
2208
2209
|
endOfTurn: new Set,
|
|
@@ -2243,6 +2244,34 @@ var buildTranscript = (payload, vendor) => {
|
|
|
2243
2244
|
vendor
|
|
2244
2245
|
};
|
|
2245
2246
|
};
|
|
2247
|
+
var resolveErrorMessage = (error) => {
|
|
2248
|
+
if (typeof error === "string" && error.trim()) {
|
|
2249
|
+
return error;
|
|
2250
|
+
}
|
|
2251
|
+
if (error instanceof Error && error.message.trim()) {
|
|
2252
|
+
return error.message;
|
|
2253
|
+
}
|
|
2254
|
+
if (error && typeof error === "object") {
|
|
2255
|
+
const record = error;
|
|
2256
|
+
for (const key of ["message", "reason", "description"]) {
|
|
2257
|
+
const candidate = record[key];
|
|
2258
|
+
if (typeof candidate === "string" && candidate.trim()) {
|
|
2259
|
+
return candidate;
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
if ("error" in record) {
|
|
2263
|
+
return resolveErrorMessage(record.error);
|
|
2264
|
+
}
|
|
2265
|
+
if ("cause" in record) {
|
|
2266
|
+
return resolveErrorMessage(record.cause);
|
|
2267
|
+
}
|
|
2268
|
+
try {
|
|
2269
|
+
return JSON.stringify(error);
|
|
2270
|
+
} catch {}
|
|
2271
|
+
}
|
|
2272
|
+
return "Deepgram stream error";
|
|
2273
|
+
};
|
|
2274
|
+
var omitUndefined = (value) => Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== undefined));
|
|
2246
2275
|
var buildLiveOptions = (config, format) => {
|
|
2247
2276
|
const options = {
|
|
2248
2277
|
channels: format.channels,
|
|
@@ -2285,7 +2314,7 @@ var buildLiveOptions = (config, format) => {
|
|
|
2285
2314
|
if (keyterm !== undefined) {
|
|
2286
2315
|
options.keyterm = keyterm;
|
|
2287
2316
|
}
|
|
2288
|
-
return options;
|
|
2317
|
+
return omitUndefined(options);
|
|
2289
2318
|
};
|
|
2290
2319
|
var openConnection = (client, config, liveOptions) => {
|
|
2291
2320
|
const listen = client.listen;
|
|
@@ -2303,7 +2332,13 @@ var openConnection = (client, config, liveOptions) => {
|
|
|
2303
2332
|
var deepgram = (config) => ({
|
|
2304
2333
|
kind: "stt",
|
|
2305
2334
|
open: (options) => {
|
|
2306
|
-
const client = createClient(config.apiKey
|
|
2335
|
+
const client = createClient(config.apiKey, {
|
|
2336
|
+
global: {
|
|
2337
|
+
websocket: {
|
|
2338
|
+
client: WS
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2341
|
+
});
|
|
2307
2342
|
const listeners = createListenerMap();
|
|
2308
2343
|
const liveOptions = buildLiveOptions(config, {
|
|
2309
2344
|
channels: options.format.channels,
|
|
@@ -2375,7 +2410,7 @@ var deepgram = (config) => ({
|
|
|
2375
2410
|
});
|
|
2376
2411
|
connection.on(LiveTranscriptionEvents.Error, (error) => {
|
|
2377
2412
|
clearKeepAlive();
|
|
2378
|
-
const resolvedError = error instanceof Error ? error : new Error(
|
|
2413
|
+
const resolvedError = error instanceof Error ? error : new Error(resolveErrorMessage(error));
|
|
2379
2414
|
emit(listeners, "error", {
|
|
2380
2415
|
error: resolvedError,
|
|
2381
2416
|
recoverable: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@absolutejs/voice-deepgram",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "Deepgram speech-to-text adapter for @absolutejs/voice",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,11 +28,13 @@
|
|
|
28
28
|
"typecheck": "bun run tsc --noEmit"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@absolutejs/voice": "0.0.
|
|
32
|
-
"@deepgram/sdk": "^4.11.2"
|
|
31
|
+
"@absolutejs/voice": "0.0.14",
|
|
32
|
+
"@deepgram/sdk": "^4.11.2",
|
|
33
|
+
"ws": "^8.18.3"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
|
-
"@absolutejs/absolute": "0.19.0-beta.
|
|
36
|
+
"@absolutejs/absolute": "0.19.0-beta.647",
|
|
37
|
+
"@types/ws": "^8.18.1",
|
|
36
38
|
"@types/bun": "1.3.9",
|
|
37
39
|
"typescript": "^5.9.3"
|
|
38
40
|
}
|