@ai-sdk/gladia 3.0.0-beta.2 → 3.0.0-beta.20
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 +146 -4
- package/README.md +2 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.js +134 -146
- package/dist/index.js.map +1 -1
- package/package.json +7 -9
- package/src/gladia-provider.ts +6 -6
- package/src/gladia-transcription-model.ts +8 -8
- package/dist/index.d.mts +0 -158
- package/dist/index.mjs +0 -604
- package/dist/index.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,311 +1,300 @@
|
|
|
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
|
-
createGladia: () => createGladia,
|
|
25
|
-
gladia: () => gladia
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(index_exports);
|
|
28
|
-
|
|
29
1
|
// src/gladia-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/gladia-transcription-model.ts
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
11
|
+
import {
|
|
12
|
+
AISDKError
|
|
13
|
+
} from "@ai-sdk/provider";
|
|
14
|
+
import {
|
|
15
|
+
combineHeaders,
|
|
16
|
+
convertBase64ToUint8Array,
|
|
17
|
+
createJsonResponseHandler,
|
|
18
|
+
mediaTypeToExtension,
|
|
19
|
+
delay,
|
|
20
|
+
getFromApi,
|
|
21
|
+
parseProviderOptions,
|
|
22
|
+
postFormDataToApi,
|
|
23
|
+
postJsonToApi
|
|
24
|
+
} from "@ai-sdk/provider-utils";
|
|
25
|
+
import { z as z2 } from "zod/v4";
|
|
37
26
|
|
|
38
27
|
// src/gladia-error.ts
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var gladiaErrorDataSchema =
|
|
42
|
-
error:
|
|
43
|
-
message:
|
|
44
|
-
code:
|
|
28
|
+
import { z } from "zod/v4";
|
|
29
|
+
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
30
|
+
var gladiaErrorDataSchema = z.object({
|
|
31
|
+
error: z.object({
|
|
32
|
+
message: z.string(),
|
|
33
|
+
code: z.number()
|
|
45
34
|
})
|
|
46
35
|
});
|
|
47
|
-
var gladiaFailedResponseHandler =
|
|
36
|
+
var gladiaFailedResponseHandler = createJsonErrorResponseHandler({
|
|
48
37
|
errorSchema: gladiaErrorDataSchema,
|
|
49
38
|
errorToMessage: (data) => data.error.message
|
|
50
39
|
});
|
|
51
40
|
|
|
52
41
|
// src/gladia-transcription-model.ts
|
|
53
|
-
var gladiaTranscriptionModelOptionsSchema =
|
|
42
|
+
var gladiaTranscriptionModelOptionsSchema = z2.object({
|
|
54
43
|
/**
|
|
55
44
|
* Optional context prompt to guide the transcription.
|
|
56
45
|
*/
|
|
57
|
-
contextPrompt:
|
|
46
|
+
contextPrompt: z2.string().nullish(),
|
|
58
47
|
/**
|
|
59
48
|
* Custom vocabulary to improve transcription accuracy.
|
|
60
49
|
* Can be a boolean or an array of custom terms.
|
|
61
50
|
*/
|
|
62
|
-
customVocabulary:
|
|
51
|
+
customVocabulary: z2.union([z2.boolean(), z2.array(z2.any())]).nullish(),
|
|
63
52
|
/**
|
|
64
53
|
* Configuration for custom vocabulary.
|
|
65
54
|
*/
|
|
66
|
-
customVocabularyConfig:
|
|
55
|
+
customVocabularyConfig: z2.object({
|
|
67
56
|
/**
|
|
68
57
|
* Array of vocabulary terms or objects with pronunciation details.
|
|
69
58
|
*/
|
|
70
|
-
vocabulary:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
59
|
+
vocabulary: z2.array(
|
|
60
|
+
z2.union([
|
|
61
|
+
z2.string(),
|
|
62
|
+
z2.object({
|
|
74
63
|
/**
|
|
75
64
|
* The vocabulary term.
|
|
76
65
|
*/
|
|
77
|
-
value:
|
|
66
|
+
value: z2.string(),
|
|
78
67
|
/**
|
|
79
68
|
* Intensity of the term in recognition (optional).
|
|
80
69
|
*/
|
|
81
|
-
intensity:
|
|
70
|
+
intensity: z2.number().nullish(),
|
|
82
71
|
/**
|
|
83
72
|
* Alternative pronunciations for the term (optional).
|
|
84
73
|
*/
|
|
85
|
-
pronunciations:
|
|
74
|
+
pronunciations: z2.array(z2.string()).nullish(),
|
|
86
75
|
/**
|
|
87
76
|
* Language of the term (optional).
|
|
88
77
|
*/
|
|
89
|
-
language:
|
|
78
|
+
language: z2.string().nullish()
|
|
90
79
|
})
|
|
91
80
|
])
|
|
92
81
|
),
|
|
93
82
|
/**
|
|
94
83
|
* Default intensity for all vocabulary terms.
|
|
95
84
|
*/
|
|
96
|
-
defaultIntensity:
|
|
85
|
+
defaultIntensity: z2.number().nullish()
|
|
97
86
|
}).nullish(),
|
|
98
87
|
/**
|
|
99
88
|
* Whether to automatically detect the language of the audio.
|
|
100
89
|
*/
|
|
101
|
-
detectLanguage:
|
|
90
|
+
detectLanguage: z2.boolean().nullish(),
|
|
102
91
|
/**
|
|
103
92
|
* Whether to enable code switching (multiple languages in the same audio).
|
|
104
93
|
*/
|
|
105
|
-
enableCodeSwitching:
|
|
94
|
+
enableCodeSwitching: z2.boolean().nullish(),
|
|
106
95
|
/**
|
|
107
96
|
* Configuration for code switching.
|
|
108
97
|
*/
|
|
109
|
-
codeSwitchingConfig:
|
|
98
|
+
codeSwitchingConfig: z2.object({
|
|
110
99
|
/**
|
|
111
100
|
* Languages to consider for code switching.
|
|
112
101
|
*/
|
|
113
|
-
languages:
|
|
102
|
+
languages: z2.array(z2.string()).nullish()
|
|
114
103
|
}).nullish(),
|
|
115
104
|
/**
|
|
116
105
|
* Specific language for transcription.
|
|
117
106
|
*/
|
|
118
|
-
language:
|
|
107
|
+
language: z2.string().nullish(),
|
|
119
108
|
/**
|
|
120
109
|
* Whether to enable callback when transcription is complete.
|
|
121
110
|
*/
|
|
122
|
-
callback:
|
|
111
|
+
callback: z2.boolean().nullish(),
|
|
123
112
|
/**
|
|
124
113
|
* Configuration for callback.
|
|
125
114
|
*/
|
|
126
|
-
callbackConfig:
|
|
115
|
+
callbackConfig: z2.object({
|
|
127
116
|
/**
|
|
128
117
|
* URL to send the callback to.
|
|
129
118
|
*/
|
|
130
|
-
url:
|
|
119
|
+
url: z2.string(),
|
|
131
120
|
/**
|
|
132
121
|
* HTTP method for the callback.
|
|
133
122
|
*/
|
|
134
|
-
method:
|
|
123
|
+
method: z2.enum(["POST", "PUT"]).nullish()
|
|
135
124
|
}).nullish(),
|
|
136
125
|
/**
|
|
137
126
|
* Whether to generate subtitles.
|
|
138
127
|
*/
|
|
139
|
-
subtitles:
|
|
128
|
+
subtitles: z2.boolean().nullish(),
|
|
140
129
|
/**
|
|
141
130
|
* Configuration for subtitles generation.
|
|
142
131
|
*/
|
|
143
|
-
subtitlesConfig:
|
|
132
|
+
subtitlesConfig: z2.object({
|
|
144
133
|
/**
|
|
145
134
|
* Subtitle file formats to generate.
|
|
146
135
|
*/
|
|
147
|
-
formats:
|
|
136
|
+
formats: z2.array(z2.enum(["srt", "vtt"])).nullish(),
|
|
148
137
|
/**
|
|
149
138
|
* Minimum duration for subtitle segments.
|
|
150
139
|
*/
|
|
151
|
-
minimumDuration:
|
|
140
|
+
minimumDuration: z2.number().nullish(),
|
|
152
141
|
/**
|
|
153
142
|
* Maximum duration for subtitle segments.
|
|
154
143
|
*/
|
|
155
|
-
maximumDuration:
|
|
144
|
+
maximumDuration: z2.number().nullish(),
|
|
156
145
|
/**
|
|
157
146
|
* Maximum characters per row in subtitles.
|
|
158
147
|
*/
|
|
159
|
-
maximumCharactersPerRow:
|
|
148
|
+
maximumCharactersPerRow: z2.number().nullish(),
|
|
160
149
|
/**
|
|
161
150
|
* Maximum rows per caption in subtitles.
|
|
162
151
|
*/
|
|
163
|
-
maximumRowsPerCaption:
|
|
152
|
+
maximumRowsPerCaption: z2.number().nullish(),
|
|
164
153
|
/**
|
|
165
154
|
* Style of subtitles.
|
|
166
155
|
*/
|
|
167
|
-
style:
|
|
156
|
+
style: z2.enum(["default", "compliance"]).nullish()
|
|
168
157
|
}).nullish(),
|
|
169
158
|
/**
|
|
170
159
|
* Whether to enable speaker diarization (speaker identification).
|
|
171
160
|
*/
|
|
172
|
-
diarization:
|
|
161
|
+
diarization: z2.boolean().nullish(),
|
|
173
162
|
/**
|
|
174
163
|
* Configuration for diarization.
|
|
175
164
|
*/
|
|
176
|
-
diarizationConfig:
|
|
165
|
+
diarizationConfig: z2.object({
|
|
177
166
|
/**
|
|
178
167
|
* Exact number of speakers to identify.
|
|
179
168
|
*/
|
|
180
|
-
numberOfSpeakers:
|
|
169
|
+
numberOfSpeakers: z2.number().nullish(),
|
|
181
170
|
/**
|
|
182
171
|
* Minimum number of speakers to identify.
|
|
183
172
|
*/
|
|
184
|
-
minSpeakers:
|
|
173
|
+
minSpeakers: z2.number().nullish(),
|
|
185
174
|
/**
|
|
186
175
|
* Maximum number of speakers to identify.
|
|
187
176
|
*/
|
|
188
|
-
maxSpeakers:
|
|
177
|
+
maxSpeakers: z2.number().nullish(),
|
|
189
178
|
/**
|
|
190
179
|
* Whether to use enhanced diarization.
|
|
191
180
|
*/
|
|
192
|
-
enhanced:
|
|
181
|
+
enhanced: z2.boolean().nullish()
|
|
193
182
|
}).nullish(),
|
|
194
183
|
/**
|
|
195
184
|
* Whether to translate the transcription.
|
|
196
185
|
*/
|
|
197
|
-
translation:
|
|
186
|
+
translation: z2.boolean().nullish(),
|
|
198
187
|
/**
|
|
199
188
|
* Configuration for translation.
|
|
200
189
|
*/
|
|
201
|
-
translationConfig:
|
|
190
|
+
translationConfig: z2.object({
|
|
202
191
|
/**
|
|
203
192
|
* Target languages for translation.
|
|
204
193
|
*/
|
|
205
|
-
targetLanguages:
|
|
194
|
+
targetLanguages: z2.array(z2.string()),
|
|
206
195
|
/**
|
|
207
196
|
* Translation model to use.
|
|
208
197
|
*/
|
|
209
|
-
model:
|
|
198
|
+
model: z2.enum(["base", "enhanced"]).nullish(),
|
|
210
199
|
/**
|
|
211
200
|
* Whether to match original utterances in translation.
|
|
212
201
|
*/
|
|
213
|
-
matchOriginalUtterances:
|
|
202
|
+
matchOriginalUtterances: z2.boolean().nullish()
|
|
214
203
|
}).nullish(),
|
|
215
204
|
/**
|
|
216
205
|
* Whether to generate a summary of the transcription.
|
|
217
206
|
*/
|
|
218
|
-
summarization:
|
|
207
|
+
summarization: z2.boolean().nullish(),
|
|
219
208
|
/**
|
|
220
209
|
* Configuration for summarization.
|
|
221
210
|
*/
|
|
222
|
-
summarizationConfig:
|
|
211
|
+
summarizationConfig: z2.object({
|
|
223
212
|
/**
|
|
224
213
|
* Type of summary to generate.
|
|
225
214
|
*/
|
|
226
|
-
type:
|
|
215
|
+
type: z2.enum(["general", "bullet_points", "concise"]).nullish()
|
|
227
216
|
}).nullish(),
|
|
228
217
|
/**
|
|
229
218
|
* Whether to enable content moderation.
|
|
230
219
|
*/
|
|
231
|
-
moderation:
|
|
220
|
+
moderation: z2.boolean().nullish(),
|
|
232
221
|
/**
|
|
233
222
|
* Whether to enable named entity recognition.
|
|
234
223
|
*/
|
|
235
|
-
namedEntityRecognition:
|
|
224
|
+
namedEntityRecognition: z2.boolean().nullish(),
|
|
236
225
|
/**
|
|
237
226
|
* Whether to enable automatic chapter creation.
|
|
238
227
|
*/
|
|
239
|
-
chapterization:
|
|
228
|
+
chapterization: z2.boolean().nullish(),
|
|
240
229
|
/**
|
|
241
230
|
* Whether to ensure consistent naming of entities.
|
|
242
231
|
*/
|
|
243
|
-
nameConsistency:
|
|
232
|
+
nameConsistency: z2.boolean().nullish(),
|
|
244
233
|
/**
|
|
245
234
|
* Whether to enable custom spelling.
|
|
246
235
|
*/
|
|
247
|
-
customSpelling:
|
|
236
|
+
customSpelling: z2.boolean().nullish(),
|
|
248
237
|
/**
|
|
249
238
|
* Configuration for custom spelling.
|
|
250
239
|
*/
|
|
251
|
-
customSpellingConfig:
|
|
240
|
+
customSpellingConfig: z2.object({
|
|
252
241
|
/**
|
|
253
242
|
* Dictionary of custom spellings.
|
|
254
243
|
*/
|
|
255
|
-
spellingDictionary:
|
|
244
|
+
spellingDictionary: z2.record(z2.string(), z2.array(z2.string()))
|
|
256
245
|
}).nullish(),
|
|
257
246
|
/**
|
|
258
247
|
* Whether to extract structured data from the transcription.
|
|
259
248
|
*/
|
|
260
|
-
structuredDataExtraction:
|
|
249
|
+
structuredDataExtraction: z2.boolean().nullish(),
|
|
261
250
|
/**
|
|
262
251
|
* Configuration for structured data extraction.
|
|
263
252
|
*/
|
|
264
|
-
structuredDataExtractionConfig:
|
|
253
|
+
structuredDataExtractionConfig: z2.object({
|
|
265
254
|
/**
|
|
266
255
|
* Classes of data to extract.
|
|
267
256
|
*/
|
|
268
|
-
classes:
|
|
257
|
+
classes: z2.array(z2.string())
|
|
269
258
|
}).nullish(),
|
|
270
259
|
/**
|
|
271
260
|
* Whether to perform sentiment analysis on the transcription.
|
|
272
261
|
*/
|
|
273
|
-
sentimentAnalysis:
|
|
262
|
+
sentimentAnalysis: z2.boolean().nullish(),
|
|
274
263
|
/**
|
|
275
264
|
* Whether to send audio to a language model for processing.
|
|
276
265
|
*/
|
|
277
|
-
audioToLlm:
|
|
266
|
+
audioToLlm: z2.boolean().nullish(),
|
|
278
267
|
/**
|
|
279
268
|
* Configuration for audio to language model processing.
|
|
280
269
|
*/
|
|
281
|
-
audioToLlmConfig:
|
|
270
|
+
audioToLlmConfig: z2.object({
|
|
282
271
|
/**
|
|
283
272
|
* Prompts to send to the language model.
|
|
284
273
|
*/
|
|
285
|
-
prompts:
|
|
274
|
+
prompts: z2.array(z2.string())
|
|
286
275
|
}).nullish(),
|
|
287
276
|
/**
|
|
288
277
|
* Custom metadata to include with the transcription.
|
|
289
278
|
*/
|
|
290
|
-
customMetadata:
|
|
279
|
+
customMetadata: z2.record(z2.string(), z2.any()).nullish(),
|
|
291
280
|
/**
|
|
292
281
|
* Whether to include sentence-level segmentation.
|
|
293
282
|
*/
|
|
294
|
-
sentences:
|
|
283
|
+
sentences: z2.boolean().nullish(),
|
|
295
284
|
/**
|
|
296
285
|
* Whether to enable display mode.
|
|
297
286
|
*/
|
|
298
|
-
displayMode:
|
|
287
|
+
displayMode: z2.boolean().nullish(),
|
|
299
288
|
/**
|
|
300
289
|
* Whether to enhance punctuation in the transcription.
|
|
301
290
|
*/
|
|
302
|
-
punctuationEnhanced:
|
|
291
|
+
punctuationEnhanced: z2.boolean().nullish()
|
|
303
292
|
});
|
|
304
293
|
var GladiaTranscriptionModel = class {
|
|
305
294
|
constructor(modelId, config) {
|
|
306
295
|
this.modelId = modelId;
|
|
307
296
|
this.config = config;
|
|
308
|
-
this.specificationVersion = "
|
|
297
|
+
this.specificationVersion = "v4";
|
|
309
298
|
}
|
|
310
299
|
get provider() {
|
|
311
300
|
return this.config.provider;
|
|
@@ -315,7 +304,7 @@ var GladiaTranscriptionModel = class {
|
|
|
315
304
|
}) {
|
|
316
305
|
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, _I, _J, _K, _L, _M, _N;
|
|
317
306
|
const warnings = [];
|
|
318
|
-
const gladiaOptions = await
|
|
307
|
+
const gladiaOptions = await parseProviderOptions({
|
|
319
308
|
provider: "gladia",
|
|
320
309
|
providerOptions,
|
|
321
310
|
schema: gladiaTranscriptionModelOptionsSchema
|
|
@@ -419,40 +408,40 @@ var GladiaTranscriptionModel = class {
|
|
|
419
408
|
var _a, _b, _c;
|
|
420
409
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
421
410
|
const formData = new FormData();
|
|
422
|
-
const blob = options.audio instanceof Uint8Array ? new Blob([options.audio]) : new Blob([
|
|
423
|
-
const fileExtension =
|
|
411
|
+
const blob = options.audio instanceof Uint8Array ? new Blob([options.audio]) : new Blob([convertBase64ToUint8Array(options.audio)]);
|
|
412
|
+
const fileExtension = mediaTypeToExtension(options.mediaType);
|
|
424
413
|
formData.append(
|
|
425
414
|
"audio",
|
|
426
415
|
new File([blob], "audio", { type: options.mediaType }),
|
|
427
416
|
`audio.${fileExtension}`
|
|
428
417
|
);
|
|
429
|
-
const { value: uploadResponse } = await
|
|
418
|
+
const { value: uploadResponse } = await postFormDataToApi({
|
|
430
419
|
url: this.config.url({
|
|
431
420
|
path: "/v2/upload",
|
|
432
421
|
modelId: "default"
|
|
433
422
|
}),
|
|
434
|
-
headers:
|
|
423
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
435
424
|
formData,
|
|
436
425
|
failedResponseHandler: gladiaFailedResponseHandler,
|
|
437
|
-
successfulResponseHandler:
|
|
426
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
438
427
|
gladiaUploadResponseSchema
|
|
439
428
|
),
|
|
440
429
|
abortSignal: options.abortSignal,
|
|
441
430
|
fetch: this.config.fetch
|
|
442
431
|
});
|
|
443
432
|
const { body, warnings } = await this.getArgs(options);
|
|
444
|
-
const { value: transcriptionInitResponse } = await
|
|
433
|
+
const { value: transcriptionInitResponse } = await postJsonToApi({
|
|
445
434
|
url: this.config.url({
|
|
446
435
|
path: "/v2/pre-recorded",
|
|
447
436
|
modelId: "default"
|
|
448
437
|
}),
|
|
449
|
-
headers:
|
|
438
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
450
439
|
body: {
|
|
451
440
|
...body,
|
|
452
441
|
audio_url: uploadResponse.audio_url
|
|
453
442
|
},
|
|
454
443
|
failedResponseHandler: gladiaFailedResponseHandler,
|
|
455
|
-
successfulResponseHandler:
|
|
444
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
456
445
|
gladiaTranscriptionInitializeResponseSchema
|
|
457
446
|
),
|
|
458
447
|
abortSignal: options.abortSignal,
|
|
@@ -466,17 +455,17 @@ var GladiaTranscriptionModel = class {
|
|
|
466
455
|
const pollingInterval = 1e3;
|
|
467
456
|
while (true) {
|
|
468
457
|
if (Date.now() - startTime > timeoutMs) {
|
|
469
|
-
throw new
|
|
458
|
+
throw new AISDKError({
|
|
470
459
|
message: "Transcription job polling timed out",
|
|
471
460
|
name: "TranscriptionJobPollingTimedOut",
|
|
472
461
|
cause: transcriptionResult
|
|
473
462
|
});
|
|
474
463
|
}
|
|
475
|
-
const response = await
|
|
464
|
+
const response = await getFromApi({
|
|
476
465
|
url: resultUrl,
|
|
477
|
-
headers:
|
|
466
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
478
467
|
failedResponseHandler: gladiaFailedResponseHandler,
|
|
479
|
-
successfulResponseHandler:
|
|
468
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
480
469
|
gladiaTranscriptionResultResponseSchema
|
|
481
470
|
),
|
|
482
471
|
abortSignal: options.abortSignal,
|
|
@@ -488,16 +477,16 @@ var GladiaTranscriptionModel = class {
|
|
|
488
477
|
break;
|
|
489
478
|
}
|
|
490
479
|
if (transcriptionResult.status === "error") {
|
|
491
|
-
throw new
|
|
480
|
+
throw new AISDKError({
|
|
492
481
|
message: "Transcription job failed",
|
|
493
482
|
name: "TranscriptionJobFailed",
|
|
494
483
|
cause: transcriptionResult
|
|
495
484
|
});
|
|
496
485
|
}
|
|
497
|
-
await
|
|
486
|
+
await delay(pollingInterval);
|
|
498
487
|
}
|
|
499
488
|
if (!transcriptionResult.result) {
|
|
500
|
-
throw new
|
|
489
|
+
throw new AISDKError({
|
|
501
490
|
message: "Transcription result is empty",
|
|
502
491
|
name: "TranscriptionResultEmpty",
|
|
503
492
|
cause: transcriptionResult
|
|
@@ -526,26 +515,26 @@ var GladiaTranscriptionModel = class {
|
|
|
526
515
|
};
|
|
527
516
|
}
|
|
528
517
|
};
|
|
529
|
-
var gladiaUploadResponseSchema =
|
|
530
|
-
audio_url:
|
|
518
|
+
var gladiaUploadResponseSchema = z2.object({
|
|
519
|
+
audio_url: z2.string()
|
|
531
520
|
});
|
|
532
|
-
var gladiaTranscriptionInitializeResponseSchema =
|
|
533
|
-
result_url:
|
|
521
|
+
var gladiaTranscriptionInitializeResponseSchema = z2.object({
|
|
522
|
+
result_url: z2.string()
|
|
534
523
|
});
|
|
535
|
-
var gladiaTranscriptionResultResponseSchema =
|
|
536
|
-
status:
|
|
537
|
-
result:
|
|
538
|
-
metadata:
|
|
539
|
-
audio_duration:
|
|
524
|
+
var gladiaTranscriptionResultResponseSchema = z2.object({
|
|
525
|
+
status: z2.enum(["queued", "processing", "done", "error"]),
|
|
526
|
+
result: z2.object({
|
|
527
|
+
metadata: z2.object({
|
|
528
|
+
audio_duration: z2.number()
|
|
540
529
|
}),
|
|
541
|
-
transcription:
|
|
542
|
-
full_transcript:
|
|
543
|
-
languages:
|
|
544
|
-
utterances:
|
|
545
|
-
|
|
546
|
-
start:
|
|
547
|
-
end:
|
|
548
|
-
text:
|
|
530
|
+
transcription: z2.object({
|
|
531
|
+
full_transcript: z2.string(),
|
|
532
|
+
languages: z2.array(z2.string()),
|
|
533
|
+
utterances: z2.array(
|
|
534
|
+
z2.object({
|
|
535
|
+
start: z2.number(),
|
|
536
|
+
end: z2.number(),
|
|
537
|
+
text: z2.string()
|
|
549
538
|
})
|
|
550
539
|
)
|
|
551
540
|
})
|
|
@@ -553,13 +542,13 @@ var gladiaTranscriptionResultResponseSchema = import_v42.z.object({
|
|
|
553
542
|
});
|
|
554
543
|
|
|
555
544
|
// src/version.ts
|
|
556
|
-
var VERSION = true ? "3.0.0-beta.
|
|
545
|
+
var VERSION = true ? "3.0.0-beta.20" : "0.0.0-test";
|
|
557
546
|
|
|
558
547
|
// src/gladia-provider.ts
|
|
559
548
|
function createGladia(options = {}) {
|
|
560
|
-
const getHeaders = () =>
|
|
549
|
+
const getHeaders = () => withUserAgentSuffix(
|
|
561
550
|
{
|
|
562
|
-
"x-gladia-key":
|
|
551
|
+
"x-gladia-key": loadApiKey({
|
|
563
552
|
apiKey: options.apiKey,
|
|
564
553
|
environmentVariableName: "GLADIA_API_KEY",
|
|
565
554
|
description: "Gladia"
|
|
@@ -579,18 +568,18 @@ function createGladia(options = {}) {
|
|
|
579
568
|
transcription: createTranscriptionModel()
|
|
580
569
|
};
|
|
581
570
|
};
|
|
582
|
-
provider.specificationVersion = "
|
|
571
|
+
provider.specificationVersion = "v4";
|
|
583
572
|
provider.transcription = createTranscriptionModel;
|
|
584
573
|
provider.transcriptionModel = createTranscriptionModel;
|
|
585
574
|
provider.languageModel = (modelId) => {
|
|
586
|
-
throw new
|
|
575
|
+
throw new NoSuchModelError({
|
|
587
576
|
modelId,
|
|
588
577
|
modelType: "languageModel",
|
|
589
578
|
message: "Gladia does not provide language models"
|
|
590
579
|
});
|
|
591
580
|
};
|
|
592
581
|
provider.embeddingModel = (modelId) => {
|
|
593
|
-
throw new
|
|
582
|
+
throw new NoSuchModelError({
|
|
594
583
|
modelId,
|
|
595
584
|
modelType: "embeddingModel",
|
|
596
585
|
message: "Gladia does not provide embedding models"
|
|
@@ -598,7 +587,7 @@ function createGladia(options = {}) {
|
|
|
598
587
|
};
|
|
599
588
|
provider.textEmbeddingModel = provider.embeddingModel;
|
|
600
589
|
provider.imageModel = (modelId) => {
|
|
601
|
-
throw new
|
|
590
|
+
throw new NoSuchModelError({
|
|
602
591
|
modelId,
|
|
603
592
|
modelType: "imageModel",
|
|
604
593
|
message: "Gladia does not provide image models"
|
|
@@ -607,10 +596,9 @@ function createGladia(options = {}) {
|
|
|
607
596
|
return provider;
|
|
608
597
|
}
|
|
609
598
|
var gladia = createGladia();
|
|
610
|
-
|
|
611
|
-
0 && (module.exports = {
|
|
599
|
+
export {
|
|
612
600
|
VERSION,
|
|
613
601
|
createGladia,
|
|
614
602
|
gladia
|
|
615
|
-
}
|
|
603
|
+
};
|
|
616
604
|
//# sourceMappingURL=index.js.map
|