@ai-sdk/assemblyai 3.0.0-beta.20 → 3.0.0-beta.22
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 +29 -0
- package/dist/index.d.ts +12 -3
- package/dist/index.js +117 -122
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/assemblyai-config.ts +1 -1
- package/src/assemblyai-transcription-model.ts +21 -4
- package/src/assemblyai-transcription-settings.ts +1 -1
- package/dist/index.d.mts +0 -123
- package/dist/index.mjs +0 -439
- package/dist/index.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @ai-sdk/assemblyai
|
|
2
2
|
|
|
3
|
+
## 3.0.0-beta.22
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b3976a2: Add workflow serialization support to all provider models.
|
|
8
|
+
|
|
9
|
+
**`@ai-sdk/provider-utils`:** New `serializeModel()` helper that extracts only serializable properties from a model instance, filtering out functions and objects containing functions. Third-party provider authors can use this to add workflow support to their own models.
|
|
10
|
+
|
|
11
|
+
**All providers:** `headers` is now optional in provider config types. This is non-breaking — existing code that passes `headers` continues to work. Custom provider implementations that construct model configs manually can now omit `headers`, which is useful when models are deserialized from a workflow step boundary where auth is provided separately.
|
|
12
|
+
|
|
13
|
+
All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [b3976a2]
|
|
16
|
+
- Updated dependencies [ff5eba1]
|
|
17
|
+
- @ai-sdk/provider-utils@5.0.0-beta.20
|
|
18
|
+
- @ai-sdk/provider@4.0.0-beta.12
|
|
19
|
+
|
|
20
|
+
## 3.0.0-beta.21
|
|
21
|
+
|
|
22
|
+
### Major Changes
|
|
23
|
+
|
|
24
|
+
- ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [ef992f8]
|
|
29
|
+
- @ai-sdk/provider@4.0.0-beta.11
|
|
30
|
+
- @ai-sdk/provider-utils@5.0.0-beta.19
|
|
31
|
+
|
|
3
32
|
## 3.0.0-beta.20
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
1
2
|
import { TranscriptionModelV4, ProviderV4 } from '@ai-sdk/provider';
|
|
2
|
-
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
+
import { FetchFunction, WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@ai-sdk/provider-utils';
|
|
3
4
|
import { z } from 'zod/v4';
|
|
4
5
|
|
|
5
6
|
type AssemblyAIConfig = {
|
|
@@ -8,12 +9,12 @@ type AssemblyAIConfig = {
|
|
|
8
9
|
modelId: string;
|
|
9
10
|
path: string;
|
|
10
11
|
}) => string;
|
|
11
|
-
headers
|
|
12
|
+
headers?: () => Record<string, string | undefined>;
|
|
12
13
|
fetch?: FetchFunction;
|
|
13
14
|
generateId?: () => string;
|
|
14
15
|
};
|
|
15
16
|
|
|
16
|
-
type AssemblyAITranscriptionModelId = 'best' | 'nano';
|
|
17
|
+
type AssemblyAITranscriptionModelId = 'best' | 'nano' | (string & {});
|
|
17
18
|
|
|
18
19
|
declare const assemblyaiTranscriptionModelOptionsSchema: z.ZodObject<{
|
|
19
20
|
audioEndAt: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
@@ -70,6 +71,14 @@ declare class AssemblyAITranscriptionModel implements TranscriptionModelV4 {
|
|
|
70
71
|
readonly specificationVersion = "v4";
|
|
71
72
|
private readonly POLLING_INTERVAL_MS;
|
|
72
73
|
get provider(): string;
|
|
74
|
+
static [WORKFLOW_SERIALIZE](model: AssemblyAITranscriptionModel): {
|
|
75
|
+
modelId: string;
|
|
76
|
+
config: _ai_sdk_provider.JSONObject;
|
|
77
|
+
};
|
|
78
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
79
|
+
modelId: AssemblyAITranscriptionModelId;
|
|
80
|
+
config: AssemblyAITranscriptionModelConfig;
|
|
81
|
+
}): AssemblyAITranscriptionModel;
|
|
73
82
|
constructor(modelId: AssemblyAITranscriptionModelId, config: AssemblyAITranscriptionModelConfig);
|
|
74
83
|
private getArgs;
|
|
75
84
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,199 +1,186 @@
|
|
|
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 index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
VERSION: () => VERSION,
|
|
24
|
-
assemblyai: () => assemblyai,
|
|
25
|
-
createAssemblyAI: () => createAssemblyAI
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(index_exports);
|
|
28
|
-
|
|
29
1
|
// src/assemblyai-provider.ts
|
|
30
|
-
|
|
31
|
-
|
|
2
|
+
import {
|
|
3
|
+
NoSuchModelError
|
|
4
|
+
} from "@ai-sdk/provider";
|
|
5
|
+
import {
|
|
6
|
+
loadApiKey,
|
|
7
|
+
withUserAgentSuffix
|
|
8
|
+
} from "@ai-sdk/provider-utils";
|
|
32
9
|
|
|
33
10
|
// src/assemblyai-transcription-model.ts
|
|
34
|
-
|
|
35
|
-
|
|
11
|
+
import {
|
|
12
|
+
combineHeaders,
|
|
13
|
+
createJsonResponseHandler,
|
|
14
|
+
extractResponseHeaders,
|
|
15
|
+
parseProviderOptions,
|
|
16
|
+
postJsonToApi,
|
|
17
|
+
postToApi,
|
|
18
|
+
serializeModelOptions,
|
|
19
|
+
WORKFLOW_SERIALIZE,
|
|
20
|
+
WORKFLOW_DESERIALIZE
|
|
21
|
+
} from "@ai-sdk/provider-utils";
|
|
22
|
+
import { z as z2 } from "zod/v4";
|
|
36
23
|
|
|
37
24
|
// src/assemblyai-error.ts
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var assemblyaiErrorDataSchema =
|
|
41
|
-
error:
|
|
42
|
-
message:
|
|
43
|
-
code:
|
|
25
|
+
import { z } from "zod/v4";
|
|
26
|
+
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
27
|
+
var assemblyaiErrorDataSchema = z.object({
|
|
28
|
+
error: z.object({
|
|
29
|
+
message: z.string(),
|
|
30
|
+
code: z.number()
|
|
44
31
|
})
|
|
45
32
|
});
|
|
46
|
-
var assemblyaiFailedResponseHandler =
|
|
33
|
+
var assemblyaiFailedResponseHandler = createJsonErrorResponseHandler({
|
|
47
34
|
errorSchema: assemblyaiErrorDataSchema,
|
|
48
35
|
errorToMessage: (data) => data.error.message
|
|
49
36
|
});
|
|
50
37
|
|
|
51
38
|
// src/assemblyai-transcription-model.ts
|
|
52
|
-
var assemblyaiTranscriptionModelOptionsSchema =
|
|
39
|
+
var assemblyaiTranscriptionModelOptionsSchema = z2.object({
|
|
53
40
|
/**
|
|
54
41
|
* End time of the audio in milliseconds.
|
|
55
42
|
*/
|
|
56
|
-
audioEndAt:
|
|
43
|
+
audioEndAt: z2.number().int().nullish(),
|
|
57
44
|
/**
|
|
58
45
|
* Start time of the audio in milliseconds.
|
|
59
46
|
*/
|
|
60
|
-
audioStartFrom:
|
|
47
|
+
audioStartFrom: z2.number().int().nullish(),
|
|
61
48
|
/**
|
|
62
49
|
* Whether to automatically generate chapters for the transcription.
|
|
63
50
|
*/
|
|
64
|
-
autoChapters:
|
|
51
|
+
autoChapters: z2.boolean().nullish(),
|
|
65
52
|
/**
|
|
66
53
|
* Whether to automatically generate highlights for the transcription.
|
|
67
54
|
*/
|
|
68
|
-
autoHighlights:
|
|
55
|
+
autoHighlights: z2.boolean().nullish(),
|
|
69
56
|
/**
|
|
70
57
|
* Boost parameter for the transcription.
|
|
71
58
|
* Allowed values: 'low', 'default', 'high'.
|
|
72
59
|
*/
|
|
73
|
-
boostParam:
|
|
60
|
+
boostParam: z2.string().nullish(),
|
|
74
61
|
/**
|
|
75
62
|
* Whether to enable content safety filtering.
|
|
76
63
|
*/
|
|
77
|
-
contentSafety:
|
|
64
|
+
contentSafety: z2.boolean().nullish(),
|
|
78
65
|
/**
|
|
79
66
|
* Confidence threshold for content safety filtering (25-100).
|
|
80
67
|
*/
|
|
81
|
-
contentSafetyConfidence:
|
|
68
|
+
contentSafetyConfidence: z2.number().int().min(25).max(100).nullish(),
|
|
82
69
|
/**
|
|
83
70
|
* Custom spelling rules for the transcription.
|
|
84
71
|
*/
|
|
85
|
-
customSpelling:
|
|
86
|
-
|
|
87
|
-
from:
|
|
88
|
-
to:
|
|
72
|
+
customSpelling: z2.array(
|
|
73
|
+
z2.object({
|
|
74
|
+
from: z2.array(z2.string()),
|
|
75
|
+
to: z2.string()
|
|
89
76
|
})
|
|
90
77
|
).nullish(),
|
|
91
78
|
/**
|
|
92
79
|
* Whether to include filler words (um, uh, etc.) in the transcription.
|
|
93
80
|
*/
|
|
94
|
-
disfluencies:
|
|
81
|
+
disfluencies: z2.boolean().nullish(),
|
|
95
82
|
/**
|
|
96
83
|
* Whether to enable entity detection.
|
|
97
84
|
*/
|
|
98
|
-
entityDetection:
|
|
85
|
+
entityDetection: z2.boolean().nullish(),
|
|
99
86
|
/**
|
|
100
87
|
* Whether to filter profanity from the transcription.
|
|
101
88
|
*/
|
|
102
|
-
filterProfanity:
|
|
89
|
+
filterProfanity: z2.boolean().nullish(),
|
|
103
90
|
/**
|
|
104
91
|
* Whether to format text with punctuation and capitalization.
|
|
105
92
|
*/
|
|
106
|
-
formatText:
|
|
93
|
+
formatText: z2.boolean().nullish(),
|
|
107
94
|
/**
|
|
108
95
|
* Whether to enable IAB categories detection.
|
|
109
96
|
*/
|
|
110
|
-
iabCategories:
|
|
97
|
+
iabCategories: z2.boolean().nullish(),
|
|
111
98
|
/**
|
|
112
99
|
* Language code for the transcription.
|
|
113
100
|
*/
|
|
114
|
-
languageCode:
|
|
101
|
+
languageCode: z2.union([z2.literal("en"), z2.string()]).nullish(),
|
|
115
102
|
/**
|
|
116
103
|
* Confidence threshold for language detection.
|
|
117
104
|
*/
|
|
118
|
-
languageConfidenceThreshold:
|
|
105
|
+
languageConfidenceThreshold: z2.number().nullish(),
|
|
119
106
|
/**
|
|
120
107
|
* Whether to enable language detection.
|
|
121
108
|
*/
|
|
122
|
-
languageDetection:
|
|
109
|
+
languageDetection: z2.boolean().nullish(),
|
|
123
110
|
/**
|
|
124
111
|
* Whether to process audio as multichannel.
|
|
125
112
|
*/
|
|
126
|
-
multichannel:
|
|
113
|
+
multichannel: z2.boolean().nullish(),
|
|
127
114
|
/**
|
|
128
115
|
* Whether to add punctuation to the transcription.
|
|
129
116
|
*/
|
|
130
|
-
punctuate:
|
|
117
|
+
punctuate: z2.boolean().nullish(),
|
|
131
118
|
/**
|
|
132
119
|
* Whether to redact personally identifiable information (PII).
|
|
133
120
|
*/
|
|
134
|
-
redactPii:
|
|
121
|
+
redactPii: z2.boolean().nullish(),
|
|
135
122
|
/**
|
|
136
123
|
* Whether to redact PII in the audio file.
|
|
137
124
|
*/
|
|
138
|
-
redactPiiAudio:
|
|
125
|
+
redactPiiAudio: z2.boolean().nullish(),
|
|
139
126
|
/**
|
|
140
127
|
* Audio format for PII redaction.
|
|
141
128
|
*/
|
|
142
|
-
redactPiiAudioQuality:
|
|
129
|
+
redactPiiAudioQuality: z2.string().nullish(),
|
|
143
130
|
/**
|
|
144
131
|
* List of PII types to redact.
|
|
145
132
|
*/
|
|
146
|
-
redactPiiPolicies:
|
|
133
|
+
redactPiiPolicies: z2.array(z2.string()).nullish(),
|
|
147
134
|
/**
|
|
148
135
|
* Substitution method for redacted PII.
|
|
149
136
|
*/
|
|
150
|
-
redactPiiSub:
|
|
137
|
+
redactPiiSub: z2.string().nullish(),
|
|
151
138
|
/**
|
|
152
139
|
* Whether to enable sentiment analysis.
|
|
153
140
|
*/
|
|
154
|
-
sentimentAnalysis:
|
|
141
|
+
sentimentAnalysis: z2.boolean().nullish(),
|
|
155
142
|
/**
|
|
156
143
|
* Whether to identify different speakers in the audio.
|
|
157
144
|
*/
|
|
158
|
-
speakerLabels:
|
|
145
|
+
speakerLabels: z2.boolean().nullish(),
|
|
159
146
|
/**
|
|
160
147
|
* Number of speakers expected in the audio.
|
|
161
148
|
*/
|
|
162
|
-
speakersExpected:
|
|
149
|
+
speakersExpected: z2.number().int().nullish(),
|
|
163
150
|
/**
|
|
164
151
|
* Threshold for speech detection (0-1).
|
|
165
152
|
*/
|
|
166
|
-
speechThreshold:
|
|
153
|
+
speechThreshold: z2.number().min(0).max(1).nullish(),
|
|
167
154
|
/**
|
|
168
155
|
* Whether to generate a summary of the transcription.
|
|
169
156
|
*/
|
|
170
|
-
summarization:
|
|
157
|
+
summarization: z2.boolean().nullish(),
|
|
171
158
|
/**
|
|
172
159
|
* Model to use for summarization.
|
|
173
160
|
*/
|
|
174
|
-
summaryModel:
|
|
161
|
+
summaryModel: z2.string().nullish(),
|
|
175
162
|
/**
|
|
176
163
|
* Type of summary to generate.
|
|
177
164
|
*/
|
|
178
|
-
summaryType:
|
|
165
|
+
summaryType: z2.string().nullish(),
|
|
179
166
|
/**
|
|
180
167
|
* Name of the authentication header for webhook requests.
|
|
181
168
|
*/
|
|
182
|
-
webhookAuthHeaderName:
|
|
169
|
+
webhookAuthHeaderName: z2.string().nullish(),
|
|
183
170
|
/**
|
|
184
171
|
* Value of the authentication header for webhook requests.
|
|
185
172
|
*/
|
|
186
|
-
webhookAuthHeaderValue:
|
|
173
|
+
webhookAuthHeaderValue: z2.string().nullish(),
|
|
187
174
|
/**
|
|
188
175
|
* URL to send webhook notifications to.
|
|
189
176
|
*/
|
|
190
|
-
webhookUrl:
|
|
177
|
+
webhookUrl: z2.string().nullish(),
|
|
191
178
|
/**
|
|
192
179
|
* List of words to boost recognition for.
|
|
193
180
|
*/
|
|
194
|
-
wordBoost:
|
|
181
|
+
wordBoost: z2.array(z2.string()).nullish()
|
|
195
182
|
});
|
|
196
|
-
var AssemblyAITranscriptionModel = class {
|
|
183
|
+
var AssemblyAITranscriptionModel = class _AssemblyAITranscriptionModel {
|
|
197
184
|
constructor(modelId, config) {
|
|
198
185
|
this.modelId = modelId;
|
|
199
186
|
this.config = config;
|
|
@@ -203,12 +190,21 @@ var AssemblyAITranscriptionModel = class {
|
|
|
203
190
|
get provider() {
|
|
204
191
|
return this.config.provider;
|
|
205
192
|
}
|
|
193
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
194
|
+
return serializeModelOptions({
|
|
195
|
+
modelId: model.modelId,
|
|
196
|
+
config: model.config
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
200
|
+
return new _AssemblyAITranscriptionModel(options.modelId, options.config);
|
|
201
|
+
}
|
|
206
202
|
async getArgs({
|
|
207
203
|
providerOptions
|
|
208
204
|
}) {
|
|
209
205
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H;
|
|
210
206
|
const warnings = [];
|
|
211
|
-
const assemblyaiOptions = await
|
|
207
|
+
const assemblyaiOptions = await parseProviderOptions({
|
|
212
208
|
provider: "assemblyai",
|
|
213
209
|
providerOptions,
|
|
214
210
|
schema: assemblyaiTranscriptionModelOptionsSchema
|
|
@@ -263,7 +259,7 @@ var AssemblyAITranscriptionModel = class {
|
|
|
263
259
|
* @see https://www.assemblyai.com/docs/getting-started/transcribe-an-audio-file#step-33
|
|
264
260
|
*/
|
|
265
261
|
async waitForCompletion(transcriptId, headers, abortSignal) {
|
|
266
|
-
var _a, _b;
|
|
262
|
+
var _a, _b, _c, _d;
|
|
267
263
|
const pollingInterval = (_a = this.config.pollingInterval) != null ? _a : this.POLLING_INTERVAL_MS;
|
|
268
264
|
while (true) {
|
|
269
265
|
if (abortSignal == null ? void 0 : abortSignal.aborted) {
|
|
@@ -276,8 +272,8 @@ var AssemblyAITranscriptionModel = class {
|
|
|
276
272
|
}),
|
|
277
273
|
{
|
|
278
274
|
method: "GET",
|
|
279
|
-
headers:
|
|
280
|
-
this.config.headers(),
|
|
275
|
+
headers: combineHeaders(
|
|
276
|
+
(_c = (_b = this.config).headers) == null ? void 0 : _c.call(_b),
|
|
281
277
|
headers
|
|
282
278
|
),
|
|
283
279
|
signal: abortSignal
|
|
@@ -299,53 +295,53 @@ var AssemblyAITranscriptionModel = class {
|
|
|
299
295
|
if (transcript.status === "completed") {
|
|
300
296
|
return {
|
|
301
297
|
transcript,
|
|
302
|
-
responseHeaders:
|
|
298
|
+
responseHeaders: extractResponseHeaders(response)
|
|
303
299
|
};
|
|
304
300
|
}
|
|
305
301
|
if (transcript.status === "error") {
|
|
306
302
|
throw new Error(
|
|
307
|
-
`Transcription failed: ${(
|
|
303
|
+
`Transcription failed: ${(_d = transcript.error) != null ? _d : "Unknown error"}`
|
|
308
304
|
);
|
|
309
305
|
}
|
|
310
306
|
await new Promise((resolve) => setTimeout(resolve, pollingInterval));
|
|
311
307
|
}
|
|
312
308
|
}
|
|
313
309
|
async doGenerate(options) {
|
|
314
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
310
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
315
311
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
316
|
-
const { value: uploadResponse } = await
|
|
312
|
+
const { value: uploadResponse } = await postToApi({
|
|
317
313
|
url: this.config.url({
|
|
318
314
|
path: "/v2/upload",
|
|
319
315
|
modelId: ""
|
|
320
316
|
}),
|
|
321
317
|
headers: {
|
|
322
318
|
"Content-Type": "application/octet-stream",
|
|
323
|
-
...(
|
|
319
|
+
...combineHeaders((_e = (_d = this.config).headers) == null ? void 0 : _e.call(_d), options.headers)
|
|
324
320
|
},
|
|
325
321
|
body: {
|
|
326
322
|
content: options.audio,
|
|
327
323
|
values: options.audio
|
|
328
324
|
},
|
|
329
325
|
failedResponseHandler: assemblyaiFailedResponseHandler,
|
|
330
|
-
successfulResponseHandler:
|
|
326
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
331
327
|
assemblyaiUploadResponseSchema
|
|
332
328
|
),
|
|
333
329
|
abortSignal: options.abortSignal,
|
|
334
330
|
fetch: this.config.fetch
|
|
335
331
|
});
|
|
336
332
|
const { body, warnings } = await this.getArgs(options);
|
|
337
|
-
const { value: submitResponse } = await
|
|
333
|
+
const { value: submitResponse } = await postJsonToApi({
|
|
338
334
|
url: this.config.url({
|
|
339
335
|
path: "/v2/transcript",
|
|
340
336
|
modelId: this.modelId
|
|
341
337
|
}),
|
|
342
|
-
headers: (
|
|
338
|
+
headers: combineHeaders((_g = (_f = this.config).headers) == null ? void 0 : _g.call(_f), options.headers),
|
|
343
339
|
body: {
|
|
344
340
|
...body,
|
|
345
341
|
audio_url: uploadResponse.upload_url
|
|
346
342
|
},
|
|
347
343
|
failedResponseHandler: assemblyaiFailedResponseHandler,
|
|
348
|
-
successfulResponseHandler:
|
|
344
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
349
345
|
assemblyaiSubmitResponseSchema
|
|
350
346
|
),
|
|
351
347
|
abortSignal: options.abortSignal,
|
|
@@ -357,14 +353,14 @@ var AssemblyAITranscriptionModel = class {
|
|
|
357
353
|
options.abortSignal
|
|
358
354
|
);
|
|
359
355
|
return {
|
|
360
|
-
text: (
|
|
361
|
-
segments: (
|
|
356
|
+
text: (_h = transcript.text) != null ? _h : "",
|
|
357
|
+
segments: (_j = (_i = transcript.words) == null ? void 0 : _i.map((word) => ({
|
|
362
358
|
text: word.text,
|
|
363
359
|
startSecond: word.start,
|
|
364
360
|
endSecond: word.end
|
|
365
|
-
}))) != null ?
|
|
366
|
-
language: (
|
|
367
|
-
durationInSeconds: (
|
|
361
|
+
}))) != null ? _j : [],
|
|
362
|
+
language: (_k = transcript.language_code) != null ? _k : void 0,
|
|
363
|
+
durationInSeconds: (_o = (_n = transcript.audio_duration) != null ? _n : (_m = (_l = transcript.words) == null ? void 0 : _l.at(-1)) == null ? void 0 : _m.end) != null ? _o : void 0,
|
|
368
364
|
warnings,
|
|
369
365
|
response: {
|
|
370
366
|
timestamp: currentDate,
|
|
@@ -377,37 +373,37 @@ var AssemblyAITranscriptionModel = class {
|
|
|
377
373
|
};
|
|
378
374
|
}
|
|
379
375
|
};
|
|
380
|
-
var assemblyaiUploadResponseSchema =
|
|
381
|
-
upload_url:
|
|
376
|
+
var assemblyaiUploadResponseSchema = z2.object({
|
|
377
|
+
upload_url: z2.string()
|
|
382
378
|
});
|
|
383
|
-
var assemblyaiSubmitResponseSchema =
|
|
384
|
-
id:
|
|
385
|
-
status:
|
|
379
|
+
var assemblyaiSubmitResponseSchema = z2.object({
|
|
380
|
+
id: z2.string(),
|
|
381
|
+
status: z2.enum(["queued", "processing", "completed", "error"])
|
|
386
382
|
});
|
|
387
|
-
var assemblyaiTranscriptionResponseSchema =
|
|
388
|
-
id:
|
|
389
|
-
status:
|
|
390
|
-
text:
|
|
391
|
-
language_code:
|
|
392
|
-
words:
|
|
393
|
-
|
|
394
|
-
start:
|
|
395
|
-
end:
|
|
396
|
-
text:
|
|
383
|
+
var assemblyaiTranscriptionResponseSchema = z2.object({
|
|
384
|
+
id: z2.string(),
|
|
385
|
+
status: z2.enum(["queued", "processing", "completed", "error"]),
|
|
386
|
+
text: z2.string().nullish(),
|
|
387
|
+
language_code: z2.string().nullish(),
|
|
388
|
+
words: z2.array(
|
|
389
|
+
z2.object({
|
|
390
|
+
start: z2.number(),
|
|
391
|
+
end: z2.number(),
|
|
392
|
+
text: z2.string()
|
|
397
393
|
})
|
|
398
394
|
).nullish(),
|
|
399
|
-
audio_duration:
|
|
400
|
-
error:
|
|
395
|
+
audio_duration: z2.number().nullish(),
|
|
396
|
+
error: z2.string().nullish()
|
|
401
397
|
});
|
|
402
398
|
|
|
403
399
|
// src/version.ts
|
|
404
|
-
var VERSION = true ? "3.0.0-beta.
|
|
400
|
+
var VERSION = true ? "3.0.0-beta.22" : "0.0.0-test";
|
|
405
401
|
|
|
406
402
|
// src/assemblyai-provider.ts
|
|
407
403
|
function createAssemblyAI(options = {}) {
|
|
408
|
-
const getHeaders = () =>
|
|
404
|
+
const getHeaders = () => withUserAgentSuffix(
|
|
409
405
|
{
|
|
410
|
-
authorization:
|
|
406
|
+
authorization: loadApiKey({
|
|
411
407
|
apiKey: options.apiKey,
|
|
412
408
|
environmentVariableName: "ASSEMBLYAI_API_KEY",
|
|
413
409
|
description: "AssemblyAI"
|
|
@@ -431,26 +427,25 @@ function createAssemblyAI(options = {}) {
|
|
|
431
427
|
provider.transcription = createTranscriptionModel;
|
|
432
428
|
provider.transcriptionModel = createTranscriptionModel;
|
|
433
429
|
provider.languageModel = () => {
|
|
434
|
-
throw new
|
|
430
|
+
throw new NoSuchModelError({
|
|
435
431
|
modelId: "unknown",
|
|
436
432
|
modelType: "languageModel",
|
|
437
433
|
message: "AssemblyAI does not provide language models"
|
|
438
434
|
});
|
|
439
435
|
};
|
|
440
436
|
provider.embeddingModel = (modelId) => {
|
|
441
|
-
throw new
|
|
437
|
+
throw new NoSuchModelError({ modelId, modelType: "embeddingModel" });
|
|
442
438
|
};
|
|
443
439
|
provider.textEmbeddingModel = provider.embeddingModel;
|
|
444
440
|
provider.imageModel = (modelId) => {
|
|
445
|
-
throw new
|
|
441
|
+
throw new NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
446
442
|
};
|
|
447
443
|
return provider;
|
|
448
444
|
}
|
|
449
445
|
var assemblyai = createAssemblyAI();
|
|
450
|
-
|
|
451
|
-
0 && (module.exports = {
|
|
446
|
+
export {
|
|
452
447
|
VERSION,
|
|
453
448
|
assemblyai,
|
|
454
449
|
createAssemblyAI
|
|
455
|
-
}
|
|
450
|
+
};
|
|
456
451
|
//# sourceMappingURL=index.js.map
|