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