@absolutejs/voice-deepgram 0.0.20-beta.95 → 0.0.20-beta.96
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/deepgram.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +21 -6
- package/dist/types.d.ts +3 -3
- package/package.json +41 -37
package/dist/deepgram.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { STTAdapter } from
|
|
2
|
-
import type { DeepgramSTTOptions } from
|
|
1
|
+
import type { STTAdapter } from '@absolutejs/voice';
|
|
2
|
+
import type { DeepgramSTTOptions } from './types';
|
|
3
3
|
export declare const deepgram: (config: DeepgramSTTOptions) => STTAdapter;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { deepgram } from
|
|
2
|
-
export type { DeepgramConversationalOptions, DeepgramFluxModel, DeepgramModel, DeepgramNovaModel, DeepgramSTTOptions, DeepgramTranscriptionOptions, } from
|
|
1
|
+
export { deepgram } from './deepgram';
|
|
2
|
+
export type { DeepgramConversationalOptions, DeepgramFluxModel, DeepgramModel, DeepgramNovaModel, DeepgramSTTOptions, DeepgramTranscriptionOptions, } from './types';
|
package/dist/index.js
CHANGED
|
@@ -93,8 +93,10 @@ var collectLexiconTerms = (options) => (options.lexicon ?? []).flatMap((entry) =
|
|
|
93
93
|
...entry.aliases ?? []
|
|
94
94
|
]);
|
|
95
95
|
var normalizeKeyterms = (value) => value === undefined ? [] : Array.isArray(value) ? value : [value];
|
|
96
|
-
var
|
|
96
|
+
var MAX_KEYTERM_TOKEN_BUDGET = 450;
|
|
97
|
+
var MAX_KEYTERM_COUNT = 200;
|
|
97
98
|
var MAX_KEYTERM_LENGTH = 48;
|
|
99
|
+
var estimateKeytermTokens = (term) => Math.max(1, Math.ceil(term.trim().length / 4));
|
|
98
100
|
var countScripts = (value) => {
|
|
99
101
|
const scripts = new Set;
|
|
100
102
|
if (/\p{Script=Latin}/u.test(value)) {
|
|
@@ -109,7 +111,23 @@ var scoreKeytermCandidate = (value) => {
|
|
|
109
111
|
const normalized = value.trim();
|
|
110
112
|
return (countScripts(normalized) >= 2 ? 40 : 0) + (normalized.includes(" ") ? 20 : 0) + (/[^\x00-\x7F]/u.test(normalized) ? 10 : 0) + (normalized.includes("'") ? 5 : 0) + Math.min(normalized.length, 20);
|
|
111
113
|
};
|
|
112
|
-
var selectKeyterms = (terms) =>
|
|
114
|
+
var selectKeyterms = (terms) => {
|
|
115
|
+
const ranked = terms.map((term) => term.trim()).filter((term) => term.length >= 2 && term.length <= MAX_KEYTERM_LENGTH).filter((term, index, list) => list.indexOf(term) === index).sort((left, right) => scoreKeytermCandidate(right) - scoreKeytermCandidate(left));
|
|
116
|
+
const selected = [];
|
|
117
|
+
let tokenBudget = MAX_KEYTERM_TOKEN_BUDGET;
|
|
118
|
+
for (const term of ranked) {
|
|
119
|
+
if (selected.length >= MAX_KEYTERM_COUNT) {
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
const cost = estimateKeytermTokens(term);
|
|
123
|
+
if (cost > tokenBudget) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
selected.push(term);
|
|
127
|
+
tokenBudget -= cost;
|
|
128
|
+
}
|
|
129
|
+
return selected;
|
|
130
|
+
};
|
|
113
131
|
var formatErrorMessage = (details) => {
|
|
114
132
|
const parts = [
|
|
115
133
|
details.code ? `code=${details.code}` : undefined,
|
|
@@ -319,10 +337,7 @@ var createTransport = async (url, apiKey, authMode = "header") => {
|
|
|
319
337
|
const globalWebSocket = globalThis.WebSocket;
|
|
320
338
|
if (typeof globalWebSocket === "function") {
|
|
321
339
|
if (authMode === "protocol") {
|
|
322
|
-
return new globalWebSocket(url, [
|
|
323
|
-
"token",
|
|
324
|
-
apiKey
|
|
325
|
-
]);
|
|
340
|
+
return new globalWebSocket(url, ["token", apiKey]);
|
|
326
341
|
}
|
|
327
342
|
return new globalWebSocket(url, {
|
|
328
343
|
headers: {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export type DeepgramFluxModel =
|
|
2
|
-
export type DeepgramNovaModel =
|
|
1
|
+
export type DeepgramFluxModel = 'flux' | 'flux-general-en' | 'flux-general-multi';
|
|
2
|
+
export type DeepgramNovaModel = 'nova-3' | 'nova-2';
|
|
3
3
|
export type DeepgramModel = DeepgramFluxModel | DeepgramNovaModel;
|
|
4
4
|
type DeepgramSharedOptions = {
|
|
5
5
|
apiKey: string;
|
|
6
|
-
authMode?:
|
|
6
|
+
authMode?: 'header' | 'protocol';
|
|
7
7
|
language?: string;
|
|
8
8
|
keyterm?: string | string[];
|
|
9
9
|
keyterms?: string | string[];
|
package/package.json
CHANGED
|
@@ -1,39 +1,43 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
2
|
+
"name": "@absolutejs/voice-deepgram",
|
|
3
|
+
"version": "0.0.20-beta.96",
|
|
4
|
+
"description": "Deepgram speech-to-text adapter for @absolutejs/voice",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/absolutejs/voice-adapters.git",
|
|
8
|
+
"directory": "deepgram"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/absolutejs/voice-adapters/tree/main/deepgram",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/absolutejs/voice-adapters/issues"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"main": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"import": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"license": "Apache-2.0",
|
|
27
|
+
"author": "Alex Kahn",
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "rm -rf dist && bun build ./src/index.ts --outdir dist --target bun --external @absolutejs/voice && tsc --emitDeclarationOnly --project tsconfig.json",
|
|
30
|
+
"format": "prettier --write \"./**/*.{js,ts,json,md}\"",
|
|
31
|
+
"release": "bun run format && bun run build && bun publish",
|
|
32
|
+
"test": "bun test",
|
|
33
|
+
"typecheck": "bun run tsc --noEmit"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@absolutejs/voice": "0.0.22-beta.474"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@absolutejs/absolute": "0.19.0-beta.648",
|
|
40
|
+
"@types/bun": "1.3.9",
|
|
41
|
+
"typescript": "^5.9.3"
|
|
42
|
+
}
|
|
39
43
|
}
|