@absolutejs/voice-deepgram 0.0.20-beta.94 → 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/index.d.ts +1 -1
- package/dist/index.js +20 -2
- package/dist/types.d.ts +34 -9
- package/package.json +5 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { deepgram } from './deepgram';
|
|
2
|
-
export type { DeepgramModel, DeepgramSTTOptions } from './types';
|
|
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,
|
package/dist/types.d.ts
CHANGED
|
@@ -1,26 +1,51 @@
|
|
|
1
|
-
export type
|
|
2
|
-
export type
|
|
1
|
+
export type DeepgramFluxModel = 'flux' | 'flux-general-en' | 'flux-general-multi';
|
|
2
|
+
export type DeepgramNovaModel = 'nova-3' | 'nova-2';
|
|
3
|
+
export type DeepgramModel = DeepgramFluxModel | DeepgramNovaModel;
|
|
4
|
+
type DeepgramSharedOptions = {
|
|
3
5
|
apiKey: string;
|
|
4
|
-
model: DeepgramModel;
|
|
5
6
|
authMode?: 'header' | 'protocol';
|
|
6
7
|
language?: string;
|
|
8
|
+
keyterm?: string | string[];
|
|
9
|
+
keyterms?: string | string[];
|
|
10
|
+
keepAliveMs?: number;
|
|
11
|
+
connectTimeoutMs?: number;
|
|
12
|
+
tag?: string | string[];
|
|
13
|
+
extra?: Record<string, string>;
|
|
14
|
+
};
|
|
15
|
+
export type DeepgramConversationalOptions = DeepgramSharedOptions & {
|
|
16
|
+
model: DeepgramFluxModel;
|
|
17
|
+
eotThreshold?: number;
|
|
18
|
+
eagerEotThreshold?: number;
|
|
19
|
+
eotTimeoutMs?: number;
|
|
20
|
+
};
|
|
21
|
+
export type DeepgramTranscriptionOptions = DeepgramSharedOptions & {
|
|
22
|
+
model: DeepgramNovaModel;
|
|
23
|
+
interimResults?: boolean;
|
|
24
|
+
endpointing?: number | false;
|
|
25
|
+
utteranceEndMs?: number;
|
|
26
|
+
vadEvents?: boolean;
|
|
27
|
+
diarize?: boolean;
|
|
7
28
|
punctuate?: boolean;
|
|
8
29
|
smartFormat?: boolean;
|
|
30
|
+
numerals?: boolean;
|
|
31
|
+
profanityFilter?: boolean;
|
|
32
|
+
redact?: string | string[];
|
|
33
|
+
};
|
|
34
|
+
export type DeepgramSTTOptions = DeepgramConversationalOptions | DeepgramTranscriptionOptions;
|
|
35
|
+
export type DeepgramResolvedSTTOptions = DeepgramSharedOptions & {
|
|
36
|
+
model: DeepgramModel;
|
|
9
37
|
interimResults?: boolean;
|
|
10
38
|
endpointing?: number | false;
|
|
11
39
|
utteranceEndMs?: number;
|
|
12
40
|
vadEvents?: boolean;
|
|
13
41
|
diarize?: boolean;
|
|
42
|
+
punctuate?: boolean;
|
|
43
|
+
smartFormat?: boolean;
|
|
14
44
|
numerals?: boolean;
|
|
15
45
|
profanityFilter?: boolean;
|
|
16
46
|
redact?: string | string[];
|
|
17
|
-
keyterm?: string | string[];
|
|
18
|
-
keyterms?: string | string[];
|
|
19
47
|
eotThreshold?: number;
|
|
20
48
|
eagerEotThreshold?: number;
|
|
21
49
|
eotTimeoutMs?: number;
|
|
22
|
-
keepAliveMs?: number;
|
|
23
|
-
connectTimeoutMs?: number;
|
|
24
|
-
tag?: string | string[];
|
|
25
|
-
extra?: Record<string, string>;
|
|
26
50
|
};
|
|
51
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@absolutejs/voice-deepgram",
|
|
3
|
-
"version": "0.0.20-beta.
|
|
3
|
+
"version": "0.0.20-beta.96",
|
|
4
4
|
"description": "Deepgram speech-to-text adapter for @absolutejs/voice",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/absolutejs/voice-adapters.git",
|
|
8
8
|
"directory": "deepgram"
|
|
9
9
|
},
|
|
10
|
+
"homepage": "https://github.com/absolutejs/voice-adapters/tree/main/deepgram",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/absolutejs/voice-adapters/issues"
|
|
13
|
+
},
|
|
10
14
|
"files": [
|
|
11
15
|
"dist",
|
|
12
16
|
"README.md"
|