@ai-sdk/deepgram 0.0.1
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/CHANGELOG.md +7 -0
- package/LICENSE +13 -0
- package/README.md +38 -0
- package/dist/index.d.mts +65 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.js +238 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +215 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +64 -0
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2023 Vercel, Inc.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# AI SDK - Deepgram Provider
|
|
2
|
+
|
|
3
|
+
The **[Deepgram provider](https://sdk.vercel.ai/providers/ai-sdk-providers/deepgram)** for the [AI SDK](https://sdk.vercel.ai/docs)
|
|
4
|
+
contains transcription model support for the Deepgram transcription API.
|
|
5
|
+
|
|
6
|
+
## Setup
|
|
7
|
+
|
|
8
|
+
The Deepgram provider is available in the `@ai-sdk/deepgram` module. You can install it with
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm i @ai-sdk/deepgram
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Provider Instance
|
|
15
|
+
|
|
16
|
+
You can import the default provider instance `deepgram` from `@ai-sdk/deepgram`:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { deepgram } from '@ai-sdk/deepgram';
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Example
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { deepgram } from '@ai-sdk/deepgram';
|
|
26
|
+
import { experimental_transcribe as transcribe } from 'ai';
|
|
27
|
+
|
|
28
|
+
const { text } = await transcribe({
|
|
29
|
+
model: deepgram.transcription('nova-3'),
|
|
30
|
+
audio: new URL(
|
|
31
|
+
'https://github.com/vercel/ai/raw/refs/heads/main/examples/ai-core/data/galileo.mp3',
|
|
32
|
+
),
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Documentation
|
|
37
|
+
|
|
38
|
+
Please check out the **[Deepgram provider documentation](https://sdk.vercel.ai/providers/ai-sdk-providers/deepgram)** for more information.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { TranscriptionModelV1, ProviderV1 } from '@ai-sdk/provider';
|
|
2
|
+
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
+
|
|
4
|
+
type DeepgramConfig = {
|
|
5
|
+
provider: string;
|
|
6
|
+
url: (options: {
|
|
7
|
+
modelId: string;
|
|
8
|
+
path: string;
|
|
9
|
+
}) => string;
|
|
10
|
+
headers: () => Record<string, string | undefined>;
|
|
11
|
+
fetch?: FetchFunction;
|
|
12
|
+
generateId?: () => string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type DeepgramTranscriptionModelId = 'base' | 'base-general' | 'base-meeting' | 'base-phonecall' | 'base-finance' | 'base-conversationalai' | 'base-voicemail' | 'base-video' | 'enhanced' | 'enhanced-general' | 'enhanced-meeting' | 'enhanced-phonecall' | 'enhanced-finance' | 'nova' | 'nova-general' | 'nova-phonecall' | 'nova-medical' | 'nova-2' | 'nova-2-general' | 'nova-2-meeting' | 'nova-2-phonecall' | 'nova-2-finance' | 'nova-2-conversationalai' | 'nova-2-voicemail' | 'nova-2-video' | 'nova-2-medical' | 'nova-2-drivethru' | 'nova-2-automotive' | 'nova-2-atc' | 'nova-3' | 'nova-3-general' | 'nova-3-medical' | (string & {});
|
|
16
|
+
|
|
17
|
+
interface DeepgramTranscriptionModelConfig extends DeepgramConfig {
|
|
18
|
+
_internal?: {
|
|
19
|
+
currentDate?: () => Date;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
declare class DeepgramTranscriptionModel implements TranscriptionModelV1 {
|
|
23
|
+
readonly modelId: DeepgramTranscriptionModelId;
|
|
24
|
+
private readonly config;
|
|
25
|
+
readonly specificationVersion = "v1";
|
|
26
|
+
get provider(): string;
|
|
27
|
+
constructor(modelId: DeepgramTranscriptionModelId, config: DeepgramTranscriptionModelConfig);
|
|
28
|
+
private getArgs;
|
|
29
|
+
doGenerate(options: Parameters<TranscriptionModelV1['doGenerate']>[0]): Promise<Awaited<ReturnType<TranscriptionModelV1['doGenerate']>>>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface DeepgramProvider extends Pick<ProviderV1, 'transcriptionModel'> {
|
|
33
|
+
(modelId: 'nova-3', settings?: {}): {
|
|
34
|
+
transcription: DeepgramTranscriptionModel;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
Creates a model for transcription.
|
|
38
|
+
*/
|
|
39
|
+
transcription(modelId: DeepgramTranscriptionModelId): TranscriptionModelV1;
|
|
40
|
+
}
|
|
41
|
+
interface DeepgramProviderSettings {
|
|
42
|
+
/**
|
|
43
|
+
API key for authenticating requests.
|
|
44
|
+
*/
|
|
45
|
+
apiKey?: string;
|
|
46
|
+
/**
|
|
47
|
+
Custom headers to include in the requests.
|
|
48
|
+
*/
|
|
49
|
+
headers?: Record<string, string>;
|
|
50
|
+
/**
|
|
51
|
+
Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
52
|
+
or to provide a custom fetch implementation for e.g. testing.
|
|
53
|
+
*/
|
|
54
|
+
fetch?: FetchFunction;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
Create an Deepgram provider instance.
|
|
58
|
+
*/
|
|
59
|
+
declare function createDeepgram(options?: DeepgramProviderSettings): DeepgramProvider;
|
|
60
|
+
/**
|
|
61
|
+
Default Deepgram provider instance.
|
|
62
|
+
*/
|
|
63
|
+
declare const deepgram: DeepgramProvider;
|
|
64
|
+
|
|
65
|
+
export { type DeepgramProvider, type DeepgramProviderSettings, createDeepgram, deepgram };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { TranscriptionModelV1, ProviderV1 } from '@ai-sdk/provider';
|
|
2
|
+
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
+
|
|
4
|
+
type DeepgramConfig = {
|
|
5
|
+
provider: string;
|
|
6
|
+
url: (options: {
|
|
7
|
+
modelId: string;
|
|
8
|
+
path: string;
|
|
9
|
+
}) => string;
|
|
10
|
+
headers: () => Record<string, string | undefined>;
|
|
11
|
+
fetch?: FetchFunction;
|
|
12
|
+
generateId?: () => string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type DeepgramTranscriptionModelId = 'base' | 'base-general' | 'base-meeting' | 'base-phonecall' | 'base-finance' | 'base-conversationalai' | 'base-voicemail' | 'base-video' | 'enhanced' | 'enhanced-general' | 'enhanced-meeting' | 'enhanced-phonecall' | 'enhanced-finance' | 'nova' | 'nova-general' | 'nova-phonecall' | 'nova-medical' | 'nova-2' | 'nova-2-general' | 'nova-2-meeting' | 'nova-2-phonecall' | 'nova-2-finance' | 'nova-2-conversationalai' | 'nova-2-voicemail' | 'nova-2-video' | 'nova-2-medical' | 'nova-2-drivethru' | 'nova-2-automotive' | 'nova-2-atc' | 'nova-3' | 'nova-3-general' | 'nova-3-medical' | (string & {});
|
|
16
|
+
|
|
17
|
+
interface DeepgramTranscriptionModelConfig extends DeepgramConfig {
|
|
18
|
+
_internal?: {
|
|
19
|
+
currentDate?: () => Date;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
declare class DeepgramTranscriptionModel implements TranscriptionModelV1 {
|
|
23
|
+
readonly modelId: DeepgramTranscriptionModelId;
|
|
24
|
+
private readonly config;
|
|
25
|
+
readonly specificationVersion = "v1";
|
|
26
|
+
get provider(): string;
|
|
27
|
+
constructor(modelId: DeepgramTranscriptionModelId, config: DeepgramTranscriptionModelConfig);
|
|
28
|
+
private getArgs;
|
|
29
|
+
doGenerate(options: Parameters<TranscriptionModelV1['doGenerate']>[0]): Promise<Awaited<ReturnType<TranscriptionModelV1['doGenerate']>>>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface DeepgramProvider extends Pick<ProviderV1, 'transcriptionModel'> {
|
|
33
|
+
(modelId: 'nova-3', settings?: {}): {
|
|
34
|
+
transcription: DeepgramTranscriptionModel;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
Creates a model for transcription.
|
|
38
|
+
*/
|
|
39
|
+
transcription(modelId: DeepgramTranscriptionModelId): TranscriptionModelV1;
|
|
40
|
+
}
|
|
41
|
+
interface DeepgramProviderSettings {
|
|
42
|
+
/**
|
|
43
|
+
API key for authenticating requests.
|
|
44
|
+
*/
|
|
45
|
+
apiKey?: string;
|
|
46
|
+
/**
|
|
47
|
+
Custom headers to include in the requests.
|
|
48
|
+
*/
|
|
49
|
+
headers?: Record<string, string>;
|
|
50
|
+
/**
|
|
51
|
+
Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
52
|
+
or to provide a custom fetch implementation for e.g. testing.
|
|
53
|
+
*/
|
|
54
|
+
fetch?: FetchFunction;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
Create an Deepgram provider instance.
|
|
58
|
+
*/
|
|
59
|
+
declare function createDeepgram(options?: DeepgramProviderSettings): DeepgramProvider;
|
|
60
|
+
/**
|
|
61
|
+
Default Deepgram provider instance.
|
|
62
|
+
*/
|
|
63
|
+
declare const deepgram: DeepgramProvider;
|
|
64
|
+
|
|
65
|
+
export { type DeepgramProvider, type DeepgramProviderSettings, createDeepgram, deepgram };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
createDeepgram: () => createDeepgram,
|
|
24
|
+
deepgram: () => deepgram
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(src_exports);
|
|
27
|
+
|
|
28
|
+
// src/deepgram-provider.ts
|
|
29
|
+
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
30
|
+
|
|
31
|
+
// src/deepgram-transcription-model.ts
|
|
32
|
+
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
33
|
+
var import_zod2 = require("zod");
|
|
34
|
+
|
|
35
|
+
// src/deepgram-error.ts
|
|
36
|
+
var import_zod = require("zod");
|
|
37
|
+
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
38
|
+
var deepgramErrorDataSchema = import_zod.z.object({
|
|
39
|
+
error: import_zod.z.object({
|
|
40
|
+
message: import_zod.z.string(),
|
|
41
|
+
code: import_zod.z.number()
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
var deepgramFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
|
|
45
|
+
errorSchema: deepgramErrorDataSchema,
|
|
46
|
+
errorToMessage: (data) => data.error.message
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// src/deepgram-transcription-model.ts
|
|
50
|
+
var deepgramProviderOptionsSchema = import_zod2.z.object({
|
|
51
|
+
/** Language to use for transcription. If not specified, Deepgram will auto-detect the language. */
|
|
52
|
+
language: import_zod2.z.string().nullish(),
|
|
53
|
+
/** Whether to use smart formatting, which formats written-out numbers, dates, times, etc. */
|
|
54
|
+
smartFormat: import_zod2.z.boolean().nullish(),
|
|
55
|
+
/** Whether to add punctuation to the transcript. */
|
|
56
|
+
punctuate: import_zod2.z.boolean().nullish(),
|
|
57
|
+
/** Whether to format the transcript into paragraphs. */
|
|
58
|
+
paragraphs: import_zod2.z.boolean().nullish(),
|
|
59
|
+
/** Whether to generate a summary of the transcript. Use 'v2' for the latest version or false to disable. */
|
|
60
|
+
summarize: import_zod2.z.union([import_zod2.z.literal("v2"), import_zod2.z.literal(false)]).nullish(),
|
|
61
|
+
/** Whether to identify topics in the transcript. */
|
|
62
|
+
topics: import_zod2.z.boolean().nullish(),
|
|
63
|
+
/** Whether to identify intents in the transcript. */
|
|
64
|
+
intents: import_zod2.z.boolean().nullish(),
|
|
65
|
+
/** Whether to analyze sentiment in the transcript. */
|
|
66
|
+
sentiment: import_zod2.z.boolean().nullish(),
|
|
67
|
+
/** Whether to detect and tag named entities in the transcript. */
|
|
68
|
+
detectEntities: import_zod2.z.boolean().nullish(),
|
|
69
|
+
/** Specify terms or patterns to redact from the transcript. Can be a string or array of strings. */
|
|
70
|
+
redact: import_zod2.z.union([import_zod2.z.string(), import_zod2.z.array(import_zod2.z.string())]).nullish(),
|
|
71
|
+
/** String to replace redacted content with. */
|
|
72
|
+
replace: import_zod2.z.string().nullish(),
|
|
73
|
+
/** Term or phrase to search for in the transcript. */
|
|
74
|
+
search: import_zod2.z.string().nullish(),
|
|
75
|
+
/** Key term to identify in the transcript. */
|
|
76
|
+
keyterm: import_zod2.z.string().nullish(),
|
|
77
|
+
/** Whether to identify different speakers in the audio. */
|
|
78
|
+
diarize: import_zod2.z.boolean().nullish(),
|
|
79
|
+
/** Whether to segment the transcript into utterances. */
|
|
80
|
+
utterances: import_zod2.z.boolean().nullish(),
|
|
81
|
+
/** Minimum duration of silence (in seconds) to trigger a new utterance. */
|
|
82
|
+
uttSplit: import_zod2.z.number().nullish(),
|
|
83
|
+
/** Whether to include filler words (um, uh, etc.) in the transcript. */
|
|
84
|
+
fillerWords: import_zod2.z.boolean().nullish()
|
|
85
|
+
});
|
|
86
|
+
var DeepgramTranscriptionModel = class {
|
|
87
|
+
constructor(modelId, config) {
|
|
88
|
+
this.modelId = modelId;
|
|
89
|
+
this.config = config;
|
|
90
|
+
this.specificationVersion = "v1";
|
|
91
|
+
}
|
|
92
|
+
get provider() {
|
|
93
|
+
return this.config.provider;
|
|
94
|
+
}
|
|
95
|
+
getArgs({
|
|
96
|
+
providerOptions
|
|
97
|
+
}) {
|
|
98
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
99
|
+
const warnings = [];
|
|
100
|
+
const deepgramOptions = (0, import_provider_utils2.parseProviderOptions)({
|
|
101
|
+
provider: "deepgram",
|
|
102
|
+
providerOptions,
|
|
103
|
+
schema: deepgramProviderOptionsSchema
|
|
104
|
+
});
|
|
105
|
+
const body = {
|
|
106
|
+
model: this.modelId,
|
|
107
|
+
diarize: true
|
|
108
|
+
};
|
|
109
|
+
if (deepgramOptions) {
|
|
110
|
+
body.detect_entities = (_a = deepgramOptions.detectEntities) != null ? _a : void 0;
|
|
111
|
+
body.filler_words = (_b = deepgramOptions.fillerWords) != null ? _b : void 0;
|
|
112
|
+
body.language = (_c = deepgramOptions.language) != null ? _c : void 0;
|
|
113
|
+
body.punctuate = (_d = deepgramOptions.punctuate) != null ? _d : void 0;
|
|
114
|
+
body.redact = (_e = deepgramOptions.redact) != null ? _e : void 0;
|
|
115
|
+
body.search = (_f = deepgramOptions.search) != null ? _f : void 0;
|
|
116
|
+
body.smart_format = (_g = deepgramOptions.smartFormat) != null ? _g : void 0;
|
|
117
|
+
body.summarize = (_h = deepgramOptions.summarize) != null ? _h : void 0;
|
|
118
|
+
body.topics = (_i = deepgramOptions.topics) != null ? _i : void 0;
|
|
119
|
+
body.utterances = (_j = deepgramOptions.utterances) != null ? _j : void 0;
|
|
120
|
+
body.utt_split = (_k = deepgramOptions.uttSplit) != null ? _k : void 0;
|
|
121
|
+
if (typeof deepgramOptions.diarize === "boolean") {
|
|
122
|
+
body.diarize = deepgramOptions.diarize;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const queryParams = new URLSearchParams();
|
|
126
|
+
for (const [key, value] of Object.entries(body)) {
|
|
127
|
+
if (value !== void 0) {
|
|
128
|
+
queryParams.append(key, String(value));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
queryParams,
|
|
133
|
+
warnings
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
async doGenerate(options) {
|
|
137
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
138
|
+
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
139
|
+
const { queryParams, warnings } = this.getArgs(options);
|
|
140
|
+
const {
|
|
141
|
+
value: response,
|
|
142
|
+
responseHeaders,
|
|
143
|
+
rawValue: rawResponse
|
|
144
|
+
} = await (0, import_provider_utils2.postToApi)({
|
|
145
|
+
url: this.config.url({
|
|
146
|
+
path: "/v1/listen",
|
|
147
|
+
modelId: this.modelId
|
|
148
|
+
}) + "?" + queryParams.toString(),
|
|
149
|
+
headers: {
|
|
150
|
+
...(0, import_provider_utils2.combineHeaders)(this.config.headers(), options.headers),
|
|
151
|
+
"Content-Type": options.mediaType
|
|
152
|
+
},
|
|
153
|
+
body: {
|
|
154
|
+
content: options.audio,
|
|
155
|
+
values: options.audio
|
|
156
|
+
},
|
|
157
|
+
failedResponseHandler: deepgramFailedResponseHandler,
|
|
158
|
+
successfulResponseHandler: (0, import_provider_utils2.createJsonResponseHandler)(
|
|
159
|
+
deepgramTranscriptionResponseSchema
|
|
160
|
+
),
|
|
161
|
+
abortSignal: options.abortSignal,
|
|
162
|
+
fetch: this.config.fetch
|
|
163
|
+
});
|
|
164
|
+
return {
|
|
165
|
+
text: (_g = (_f = (_e = (_d = response.results) == null ? void 0 : _d.channels.at(0)) == null ? void 0 : _e.alternatives.at(0)) == null ? void 0 : _f.transcript) != null ? _g : "",
|
|
166
|
+
segments: (_j = (_i = (_h = response.results) == null ? void 0 : _h.channels[0].alternatives[0].words) == null ? void 0 : _i.map((word) => ({
|
|
167
|
+
text: word.word,
|
|
168
|
+
startSecond: word.start,
|
|
169
|
+
endSecond: word.end
|
|
170
|
+
}))) != null ? _j : [],
|
|
171
|
+
language: void 0,
|
|
172
|
+
durationInSeconds: (_l = (_k = response.metadata) == null ? void 0 : _k.duration) != null ? _l : void 0,
|
|
173
|
+
warnings,
|
|
174
|
+
response: {
|
|
175
|
+
timestamp: currentDate,
|
|
176
|
+
modelId: this.modelId,
|
|
177
|
+
headers: responseHeaders,
|
|
178
|
+
body: rawResponse
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
var deepgramTranscriptionResponseSchema = import_zod2.z.object({
|
|
184
|
+
metadata: import_zod2.z.object({
|
|
185
|
+
duration: import_zod2.z.number()
|
|
186
|
+
}).nullish(),
|
|
187
|
+
results: import_zod2.z.object({
|
|
188
|
+
channels: import_zod2.z.array(
|
|
189
|
+
import_zod2.z.object({
|
|
190
|
+
alternatives: import_zod2.z.array(
|
|
191
|
+
import_zod2.z.object({
|
|
192
|
+
transcript: import_zod2.z.string(),
|
|
193
|
+
words: import_zod2.z.array(
|
|
194
|
+
import_zod2.z.object({
|
|
195
|
+
word: import_zod2.z.string(),
|
|
196
|
+
start: import_zod2.z.number(),
|
|
197
|
+
end: import_zod2.z.number()
|
|
198
|
+
})
|
|
199
|
+
)
|
|
200
|
+
})
|
|
201
|
+
)
|
|
202
|
+
})
|
|
203
|
+
)
|
|
204
|
+
}).nullish()
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
// src/deepgram-provider.ts
|
|
208
|
+
function createDeepgram(options = {}) {
|
|
209
|
+
const getHeaders = () => ({
|
|
210
|
+
authorization: `Token ${(0, import_provider_utils3.loadApiKey)({
|
|
211
|
+
apiKey: options.apiKey,
|
|
212
|
+
environmentVariableName: "DEEPGRAM_API_KEY",
|
|
213
|
+
description: "Deepgram"
|
|
214
|
+
})}`,
|
|
215
|
+
...options.headers
|
|
216
|
+
});
|
|
217
|
+
const createTranscriptionModel = (modelId) => new DeepgramTranscriptionModel(modelId, {
|
|
218
|
+
provider: `deepgram.transcription`,
|
|
219
|
+
url: ({ path }) => `https://api.deepgram.com${path}`,
|
|
220
|
+
headers: getHeaders,
|
|
221
|
+
fetch: options.fetch
|
|
222
|
+
});
|
|
223
|
+
const provider = function(modelId) {
|
|
224
|
+
return {
|
|
225
|
+
transcription: createTranscriptionModel(modelId)
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
provider.transcription = createTranscriptionModel;
|
|
229
|
+
provider.transcriptionModel = createTranscriptionModel;
|
|
230
|
+
return provider;
|
|
231
|
+
}
|
|
232
|
+
var deepgram = createDeepgram();
|
|
233
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
234
|
+
0 && (module.exports = {
|
|
235
|
+
createDeepgram,
|
|
236
|
+
deepgram
|
|
237
|
+
});
|
|
238
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/deepgram-provider.ts","../src/deepgram-transcription-model.ts","../src/deepgram-error.ts"],"sourcesContent":["export { createDeepgram, deepgram } from './deepgram-provider';\nexport type {\n DeepgramProvider,\n DeepgramProviderSettings,\n} from './deepgram-provider';\n","import { TranscriptionModelV1, ProviderV1 } from '@ai-sdk/provider';\nimport { FetchFunction, loadApiKey } from '@ai-sdk/provider-utils';\nimport { DeepgramTranscriptionModel } from './deepgram-transcription-model';\nimport { DeepgramTranscriptionModelId } from './deepgram-transcription-settings';\n\nexport interface DeepgramProvider\n extends Pick<ProviderV1, 'transcriptionModel'> {\n (\n modelId: 'nova-3',\n settings?: {},\n ): {\n transcription: DeepgramTranscriptionModel;\n };\n\n /**\nCreates a model for transcription.\n */\n transcription(modelId: DeepgramTranscriptionModelId): TranscriptionModelV1;\n}\n\nexport interface DeepgramProviderSettings {\n /**\nAPI key for authenticating requests.\n */\n apiKey?: string;\n\n /**\nCustom headers to include in the requests.\n */\n headers?: Record<string, string>;\n\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\n/**\nCreate an Deepgram provider instance.\n */\nexport function createDeepgram(\n options: DeepgramProviderSettings = {},\n): DeepgramProvider {\n const getHeaders = () => ({\n authorization: `Token ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'DEEPGRAM_API_KEY',\n description: 'Deepgram',\n })}`,\n ...options.headers,\n });\n\n const createTranscriptionModel = (modelId: DeepgramTranscriptionModelId) =>\n new DeepgramTranscriptionModel(modelId, {\n provider: `deepgram.transcription`,\n url: ({ path }) => `https://api.deepgram.com${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const provider = function (modelId: DeepgramTranscriptionModelId) {\n return {\n transcription: createTranscriptionModel(modelId),\n };\n };\n\n provider.transcription = createTranscriptionModel;\n provider.transcriptionModel = createTranscriptionModel;\n\n return provider as DeepgramProvider;\n}\n\n/**\nDefault Deepgram provider instance.\n */\nexport const deepgram = createDeepgram();\n","import {\n TranscriptionModelV1,\n TranscriptionModelV1CallWarning,\n} from '@ai-sdk/provider';\nimport {\n combineHeaders,\n convertBase64ToUint8Array,\n createJsonResponseHandler,\n parseProviderOptions,\n postToApi,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\nimport { DeepgramConfig } from './deepgram-config';\nimport { deepgramFailedResponseHandler } from './deepgram-error';\nimport { DeepgramTranscriptionModelId } from './deepgram-transcription-settings';\nimport { DeepgramTranscriptionAPITypes } from './deepgram-api-types';\n\n// https://developers.deepgram.com/docs/pre-recorded-audio#results\nconst deepgramProviderOptionsSchema = z.object({\n /** Language to use for transcription. If not specified, Deepgram will auto-detect the language. */\n language: z.string().nullish(),\n /** Whether to use smart formatting, which formats written-out numbers, dates, times, etc. */\n smartFormat: z.boolean().nullish(),\n /** Whether to add punctuation to the transcript. */\n punctuate: z.boolean().nullish(),\n /** Whether to format the transcript into paragraphs. */\n paragraphs: z.boolean().nullish(),\n /** Whether to generate a summary of the transcript. Use 'v2' for the latest version or false to disable. */\n summarize: z.union([z.literal('v2'), z.literal(false)]).nullish(),\n /** Whether to identify topics in the transcript. */\n topics: z.boolean().nullish(),\n /** Whether to identify intents in the transcript. */\n intents: z.boolean().nullish(),\n /** Whether to analyze sentiment in the transcript. */\n sentiment: z.boolean().nullish(),\n /** Whether to detect and tag named entities in the transcript. */\n detectEntities: z.boolean().nullish(),\n /** Specify terms or patterns to redact from the transcript. Can be a string or array of strings. */\n redact: z.union([z.string(), z.array(z.string())]).nullish(),\n /** String to replace redacted content with. */\n replace: z.string().nullish(),\n /** Term or phrase to search for in the transcript. */\n search: z.string().nullish(),\n /** Key term to identify in the transcript. */\n keyterm: z.string().nullish(),\n /** Whether to identify different speakers in the audio. */\n diarize: z.boolean().nullish(),\n /** Whether to segment the transcript into utterances. */\n utterances: z.boolean().nullish(),\n /** Minimum duration of silence (in seconds) to trigger a new utterance. */\n uttSplit: z.number().nullish(),\n /** Whether to include filler words (um, uh, etc.) in the transcript. */\n fillerWords: z.boolean().nullish(),\n});\n\nexport type DeepgramTranscriptionCallOptions = z.infer<\n typeof deepgramProviderOptionsSchema\n>;\n\ninterface DeepgramTranscriptionModelConfig extends DeepgramConfig {\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class DeepgramTranscriptionModel implements TranscriptionModelV1 {\n readonly specificationVersion = 'v1';\n\n get provider(): string {\n return this.config.provider;\n }\n\n constructor(\n readonly modelId: DeepgramTranscriptionModelId,\n private readonly config: DeepgramTranscriptionModelConfig,\n ) {}\n\n private getArgs({\n providerOptions,\n }: Parameters<TranscriptionModelV1['doGenerate']>[0]) {\n const warnings: TranscriptionModelV1CallWarning[] = [];\n\n // Parse provider options\n const deepgramOptions = parseProviderOptions({\n provider: 'deepgram',\n providerOptions,\n schema: deepgramProviderOptionsSchema,\n });\n\n const body: DeepgramTranscriptionAPITypes = {\n model: this.modelId,\n diarize: true,\n };\n\n // Add provider-specific options\n if (deepgramOptions) {\n body.detect_entities = deepgramOptions.detectEntities ?? undefined;\n body.filler_words = deepgramOptions.fillerWords ?? undefined;\n body.language = deepgramOptions.language ?? undefined;\n body.punctuate = deepgramOptions.punctuate ?? undefined;\n body.redact = deepgramOptions.redact ?? undefined;\n body.search = deepgramOptions.search ?? undefined;\n body.smart_format = deepgramOptions.smartFormat ?? undefined;\n body.summarize = deepgramOptions.summarize ?? undefined;\n body.topics = deepgramOptions.topics ?? undefined;\n body.utterances = deepgramOptions.utterances ?? undefined;\n body.utt_split = deepgramOptions.uttSplit ?? undefined;\n\n if (typeof deepgramOptions.diarize === 'boolean') {\n body.diarize = deepgramOptions.diarize;\n }\n }\n\n // Convert body to URL query parameters\n const queryParams = new URLSearchParams();\n for (const [key, value] of Object.entries(body)) {\n if (value !== undefined) {\n queryParams.append(key, String(value));\n }\n }\n\n return {\n queryParams,\n warnings,\n };\n }\n\n async doGenerate(\n options: Parameters<TranscriptionModelV1['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<TranscriptionModelV1['doGenerate']>>> {\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const { queryParams, warnings } = this.getArgs(options);\n\n const {\n value: response,\n responseHeaders,\n rawValue: rawResponse,\n } = await postToApi({\n url:\n this.config.url({\n path: '/v1/listen',\n modelId: this.modelId,\n }) +\n '?' +\n queryParams.toString(),\n headers: {\n ...combineHeaders(this.config.headers(), options.headers),\n 'Content-Type': options.mediaType,\n },\n body: {\n content: options.audio,\n values: options.audio,\n },\n failedResponseHandler: deepgramFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n deepgramTranscriptionResponseSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n text:\n response.results?.channels.at(0)?.alternatives.at(0)?.transcript ?? '',\n segments:\n response.results?.channels[0].alternatives[0].words?.map(word => ({\n text: word.word,\n startSecond: word.start,\n endSecond: word.end,\n })) ?? [],\n language: undefined,\n durationInSeconds: response.metadata?.duration ?? undefined,\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n body: rawResponse,\n },\n };\n }\n}\n\nconst deepgramTranscriptionResponseSchema = z.object({\n metadata: z\n .object({\n duration: z.number(),\n })\n .nullish(),\n results: z\n .object({\n channels: z.array(\n z.object({\n alternatives: z.array(\n z.object({\n transcript: z.string(),\n words: z.array(\n z.object({\n word: z.string(),\n start: z.number(),\n end: z.number(),\n }),\n ),\n }),\n ),\n }),\n ),\n })\n .nullish(),\n});\n","import { z } from 'zod';\nimport { createJsonErrorResponseHandler } from '@ai-sdk/provider-utils';\n\nexport const deepgramErrorDataSchema = z.object({\n error: z.object({\n message: z.string(),\n code: z.number(),\n }),\n});\n\nexport type DeepgramErrorData = z.infer<typeof deepgramErrorDataSchema>;\n\nexport const deepgramFailedResponseHandler = createJson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;AAEH,QAAM,WAAW,SAAU,SAAuC;AAChE,WAAO;AAAA,MACL,eAAe,yBAAyB,OAAO;AAAA,IACjD;AAAA,EACF;AAEA,WAAS,gBAAgB;AACzB,WAAS,qBAAqB;AAE9B,SAAO;AACT;AAKO,IAAM,WAAW,eAAe;","names":["import_provider_utils","import_provider_utils","import_zod"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
// src/deepgram-provider.ts
|
|
2
|
+
import { loadApiKey } from "@ai-sdk/provider-utils";
|
|
3
|
+
|
|
4
|
+
// src/deepgram-transcription-model.ts
|
|
5
|
+
import {
|
|
6
|
+
combineHeaders,
|
|
7
|
+
createJsonResponseHandler,
|
|
8
|
+
parseProviderOptions,
|
|
9
|
+
postToApi
|
|
10
|
+
} from "@ai-sdk/provider-utils";
|
|
11
|
+
import { z as z2 } from "zod";
|
|
12
|
+
|
|
13
|
+
// src/deepgram-error.ts
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
16
|
+
var deepgramErrorDataSchema = z.object({
|
|
17
|
+
error: z.object({
|
|
18
|
+
message: z.string(),
|
|
19
|
+
code: z.number()
|
|
20
|
+
})
|
|
21
|
+
});
|
|
22
|
+
var deepgramFailedResponseHandler = createJsonErrorResponseHandler({
|
|
23
|
+
errorSchema: deepgramErrorDataSchema,
|
|
24
|
+
errorToMessage: (data) => data.error.message
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// src/deepgram-transcription-model.ts
|
|
28
|
+
var deepgramProviderOptionsSchema = z2.object({
|
|
29
|
+
/** Language to use for transcription. If not specified, Deepgram will auto-detect the language. */
|
|
30
|
+
language: z2.string().nullish(),
|
|
31
|
+
/** Whether to use smart formatting, which formats written-out numbers, dates, times, etc. */
|
|
32
|
+
smartFormat: z2.boolean().nullish(),
|
|
33
|
+
/** Whether to add punctuation to the transcript. */
|
|
34
|
+
punctuate: z2.boolean().nullish(),
|
|
35
|
+
/** Whether to format the transcript into paragraphs. */
|
|
36
|
+
paragraphs: z2.boolean().nullish(),
|
|
37
|
+
/** Whether to generate a summary of the transcript. Use 'v2' for the latest version or false to disable. */
|
|
38
|
+
summarize: z2.union([z2.literal("v2"), z2.literal(false)]).nullish(),
|
|
39
|
+
/** Whether to identify topics in the transcript. */
|
|
40
|
+
topics: z2.boolean().nullish(),
|
|
41
|
+
/** Whether to identify intents in the transcript. */
|
|
42
|
+
intents: z2.boolean().nullish(),
|
|
43
|
+
/** Whether to analyze sentiment in the transcript. */
|
|
44
|
+
sentiment: z2.boolean().nullish(),
|
|
45
|
+
/** Whether to detect and tag named entities in the transcript. */
|
|
46
|
+
detectEntities: z2.boolean().nullish(),
|
|
47
|
+
/** Specify terms or patterns to redact from the transcript. Can be a string or array of strings. */
|
|
48
|
+
redact: z2.union([z2.string(), z2.array(z2.string())]).nullish(),
|
|
49
|
+
/** String to replace redacted content with. */
|
|
50
|
+
replace: z2.string().nullish(),
|
|
51
|
+
/** Term or phrase to search for in the transcript. */
|
|
52
|
+
search: z2.string().nullish(),
|
|
53
|
+
/** Key term to identify in the transcript. */
|
|
54
|
+
keyterm: z2.string().nullish(),
|
|
55
|
+
/** Whether to identify different speakers in the audio. */
|
|
56
|
+
diarize: z2.boolean().nullish(),
|
|
57
|
+
/** Whether to segment the transcript into utterances. */
|
|
58
|
+
utterances: z2.boolean().nullish(),
|
|
59
|
+
/** Minimum duration of silence (in seconds) to trigger a new utterance. */
|
|
60
|
+
uttSplit: z2.number().nullish(),
|
|
61
|
+
/** Whether to include filler words (um, uh, etc.) in the transcript. */
|
|
62
|
+
fillerWords: z2.boolean().nullish()
|
|
63
|
+
});
|
|
64
|
+
var DeepgramTranscriptionModel = class {
|
|
65
|
+
constructor(modelId, config) {
|
|
66
|
+
this.modelId = modelId;
|
|
67
|
+
this.config = config;
|
|
68
|
+
this.specificationVersion = "v1";
|
|
69
|
+
}
|
|
70
|
+
get provider() {
|
|
71
|
+
return this.config.provider;
|
|
72
|
+
}
|
|
73
|
+
getArgs({
|
|
74
|
+
providerOptions
|
|
75
|
+
}) {
|
|
76
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
77
|
+
const warnings = [];
|
|
78
|
+
const deepgramOptions = parseProviderOptions({
|
|
79
|
+
provider: "deepgram",
|
|
80
|
+
providerOptions,
|
|
81
|
+
schema: deepgramProviderOptionsSchema
|
|
82
|
+
});
|
|
83
|
+
const body = {
|
|
84
|
+
model: this.modelId,
|
|
85
|
+
diarize: true
|
|
86
|
+
};
|
|
87
|
+
if (deepgramOptions) {
|
|
88
|
+
body.detect_entities = (_a = deepgramOptions.detectEntities) != null ? _a : void 0;
|
|
89
|
+
body.filler_words = (_b = deepgramOptions.fillerWords) != null ? _b : void 0;
|
|
90
|
+
body.language = (_c = deepgramOptions.language) != null ? _c : void 0;
|
|
91
|
+
body.punctuate = (_d = deepgramOptions.punctuate) != null ? _d : void 0;
|
|
92
|
+
body.redact = (_e = deepgramOptions.redact) != null ? _e : void 0;
|
|
93
|
+
body.search = (_f = deepgramOptions.search) != null ? _f : void 0;
|
|
94
|
+
body.smart_format = (_g = deepgramOptions.smartFormat) != null ? _g : void 0;
|
|
95
|
+
body.summarize = (_h = deepgramOptions.summarize) != null ? _h : void 0;
|
|
96
|
+
body.topics = (_i = deepgramOptions.topics) != null ? _i : void 0;
|
|
97
|
+
body.utterances = (_j = deepgramOptions.utterances) != null ? _j : void 0;
|
|
98
|
+
body.utt_split = (_k = deepgramOptions.uttSplit) != null ? _k : void 0;
|
|
99
|
+
if (typeof deepgramOptions.diarize === "boolean") {
|
|
100
|
+
body.diarize = deepgramOptions.diarize;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const queryParams = new URLSearchParams();
|
|
104
|
+
for (const [key, value] of Object.entries(body)) {
|
|
105
|
+
if (value !== void 0) {
|
|
106
|
+
queryParams.append(key, String(value));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
queryParams,
|
|
111
|
+
warnings
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
async doGenerate(options) {
|
|
115
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
116
|
+
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
117
|
+
const { queryParams, warnings } = this.getArgs(options);
|
|
118
|
+
const {
|
|
119
|
+
value: response,
|
|
120
|
+
responseHeaders,
|
|
121
|
+
rawValue: rawResponse
|
|
122
|
+
} = await postToApi({
|
|
123
|
+
url: this.config.url({
|
|
124
|
+
path: "/v1/listen",
|
|
125
|
+
modelId: this.modelId
|
|
126
|
+
}) + "?" + queryParams.toString(),
|
|
127
|
+
headers: {
|
|
128
|
+
...combineHeaders(this.config.headers(), options.headers),
|
|
129
|
+
"Content-Type": options.mediaType
|
|
130
|
+
},
|
|
131
|
+
body: {
|
|
132
|
+
content: options.audio,
|
|
133
|
+
values: options.audio
|
|
134
|
+
},
|
|
135
|
+
failedResponseHandler: deepgramFailedResponseHandler,
|
|
136
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
137
|
+
deepgramTranscriptionResponseSchema
|
|
138
|
+
),
|
|
139
|
+
abortSignal: options.abortSignal,
|
|
140
|
+
fetch: this.config.fetch
|
|
141
|
+
});
|
|
142
|
+
return {
|
|
143
|
+
text: (_g = (_f = (_e = (_d = response.results) == null ? void 0 : _d.channels.at(0)) == null ? void 0 : _e.alternatives.at(0)) == null ? void 0 : _f.transcript) != null ? _g : "",
|
|
144
|
+
segments: (_j = (_i = (_h = response.results) == null ? void 0 : _h.channels[0].alternatives[0].words) == null ? void 0 : _i.map((word) => ({
|
|
145
|
+
text: word.word,
|
|
146
|
+
startSecond: word.start,
|
|
147
|
+
endSecond: word.end
|
|
148
|
+
}))) != null ? _j : [],
|
|
149
|
+
language: void 0,
|
|
150
|
+
durationInSeconds: (_l = (_k = response.metadata) == null ? void 0 : _k.duration) != null ? _l : void 0,
|
|
151
|
+
warnings,
|
|
152
|
+
response: {
|
|
153
|
+
timestamp: currentDate,
|
|
154
|
+
modelId: this.modelId,
|
|
155
|
+
headers: responseHeaders,
|
|
156
|
+
body: rawResponse
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
var deepgramTranscriptionResponseSchema = z2.object({
|
|
162
|
+
metadata: z2.object({
|
|
163
|
+
duration: z2.number()
|
|
164
|
+
}).nullish(),
|
|
165
|
+
results: z2.object({
|
|
166
|
+
channels: z2.array(
|
|
167
|
+
z2.object({
|
|
168
|
+
alternatives: z2.array(
|
|
169
|
+
z2.object({
|
|
170
|
+
transcript: z2.string(),
|
|
171
|
+
words: z2.array(
|
|
172
|
+
z2.object({
|
|
173
|
+
word: z2.string(),
|
|
174
|
+
start: z2.number(),
|
|
175
|
+
end: z2.number()
|
|
176
|
+
})
|
|
177
|
+
)
|
|
178
|
+
})
|
|
179
|
+
)
|
|
180
|
+
})
|
|
181
|
+
)
|
|
182
|
+
}).nullish()
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// src/deepgram-provider.ts
|
|
186
|
+
function createDeepgram(options = {}) {
|
|
187
|
+
const getHeaders = () => ({
|
|
188
|
+
authorization: `Token ${loadApiKey({
|
|
189
|
+
apiKey: options.apiKey,
|
|
190
|
+
environmentVariableName: "DEEPGRAM_API_KEY",
|
|
191
|
+
description: "Deepgram"
|
|
192
|
+
})}`,
|
|
193
|
+
...options.headers
|
|
194
|
+
});
|
|
195
|
+
const createTranscriptionModel = (modelId) => new DeepgramTranscriptionModel(modelId, {
|
|
196
|
+
provider: `deepgram.transcription`,
|
|
197
|
+
url: ({ path }) => `https://api.deepgram.com${path}`,
|
|
198
|
+
headers: getHeaders,
|
|
199
|
+
fetch: options.fetch
|
|
200
|
+
});
|
|
201
|
+
const provider = function(modelId) {
|
|
202
|
+
return {
|
|
203
|
+
transcription: createTranscriptionModel(modelId)
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
provider.transcription = createTranscriptionModel;
|
|
207
|
+
provider.transcriptionModel = createTranscriptionModel;
|
|
208
|
+
return provider;
|
|
209
|
+
}
|
|
210
|
+
var deepgram = createDeepgram();
|
|
211
|
+
export {
|
|
212
|
+
createDeepgram,
|
|
213
|
+
deepgram
|
|
214
|
+
};
|
|
215
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/deepgram-provider.ts","../src/deepgram-transcription-model.ts","../src/deepgram-error.ts"],"sourcesContent":["import { TranscriptionModelV1, ProviderV1 } from '@ai-sdk/provider';\nimport { FetchFunction, loadApiKey } from '@ai-sdk/provider-utils';\nimport { DeepgramTranscriptionModel } from './deepgram-transcription-model';\nimport { DeepgramTranscriptionModelId } from './deepgram-transcription-settings';\n\nexport interface DeepgramProvider\n extends Pick<ProviderV1, 'transcriptionModel'> {\n (\n modelId: 'nova-3',\n settings?: {},\n ): {\n transcription: DeepgramTranscriptionModel;\n };\n\n /**\nCreates a model for transcription.\n */\n transcription(modelId: DeepgramTranscriptionModelId): TranscriptionModelV1;\n}\n\nexport interface DeepgramProviderSettings {\n /**\nAPI key for authenticating requests.\n */\n apiKey?: string;\n\n /**\nCustom headers to include in the requests.\n */\n headers?: Record<string, string>;\n\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\n/**\nCreate an Deepgram provider instance.\n */\nexport function createDeepgram(\n options: DeepgramProviderSettings = {},\n): DeepgramProvider {\n const getHeaders = () => ({\n authorization: `Token ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'DEEPGRAM_API_KEY',\n description: 'Deepgram',\n })}`,\n ...options.headers,\n });\n\n const createTranscriptionModel = (modelId: DeepgramTranscriptionModelId) =>\n new DeepgramTranscriptionModel(modelId, {\n provider: `deepgram.transcription`,\n url: ({ path }) => `https://api.deepgram.com${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const provider = function (modelId: DeepgramTranscriptionModelId) {\n return {\n transcription: createTranscriptionModel(modelId),\n };\n };\n\n provider.transcription = createTranscriptionModel;\n provider.transcriptionModel = createTranscriptionModel;\n\n return provider as DeepgramProvider;\n}\n\n/**\nDefault Deepgram provider instance.\n */\nexport const deepgram = createDeepgram();\n","import {\n TranscriptionModelV1,\n TranscriptionModelV1CallWarning,\n} from '@ai-sdk/provider';\nimport {\n combineHeaders,\n convertBase64ToUint8Array,\n createJsonResponseHandler,\n parseProviderOptions,\n postToApi,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\nimport { DeepgramConfig } from './deepgram-config';\nimport { deepgramFailedResponseHandler } from './deepgram-error';\nimport { DeepgramTranscriptionModelId } from './deepgram-transcription-settings';\nimport { DeepgramTranscriptionAPITypes } from './deepgram-api-types';\n\n// https://developers.deepgram.com/docs/pre-recorded-audio#results\nconst deepgramProviderOptionsSchema = z.object({\n /** Language to use for transcription. If not specified, Deepgram will auto-detect the language. */\n language: z.string().nullish(),\n /** Whether to use smart formatting, which formats written-out numbers, dates, times, etc. */\n smartFormat: z.boolean().nullish(),\n /** Whether to add punctuation to the transcript. */\n punctuate: z.boolean().nullish(),\n /** Whether to format the transcript into paragraphs. */\n paragraphs: z.boolean().nullish(),\n /** Whether to generate a summary of the transcript. Use 'v2' for the latest version or false to disable. */\n summarize: z.union([z.literal('v2'), z.literal(false)]).nullish(),\n /** Whether to identify topics in the transcript. */\n topics: z.boolean().nullish(),\n /** Whether to identify intents in the transcript. */\n intents: z.boolean().nullish(),\n /** Whether to analyze sentiment in the transcript. */\n sentiment: z.boolean().nullish(),\n /** Whether to detect and tag named entities in the transcript. */\n detectEntities: z.boolean().nullish(),\n /** Specify terms or patterns to redact from the transcript. Can be a string or array of strings. */\n redact: z.union([z.string(), z.array(z.string())]).nullish(),\n /** String to replace redacted content with. */\n replace: z.string().nullish(),\n /** Term or phrase to search for in the transcript. */\n search: z.string().nullish(),\n /** Key term to identify in the transcript. */\n keyterm: z.string().nullish(),\n /** Whether to identify different speakers in the audio. */\n diarize: z.boolean().nullish(),\n /** Whether to segment the transcript into utterances. */\n utterances: z.boolean().nullish(),\n /** Minimum duration of silence (in seconds) to trigger a new utterance. */\n uttSplit: z.number().nullish(),\n /** Whether to include filler words (um, uh, etc.) in the transcript. */\n fillerWords: z.boolean().nullish(),\n});\n\nexport type DeepgramTranscriptionCallOptions = z.infer<\n typeof deepgramProviderOptionsSchema\n>;\n\ninterface DeepgramTranscriptionModelConfig extends DeepgramConfig {\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class DeepgramTranscriptionModel implements TranscriptionModelV1 {\n readonly specificationVersion = 'v1';\n\n get provider(): string {\n return this.config.provider;\n }\n\n constructor(\n readonly modelId: DeepgramTranscriptionModelId,\n private readonly config: DeepgramTranscriptionModelConfig,\n ) {}\n\n private getArgs({\n providerOptions,\n }: Parameters<TranscriptionModelV1['doGenerate']>[0]) {\n const warnings: TranscriptionModelV1CallWarning[] = [];\n\n // Parse provider options\n const deepgramOptions = parseProviderOptions({\n provider: 'deepgram',\n providerOptions,\n schema: deepgramProviderOptionsSchema,\n });\n\n const body: DeepgramTranscriptionAPITypes = {\n model: this.modelId,\n diarize: true,\n };\n\n // Add provider-specific options\n if (deepgramOptions) {\n body.detect_entities = deepgramOptions.detectEntities ?? undefined;\n body.filler_words = deepgramOptions.fillerWords ?? undefined;\n body.language = deepgramOptions.language ?? undefined;\n body.punctuate = deepgramOptions.punctuate ?? undefined;\n body.redact = deepgramOptions.redact ?? undefined;\n body.search = deepgramOptions.search ?? undefined;\n body.smart_format = deepgramOptions.smartFormat ?? undefined;\n body.summarize = deepgramOptions.summarize ?? undefined;\n body.topics = deepgramOptions.topics ?? undefined;\n body.utterances = deepgramOptions.utterances ?? undefined;\n body.utt_split = deepgramOptions.uttSplit ?? undefined;\n\n if (typeof deepgramOptions.diarize === 'boolean') {\n body.diarize = deepgramOptions.diarize;\n }\n }\n\n // Convert body to URL query parameters\n const queryParams = new URLSearchParams();\n for (const [key, value] of Object.entries(body)) {\n if (value !== undefined) {\n queryParams.append(key, String(value));\n }\n }\n\n return {\n queryParams,\n warnings,\n };\n }\n\n async doGenerate(\n options: Parameters<TranscriptionModelV1['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<TranscriptionModelV1['doGenerate']>>> {\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const { queryParams, warnings } = this.getArgs(options);\n\n const {\n value: response,\n responseHeaders,\n rawValue: rawResponse,\n } = await postToApi({\n url:\n this.config.url({\n path: '/v1/listen',\n modelId: this.modelId,\n }) +\n '?' +\n queryParams.toString(),\n headers: {\n ...combineHeaders(this.config.headers(), options.headers),\n 'Content-Type': options.mediaType,\n },\n body: {\n content: options.audio,\n values: options.audio,\n },\n failedResponseHandler: deepgramFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n deepgramTranscriptionResponseSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n text:\n response.results?.channels.at(0)?.alternatives.at(0)?.transcript ?? '',\n segments:\n response.results?.channels[0].alternatives[0].words?.map(word => ({\n text: word.word,\n startSecond: word.start,\n endSecond: word.end,\n })) ?? [],\n language: undefined,\n durationInSeconds: response.metadata?.duration ?? undefined,\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n body: rawResponse,\n },\n };\n }\n}\n\nconst deepgramTranscriptionResponseSchema = z.object({\n metadata: z\n .object({\n duration: z.number(),\n })\n .nullish(),\n results: z\n .object({\n channels: z.array(\n z.object({\n alternatives: z.array(\n z.object({\n transcript: z.string(),\n words: z.array(\n z.object({\n word: z.string(),\n start: z.number(),\n end: z.number(),\n }),\n ),\n }),\n ),\n }),\n ),\n })\n .nullish(),\n});\n","import { z } from 'zod';\nimport { createJsonErrorResponseHandler } from '@ai-sdk/provider-utils';\n\nexport const deepgramErrorDataSchema = z.object({\n error: z.object({\n message: z.string(),\n code: z.number(),\n }),\n});\n\nexport type DeepgramErrorData = z.infer<typeof deepgramErrorDataSchema>;\n\nexport const deepgramFailedResponseHandler = createJsonErrorResponseHandler({\n errorSchema: deepgramErrorDataSchema,\n errorToMessage: data => data.error.message,\n});\n"],"mappings":";AACA,SAAwB,kBAAkB;;;ACG1C;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,KAAAA,UAAS;;;ACXlB,SAAS,SAAS;AAClB,SAAS,sCAAsC;AAExC,IAAM,0BAA0B,EAAE,OAAO;AAAA,EAC9C,OAAO,EAAE,OAAO;AAAA,IACd,SAAS,EAAE,OAAO;AAAA,IAClB,MAAM,EAAE,OAAO;AAAA,EACjB,CAAC;AACH,CAAC;AAIM,IAAM,gCAAgC,+BAA+B;AAAA,EAC1E,aAAa;AAAA,EACb,gBAAgB,UAAQ,KAAK,MAAM;AACrC,CAAC;;;ADGD,IAAM,gCAAgCC,GAAE,OAAO;AAAA;AAAA,EAE7C,UAAUA,GAAE,OAAO,EAAE,QAAQ;AAAA;AAAA,EAE7B,aAAaA,GAAE,QAAQ,EAAE,QAAQ;AAAA;AAAA,EAEjC,WAAWA,GAAE,QAAQ,EAAE,QAAQ;AAAA;AAAA,EAE/B,YAAYA,GAAE,QAAQ,EAAE,QAAQ;AAAA;AAAA,EAEhC,WAAWA,GAAE,MAAM,CAACA,GAAE,QAAQ,IAAI,GAAGA,GAAE,QAAQ,KAAK,CAAC,CAAC,EAAE,QAAQ;AAAA;AAAA,EAEhE,QAAQA,GAAE,QAAQ,EAAE,QAAQ;AAAA;AAAA,EAE5B,SAASA,GAAE,QAAQ,EAAE,QAAQ;AAAA;AAAA,EAE7B,WAAWA,GAAE,QAAQ,EAAE,QAAQ;AAAA;AAAA,EAE/B,gBAAgBA,GAAE,QAAQ,EAAE,QAAQ;AAA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Q;AAAA,EACb;AAEA,QAAM,2BAA2B,CAAC,YAChC,IAAI,2BAA2B,SAAS;AAAA,IACtC,UAAU;AAAA,IACV,KAAK,CAAC,EAAE,KAAK,MAAM,2BAA2B,IAAI;AAAA,IAClD,SAAS;AAAA,IACT,OAAO,QAAQ;AAAA,EACjB,CAAC;AAEH,QAAM,WAAW,SAAU,SAAuC;AAChE,WAAO;AAAA,MACL,eAAe,yBAAyB,OAAO;AAAA,IACjD;AAAA,EACF;AAEA,WAAS,gBAAgB;AACzB,WAAS,qBAAqB;AAE9B,SAAO;AACT;AAKO,IAAM,WAAW,eAAe;","names":["z","z"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ai-sdk/deepgram",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/**/*",
|
|
11
|
+
"CHANGELOG.md"
|
|
12
|
+
],
|
|
13
|
+
"exports": {
|
|
14
|
+
"./package.json": "./package.json",
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.mjs",
|
|
18
|
+
"require": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@ai-sdk/provider": "1.1.2",
|
|
23
|
+
"@ai-sdk/provider-utils": "2.2.6"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "20.17.24",
|
|
27
|
+
"tsup": "^8",
|
|
28
|
+
"typescript": "5.6.3",
|
|
29
|
+
"zod": "3.23.8",
|
|
30
|
+
"@vercel/ai-tsconfig": "0.0.0"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"zod": "^3.0.0"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=18"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://sdk.vercel.ai/docs",
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "git+https://github.com/vercel/ai.git"
|
|
45
|
+
},
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/vercel/ai/issues"
|
|
48
|
+
},
|
|
49
|
+
"keywords": [
|
|
50
|
+
"ai"
|
|
51
|
+
],
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsup",
|
|
54
|
+
"build:watch": "tsup --watch",
|
|
55
|
+
"clean": "rm -rf dist",
|
|
56
|
+
"lint": "eslint \"./**/*.ts*\"",
|
|
57
|
+
"type-check": "tsc --noEmit",
|
|
58
|
+
"prettier-check": "prettier --check \"./**/*.ts*\"",
|
|
59
|
+
"test": "pnpm test:node && pnpm test:edge",
|
|
60
|
+
"test:edge": "vitest --config vitest.edge.config.js --run",
|
|
61
|
+
"test:node": "vitest --config vitest.node.config.js --run",
|
|
62
|
+
"test:node:watch": "vitest --config vitest.node.config.js --watch"
|
|
63
|
+
}
|
|
64
|
+
}
|