@absolutejs/voice-deepgram 0.0.13 → 0.0.15
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 +36 -2
- 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,33 @@ 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
|
+
};
|
|
2246
2274
|
var buildLiveOptions = (config, format) => {
|
|
2247
2275
|
const options = {
|
|
2248
2276
|
channels: format.channels,
|
|
@@ -2303,7 +2331,13 @@ var openConnection = (client, config, liveOptions) => {
|
|
|
2303
2331
|
var deepgram = (config) => ({
|
|
2304
2332
|
kind: "stt",
|
|
2305
2333
|
open: (options) => {
|
|
2306
|
-
const client = createClient(config.apiKey
|
|
2334
|
+
const client = createClient(config.apiKey, {
|
|
2335
|
+
global: {
|
|
2336
|
+
websocket: {
|
|
2337
|
+
client: WS
|
|
2338
|
+
}
|
|
2339
|
+
}
|
|
2340
|
+
});
|
|
2307
2341
|
const listeners = createListenerMap();
|
|
2308
2342
|
const liveOptions = buildLiveOptions(config, {
|
|
2309
2343
|
channels: options.format.channels,
|
|
@@ -2375,7 +2409,7 @@ var deepgram = (config) => ({
|
|
|
2375
2409
|
});
|
|
2376
2410
|
connection.on(LiveTranscriptionEvents.Error, (error) => {
|
|
2377
2411
|
clearKeepAlive();
|
|
2378
|
-
const resolvedError = error instanceof Error ? error : new Error(
|
|
2412
|
+
const resolvedError = error instanceof Error ? error : new Error(resolveErrorMessage(error));
|
|
2379
2413
|
emit(listeners, "error", {
|
|
2380
2414
|
error: resolvedError,
|
|
2381
2415
|
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.15",
|
|
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
|
}
|