@ai-sdk/revai 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 +11 -2
- package/dist/index.js +124 -125
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/revai-config.ts +1 -1
- package/src/revai-transcription-model.ts +20 -3
- package/dist/index.d.mts +0 -148
- package/dist/index.mjs +0 -505
- package/dist/index.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @ai-sdk/revai
|
|
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 RevaiConfig = {
|
|
@@ -8,7 +9,7 @@ type RevaiConfig = {
|
|
|
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
|
};
|
|
@@ -101,6 +102,14 @@ declare class RevaiTranscriptionModel implements TranscriptionModelV4 {
|
|
|
101
102
|
private readonly config;
|
|
102
103
|
readonly specificationVersion = "v4";
|
|
103
104
|
get provider(): string;
|
|
105
|
+
static [WORKFLOW_SERIALIZE](model: RevaiTranscriptionModel): {
|
|
106
|
+
modelId: string;
|
|
107
|
+
config: _ai_sdk_provider.JSONObject;
|
|
108
|
+
};
|
|
109
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
110
|
+
modelId: RevaiTranscriptionModelId;
|
|
111
|
+
config: RevaiTranscriptionModelConfig;
|
|
112
|
+
}): RevaiTranscriptionModel;
|
|
104
113
|
constructor(modelId: RevaiTranscriptionModelId, config: RevaiTranscriptionModelConfig);
|
|
105
114
|
private getArgs;
|
|
106
115
|
doGenerate(options: Parameters<TranscriptionModelV4['doGenerate']>[0]): Promise<Awaited<ReturnType<TranscriptionModelV4['doGenerate']>>>;
|
package/dist/index.js
CHANGED
|
@@ -1,195 +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
|
-
createRevai: () => createRevai,
|
|
25
|
-
revai: () => revai
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(index_exports);
|
|
28
|
-
|
|
29
1
|
// src/revai-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/revai-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
|
+
serializeModelOptions,
|
|
24
|
+
WORKFLOW_SERIALIZE,
|
|
25
|
+
WORKFLOW_DESERIALIZE
|
|
26
|
+
} from "@ai-sdk/provider-utils";
|
|
27
|
+
import { z as z2 } from "zod/v4";
|
|
37
28
|
|
|
38
29
|
// src/revai-error.ts
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var revaiErrorDataSchema =
|
|
42
|
-
error:
|
|
43
|
-
message:
|
|
44
|
-
code:
|
|
30
|
+
import { z } from "zod/v4";
|
|
31
|
+
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
32
|
+
var revaiErrorDataSchema = z.object({
|
|
33
|
+
error: z.object({
|
|
34
|
+
message: z.string(),
|
|
35
|
+
code: z.number()
|
|
45
36
|
})
|
|
46
37
|
});
|
|
47
|
-
var revaiFailedResponseHandler =
|
|
38
|
+
var revaiFailedResponseHandler = createJsonErrorResponseHandler({
|
|
48
39
|
errorSchema: revaiErrorDataSchema,
|
|
49
40
|
errorToMessage: (data) => data.error.message
|
|
50
41
|
});
|
|
51
42
|
|
|
52
43
|
// src/revai-transcription-model.ts
|
|
53
|
-
var revaiTranscriptionModelOptionsSchema =
|
|
44
|
+
var revaiTranscriptionModelOptionsSchema = z2.object({
|
|
54
45
|
/**
|
|
55
46
|
* Optional metadata string to associate with the transcription job.
|
|
56
47
|
*/
|
|
57
|
-
metadata:
|
|
48
|
+
metadata: z2.string().nullish(),
|
|
58
49
|
/**
|
|
59
50
|
* Configuration for webhook notifications when job is complete.
|
|
60
51
|
*/
|
|
61
|
-
notification_config:
|
|
52
|
+
notification_config: z2.object({
|
|
62
53
|
/**
|
|
63
54
|
* URL to send the notification to.
|
|
64
55
|
*/
|
|
65
|
-
url:
|
|
56
|
+
url: z2.string(),
|
|
66
57
|
/**
|
|
67
58
|
* Optional authorization headers for the notification request.
|
|
68
59
|
*/
|
|
69
|
-
auth_headers:
|
|
70
|
-
Authorization:
|
|
60
|
+
auth_headers: z2.object({
|
|
61
|
+
Authorization: z2.string()
|
|
71
62
|
}).nullish()
|
|
72
63
|
}).nullish(),
|
|
73
64
|
/**
|
|
74
65
|
* Number of seconds after which the job will be automatically deleted.
|
|
75
66
|
*/
|
|
76
|
-
delete_after_seconds:
|
|
67
|
+
delete_after_seconds: z2.number().nullish(),
|
|
77
68
|
/**
|
|
78
69
|
* Whether to include filler words and false starts in the transcription.
|
|
79
70
|
*/
|
|
80
|
-
verbatim:
|
|
71
|
+
verbatim: z2.boolean().optional(),
|
|
81
72
|
/**
|
|
82
73
|
* Whether to prioritize the job for faster processing.
|
|
83
74
|
*/
|
|
84
|
-
rush:
|
|
75
|
+
rush: z2.boolean().nullish().default(false),
|
|
85
76
|
/**
|
|
86
77
|
* Whether to run the job in test mode.
|
|
87
78
|
*/
|
|
88
|
-
test_mode:
|
|
79
|
+
test_mode: z2.boolean().nullish().default(false),
|
|
89
80
|
/**
|
|
90
81
|
* Specific segments of the audio to transcribe.
|
|
91
82
|
*/
|
|
92
|
-
segments_to_transcribe:
|
|
93
|
-
|
|
83
|
+
segments_to_transcribe: z2.array(
|
|
84
|
+
z2.object({
|
|
94
85
|
/**
|
|
95
86
|
* Start time of the segment in seconds.
|
|
96
87
|
*/
|
|
97
|
-
start:
|
|
88
|
+
start: z2.number(),
|
|
98
89
|
/**
|
|
99
90
|
* End time of the segment in seconds.
|
|
100
91
|
*/
|
|
101
|
-
end:
|
|
92
|
+
end: z2.number()
|
|
102
93
|
})
|
|
103
94
|
).nullish(),
|
|
104
95
|
/**
|
|
105
96
|
* Names to assign to speakers in the transcription.
|
|
106
97
|
*/
|
|
107
|
-
speaker_names:
|
|
108
|
-
|
|
98
|
+
speaker_names: z2.array(
|
|
99
|
+
z2.object({
|
|
109
100
|
/**
|
|
110
101
|
* Display name for the speaker.
|
|
111
102
|
*/
|
|
112
|
-
display_name:
|
|
103
|
+
display_name: z2.string()
|
|
113
104
|
})
|
|
114
105
|
).nullish(),
|
|
115
106
|
/**
|
|
116
107
|
* Whether to skip speaker diarization.
|
|
117
108
|
*/
|
|
118
|
-
skip_diarization:
|
|
109
|
+
skip_diarization: z2.boolean().nullish().default(false),
|
|
119
110
|
/**
|
|
120
111
|
* Whether to skip post-processing steps.
|
|
121
112
|
*/
|
|
122
|
-
skip_postprocessing:
|
|
113
|
+
skip_postprocessing: z2.boolean().nullish().default(false),
|
|
123
114
|
/**
|
|
124
115
|
* Whether to skip adding punctuation to the transcription.
|
|
125
116
|
*/
|
|
126
|
-
skip_punctuation:
|
|
117
|
+
skip_punctuation: z2.boolean().nullish().default(false),
|
|
127
118
|
/**
|
|
128
119
|
* Whether to remove disfluencies (um, uh, etc.) from the transcription.
|
|
129
120
|
*/
|
|
130
|
-
remove_disfluencies:
|
|
121
|
+
remove_disfluencies: z2.boolean().nullish().default(false),
|
|
131
122
|
/**
|
|
132
123
|
* Whether to remove atmospheric sounds from the transcription.
|
|
133
124
|
*/
|
|
134
|
-
remove_atmospherics:
|
|
125
|
+
remove_atmospherics: z2.boolean().nullish().default(false),
|
|
135
126
|
/**
|
|
136
127
|
* Whether to filter profanity from the transcription.
|
|
137
128
|
*/
|
|
138
|
-
filter_profanity:
|
|
129
|
+
filter_profanity: z2.boolean().nullish().default(false),
|
|
139
130
|
/**
|
|
140
131
|
* Number of speaker channels in the audio.
|
|
141
132
|
*/
|
|
142
|
-
speaker_channels_count:
|
|
133
|
+
speaker_channels_count: z2.number().nullish(),
|
|
143
134
|
/**
|
|
144
135
|
* Expected number of speakers in the audio.
|
|
145
136
|
*/
|
|
146
|
-
speakers_count:
|
|
137
|
+
speakers_count: z2.number().nullish(),
|
|
147
138
|
/**
|
|
148
139
|
* Type of diarization to use.
|
|
149
140
|
*/
|
|
150
|
-
diarization_type:
|
|
141
|
+
diarization_type: z2.enum(["standard", "premium"]).nullish().default("standard"),
|
|
151
142
|
/**
|
|
152
143
|
* ID of a custom vocabulary to use for the transcription.
|
|
153
144
|
*/
|
|
154
|
-
custom_vocabulary_id:
|
|
145
|
+
custom_vocabulary_id: z2.string().nullish(),
|
|
155
146
|
/**
|
|
156
147
|
* Custom vocabularies to use for the transcription.
|
|
157
148
|
*/
|
|
158
|
-
custom_vocabularies:
|
|
149
|
+
custom_vocabularies: z2.array(z2.object({})).optional(),
|
|
159
150
|
/**
|
|
160
151
|
* Whether to strictly enforce custom vocabulary.
|
|
161
152
|
*/
|
|
162
|
-
strict_custom_vocabulary:
|
|
153
|
+
strict_custom_vocabulary: z2.boolean().optional(),
|
|
163
154
|
/**
|
|
164
155
|
* Configuration for generating a summary of the transcription.
|
|
165
156
|
*/
|
|
166
|
-
summarization_config:
|
|
157
|
+
summarization_config: z2.object({
|
|
167
158
|
/**
|
|
168
159
|
* Model to use for summarization.
|
|
169
160
|
*/
|
|
170
|
-
model:
|
|
161
|
+
model: z2.enum(["standard", "premium"]).nullish().default("standard"),
|
|
171
162
|
/**
|
|
172
163
|
* Format of the summary.
|
|
173
164
|
*/
|
|
174
|
-
type:
|
|
165
|
+
type: z2.enum(["paragraph", "bullets"]).nullish().default("paragraph"),
|
|
175
166
|
/**
|
|
176
167
|
* Custom prompt for the summarization.
|
|
177
168
|
*/
|
|
178
|
-
prompt:
|
|
169
|
+
prompt: z2.string().nullish()
|
|
179
170
|
}).nullish(),
|
|
180
171
|
/**
|
|
181
172
|
* Configuration for translating the transcription.
|
|
182
173
|
*/
|
|
183
|
-
translation_config:
|
|
174
|
+
translation_config: z2.object({
|
|
184
175
|
/**
|
|
185
176
|
* Target languages for translation.
|
|
186
177
|
*/
|
|
187
|
-
target_languages:
|
|
188
|
-
|
|
178
|
+
target_languages: z2.array(
|
|
179
|
+
z2.object({
|
|
189
180
|
/**
|
|
190
181
|
* Language code for translation target.
|
|
191
182
|
*/
|
|
192
|
-
language:
|
|
183
|
+
language: z2.enum([
|
|
193
184
|
"en",
|
|
194
185
|
"en-us",
|
|
195
186
|
"en-gb",
|
|
@@ -213,18 +204,18 @@ var revaiTranscriptionModelOptionsSchema = import_v42.z.object({
|
|
|
213
204
|
/**
|
|
214
205
|
* Model to use for translation.
|
|
215
206
|
*/
|
|
216
|
-
model:
|
|
207
|
+
model: z2.enum(["standard", "premium"]).nullish().default("standard")
|
|
217
208
|
}).nullish(),
|
|
218
209
|
/**
|
|
219
210
|
* Language of the audio content.
|
|
220
211
|
*/
|
|
221
|
-
language:
|
|
212
|
+
language: z2.string().nullish().default("en"),
|
|
222
213
|
/**
|
|
223
214
|
* Whether to perform forced alignment.
|
|
224
215
|
*/
|
|
225
|
-
forced_alignment:
|
|
216
|
+
forced_alignment: z2.boolean().nullish().default(false)
|
|
226
217
|
});
|
|
227
|
-
var RevaiTranscriptionModel = class {
|
|
218
|
+
var RevaiTranscriptionModel = class _RevaiTranscriptionModel {
|
|
228
219
|
constructor(modelId, config) {
|
|
229
220
|
this.modelId = modelId;
|
|
230
221
|
this.config = config;
|
|
@@ -233,6 +224,15 @@ var RevaiTranscriptionModel = class {
|
|
|
233
224
|
get provider() {
|
|
234
225
|
return this.config.provider;
|
|
235
226
|
}
|
|
227
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
228
|
+
return serializeModelOptions({
|
|
229
|
+
modelId: model.modelId,
|
|
230
|
+
config: model.config
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
234
|
+
return new _RevaiTranscriptionModel(options.modelId, options.config);
|
|
235
|
+
}
|
|
236
236
|
async getArgs({
|
|
237
237
|
audio,
|
|
238
238
|
mediaType,
|
|
@@ -240,14 +240,14 @@ var RevaiTranscriptionModel = class {
|
|
|
240
240
|
}) {
|
|
241
241
|
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;
|
|
242
242
|
const warnings = [];
|
|
243
|
-
const revaiOptions = await
|
|
243
|
+
const revaiOptions = await parseProviderOptions({
|
|
244
244
|
provider: "revai",
|
|
245
245
|
providerOptions,
|
|
246
246
|
schema: revaiTranscriptionModelOptionsSchema
|
|
247
247
|
});
|
|
248
248
|
const formData = new FormData();
|
|
249
|
-
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([
|
|
250
|
-
const fileExtension =
|
|
249
|
+
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([convertBase64ToUint8Array(audio)]);
|
|
250
|
+
const fileExtension = mediaTypeToExtension(mediaType);
|
|
251
251
|
formData.append(
|
|
252
252
|
"media",
|
|
253
253
|
new File([blob], "audio", { type: mediaType }),
|
|
@@ -297,25 +297,25 @@ var RevaiTranscriptionModel = class {
|
|
|
297
297
|
};
|
|
298
298
|
}
|
|
299
299
|
async doGenerate(options) {
|
|
300
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
300
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
301
301
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
302
302
|
const { formData, warnings } = await this.getArgs(options);
|
|
303
|
-
const { value: submissionResponse } = await
|
|
303
|
+
const { value: submissionResponse } = await postFormDataToApi({
|
|
304
304
|
url: this.config.url({
|
|
305
305
|
path: "/speechtotext/v1/jobs",
|
|
306
306
|
modelId: this.modelId
|
|
307
307
|
}),
|
|
308
|
-
headers: (
|
|
308
|
+
headers: combineHeaders((_e = (_d = this.config).headers) == null ? void 0 : _e.call(_d), options.headers),
|
|
309
309
|
formData,
|
|
310
310
|
failedResponseHandler: revaiFailedResponseHandler,
|
|
311
|
-
successfulResponseHandler:
|
|
311
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
312
312
|
revaiTranscriptionJobResponseSchema
|
|
313
313
|
),
|
|
314
314
|
abortSignal: options.abortSignal,
|
|
315
315
|
fetch: this.config.fetch
|
|
316
316
|
});
|
|
317
317
|
if (submissionResponse.status === "failed") {
|
|
318
|
-
throw new
|
|
318
|
+
throw new AISDKError({
|
|
319
319
|
message: "Failed to submit transcription job to Rev.ai",
|
|
320
320
|
name: "TranscriptionJobSubmissionFailed",
|
|
321
321
|
cause: submissionResponse
|
|
@@ -328,20 +328,20 @@ var RevaiTranscriptionModel = class {
|
|
|
328
328
|
let jobResponse = submissionResponse;
|
|
329
329
|
while (jobResponse.status !== "transcribed") {
|
|
330
330
|
if (Date.now() - startTime > timeoutMs) {
|
|
331
|
-
throw new
|
|
331
|
+
throw new AISDKError({
|
|
332
332
|
message: "Transcription job polling timed out",
|
|
333
333
|
name: "TranscriptionJobPollingTimedOut",
|
|
334
334
|
cause: submissionResponse
|
|
335
335
|
});
|
|
336
336
|
}
|
|
337
|
-
const pollingResult = await
|
|
337
|
+
const pollingResult = await getFromApi({
|
|
338
338
|
url: this.config.url({
|
|
339
339
|
path: `/speechtotext/v1/jobs/${jobId}`,
|
|
340
340
|
modelId: this.modelId
|
|
341
341
|
}),
|
|
342
|
-
headers: (
|
|
342
|
+
headers: combineHeaders((_g = (_f = this.config).headers) == null ? void 0 : _g.call(_f), options.headers),
|
|
343
343
|
failedResponseHandler: revaiFailedResponseHandler,
|
|
344
|
-
successfulResponseHandler:
|
|
344
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
345
345
|
revaiTranscriptionJobResponseSchema
|
|
346
346
|
),
|
|
347
347
|
abortSignal: options.abortSignal,
|
|
@@ -349,28 +349,28 @@ var RevaiTranscriptionModel = class {
|
|
|
349
349
|
});
|
|
350
350
|
jobResponse = pollingResult.value;
|
|
351
351
|
if (jobResponse.status === "failed") {
|
|
352
|
-
throw new
|
|
352
|
+
throw new AISDKError({
|
|
353
353
|
message: "Transcription job failed",
|
|
354
354
|
name: "TranscriptionJobFailed",
|
|
355
355
|
cause: jobResponse
|
|
356
356
|
});
|
|
357
357
|
}
|
|
358
358
|
if (jobResponse.status !== "transcribed") {
|
|
359
|
-
await
|
|
359
|
+
await delay(pollingInterval);
|
|
360
360
|
}
|
|
361
361
|
}
|
|
362
362
|
const {
|
|
363
363
|
value: transcriptionResult,
|
|
364
364
|
responseHeaders,
|
|
365
365
|
rawValue: rawResponse
|
|
366
|
-
} = await
|
|
366
|
+
} = await getFromApi({
|
|
367
367
|
url: this.config.url({
|
|
368
368
|
path: `/speechtotext/v1/jobs/${jobId}/transcript`,
|
|
369
369
|
modelId: this.modelId
|
|
370
370
|
}),
|
|
371
|
-
headers: (
|
|
371
|
+
headers: combineHeaders((_i = (_h = this.config).headers) == null ? void 0 : _i.call(_h), options.headers),
|
|
372
372
|
failedResponseHandler: revaiFailedResponseHandler,
|
|
373
|
-
successfulResponseHandler:
|
|
373
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
374
374
|
revaiTranscriptionResponseSchema
|
|
375
375
|
),
|
|
376
376
|
abortSignal: options.abortSignal,
|
|
@@ -378,11 +378,11 @@ var RevaiTranscriptionModel = class {
|
|
|
378
378
|
});
|
|
379
379
|
let durationInSeconds = 0;
|
|
380
380
|
const segments = [];
|
|
381
|
-
for (const monologue of (
|
|
381
|
+
for (const monologue of (_j = transcriptionResult.monologues) != null ? _j : []) {
|
|
382
382
|
let currentSegmentText = "";
|
|
383
383
|
let segmentStartSecond = 0;
|
|
384
384
|
let hasStartedSegment = false;
|
|
385
|
-
for (const element of (
|
|
385
|
+
for (const element of (_k = monologue == null ? void 0 : monologue.elements) != null ? _k : []) {
|
|
386
386
|
currentSegmentText += element.value;
|
|
387
387
|
if (element.type === "text") {
|
|
388
388
|
if (element.end_ts && element.end_ts > durationInSeconds) {
|
|
@@ -415,14 +415,14 @@ var RevaiTranscriptionModel = class {
|
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
417
|
return {
|
|
418
|
-
text: (
|
|
418
|
+
text: (_m = (_l = transcriptionResult.monologues) == null ? void 0 : _l.map(
|
|
419
419
|
(monologue) => {
|
|
420
420
|
var _a2;
|
|
421
421
|
return (_a2 = monologue == null ? void 0 : monologue.elements) == null ? void 0 : _a2.map((element) => element.value).join("");
|
|
422
422
|
}
|
|
423
|
-
).join(" ")) != null ?
|
|
423
|
+
).join(" ")) != null ? _m : "",
|
|
424
424
|
segments,
|
|
425
|
-
language: (
|
|
425
|
+
language: (_n = submissionResponse.language) != null ? _n : void 0,
|
|
426
426
|
durationInSeconds,
|
|
427
427
|
warnings,
|
|
428
428
|
response: {
|
|
@@ -434,20 +434,20 @@ var RevaiTranscriptionModel = class {
|
|
|
434
434
|
};
|
|
435
435
|
}
|
|
436
436
|
};
|
|
437
|
-
var revaiTranscriptionJobResponseSchema =
|
|
438
|
-
id:
|
|
439
|
-
status:
|
|
440
|
-
language:
|
|
437
|
+
var revaiTranscriptionJobResponseSchema = z2.object({
|
|
438
|
+
id: z2.string().nullish(),
|
|
439
|
+
status: z2.string().nullish(),
|
|
440
|
+
language: z2.string().nullish()
|
|
441
441
|
});
|
|
442
|
-
var revaiTranscriptionResponseSchema =
|
|
443
|
-
monologues:
|
|
444
|
-
|
|
445
|
-
elements:
|
|
446
|
-
|
|
447
|
-
type:
|
|
448
|
-
value:
|
|
449
|
-
ts:
|
|
450
|
-
end_ts:
|
|
442
|
+
var revaiTranscriptionResponseSchema = z2.object({
|
|
443
|
+
monologues: z2.array(
|
|
444
|
+
z2.object({
|
|
445
|
+
elements: z2.array(
|
|
446
|
+
z2.object({
|
|
447
|
+
type: z2.string().nullish(),
|
|
448
|
+
value: z2.string().nullish(),
|
|
449
|
+
ts: z2.number().nullish(),
|
|
450
|
+
end_ts: z2.number().nullish()
|
|
451
451
|
})
|
|
452
452
|
).nullish()
|
|
453
453
|
})
|
|
@@ -455,13 +455,13 @@ var revaiTranscriptionResponseSchema = import_v42.z.object({
|
|
|
455
455
|
});
|
|
456
456
|
|
|
457
457
|
// src/version.ts
|
|
458
|
-
var VERSION = true ? "3.0.0-beta.
|
|
458
|
+
var VERSION = true ? "3.0.0-beta.22" : "0.0.0-test";
|
|
459
459
|
|
|
460
460
|
// src/revai-provider.ts
|
|
461
461
|
function createRevai(options = {}) {
|
|
462
|
-
const getHeaders = () =>
|
|
462
|
+
const getHeaders = () => withUserAgentSuffix(
|
|
463
463
|
{
|
|
464
|
-
authorization: `Bearer ${
|
|
464
|
+
authorization: `Bearer ${loadApiKey({
|
|
465
465
|
apiKey: options.apiKey,
|
|
466
466
|
environmentVariableName: "REVAI_API_KEY",
|
|
467
467
|
description: "Rev.ai"
|
|
@@ -485,14 +485,14 @@ function createRevai(options = {}) {
|
|
|
485
485
|
provider.transcription = createTranscriptionModel;
|
|
486
486
|
provider.transcriptionModel = createTranscriptionModel;
|
|
487
487
|
provider.languageModel = () => {
|
|
488
|
-
throw new
|
|
488
|
+
throw new NoSuchModelError({
|
|
489
489
|
modelId: "unknown",
|
|
490
490
|
modelType: "languageModel",
|
|
491
491
|
message: "Rev.ai does not provide language models"
|
|
492
492
|
});
|
|
493
493
|
};
|
|
494
494
|
provider.embeddingModel = () => {
|
|
495
|
-
throw new
|
|
495
|
+
throw new NoSuchModelError({
|
|
496
496
|
modelId: "unknown",
|
|
497
497
|
modelType: "embeddingModel",
|
|
498
498
|
message: "Rev.ai does not provide text embedding models"
|
|
@@ -500,7 +500,7 @@ function createRevai(options = {}) {
|
|
|
500
500
|
};
|
|
501
501
|
provider.textEmbeddingModel = provider.embeddingModel;
|
|
502
502
|
provider.imageModel = () => {
|
|
503
|
-
throw new
|
|
503
|
+
throw new NoSuchModelError({
|
|
504
504
|
modelId: "unknown",
|
|
505
505
|
modelType: "imageModel",
|
|
506
506
|
message: "Rev.ai does not provide image models"
|
|
@@ -509,10 +509,9 @@ function createRevai(options = {}) {
|
|
|
509
509
|
return provider;
|
|
510
510
|
}
|
|
511
511
|
var revai = createRevai();
|
|
512
|
-
|
|
513
|
-
0 && (module.exports = {
|
|
512
|
+
export {
|
|
514
513
|
VERSION,
|
|
515
514
|
createRevai,
|
|
516
515
|
revai
|
|
517
|
-
}
|
|
516
|
+
};
|
|
518
517
|
//# sourceMappingURL=index.js.map
|