@ai-sdk/assemblyai 3.0.3 → 3.0.4
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 +30 -0
- package/README.md +1 -1
- package/dist/index.d.ts +36 -2
- package/dist/index.js +245 -26
- package/dist/index.js.map +1 -1
- package/docs/100-assemblyai.mdx +134 -9
- package/package.json +2 -2
- package/src/assemblyai-api-types.ts +84 -1
- package/src/assemblyai-provider.ts +1 -1
- package/src/assemblyai-transcription-model-options.ts +83 -1
- package/src/assemblyai-transcription-model.ts +244 -18
- package/src/assemblyai-transcription-settings.ts +15 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @ai-sdk/assemblyai
|
|
2
2
|
|
|
3
|
+
## 3.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ec598e2: feat(assemblyai): support universal-3-5-pro and expand the transcription provider
|
|
8
|
+
|
|
9
|
+
- Add current speech models `universal-3-5-pro`, `universal-3-pro`, and
|
|
10
|
+
`universal-2`, routed via AssemblyAI's `speech_models` parameter (the
|
|
11
|
+
deprecated singular `speech_model` is used only for the legacy `best` model).
|
|
12
|
+
Using `universal-3-pro`/`universal-2` emits an informational warning
|
|
13
|
+
suggesting `universal-3-5-pro`.
|
|
14
|
+
- Deprecate the legacy `best` model (still works, warns) and remove `nano`,
|
|
15
|
+
which AssemblyAI no longer accepts.
|
|
16
|
+
- Surface speaker diarization and audio-intelligence results: `doGenerate` now
|
|
17
|
+
returns the full raw response on `response.body` and populates
|
|
18
|
+
`providerMetadata.assemblyai` with `utterances`, `entities`,
|
|
19
|
+
`sentimentAnalysisResults`, `contentSafetyLabels`, `iabCategoriesResult`, and
|
|
20
|
+
`autoHighlightsResult`.
|
|
21
|
+
- Add provider options for newer request parameters: `prompt`, `keytermsPrompt`,
|
|
22
|
+
`temperature`, `removeAudioTags`, `domain`, `speakerOptions`,
|
|
23
|
+
`languageDetectionOptions`, `redactPiiAudioOptions`,
|
|
24
|
+
`redactPiiReturnUnredacted`, and `redactStaticEntities`. Deprecate
|
|
25
|
+
`wordBoost`/`boostParam` in favor of `keytermsPrompt` (AssemblyAI rejects
|
|
26
|
+
`word_boost` on the newer models).
|
|
27
|
+
- Fix transcription segment timings, which were reported in milliseconds instead
|
|
28
|
+
of seconds.
|
|
29
|
+
|
|
30
|
+
- Updated dependencies [c6f5e62]
|
|
31
|
+
- @ai-sdk/provider-utils@5.0.4
|
|
32
|
+
|
|
3
33
|
## 3.0.3
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ import { assemblyai } from '@ai-sdk/assemblyai';
|
|
|
36
36
|
import { transcribe } from 'ai';
|
|
37
37
|
|
|
38
38
|
const { text } = await transcribe({
|
|
39
|
-
model: assemblyai.transcription('
|
|
39
|
+
model: assemblyai.transcription('universal-3-5-pro'),
|
|
40
40
|
audio: new URL(
|
|
41
41
|
'https://github.com/vercel/ai/raw/refs/heads/main/examples/ai-functions/data/galileo.mp3',
|
|
42
42
|
),
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,15 @@ type AssemblyAIConfig = {
|
|
|
14
14
|
generateId?: () => string;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Legacy AssemblyAI speech model, sent via the deprecated singular
|
|
19
|
+
* `speech_model` request parameter.
|
|
20
|
+
*
|
|
21
|
+
* @deprecated Use `universal-3-5-pro` instead.
|
|
22
|
+
* @see https://www.assemblyai.com/docs/pre-recorded-audio/select-the-speech-model
|
|
23
|
+
*/
|
|
24
|
+
type AssemblyAIDeprecatedTranscriptionModelId = 'best';
|
|
25
|
+
type AssemblyAITranscriptionModelId = 'universal-2' | 'universal-3-pro' | 'universal-3-5-pro' | AssemblyAIDeprecatedTranscriptionModelId | (string & {});
|
|
18
26
|
|
|
19
27
|
interface AssemblyAITranscriptionModelConfig extends AssemblyAIConfig {
|
|
20
28
|
_internal?: {
|
|
@@ -51,7 +59,7 @@ declare class AssemblyAITranscriptionModel implements TranscriptionModelV4 {
|
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
interface AssemblyAIProvider extends ProviderV4 {
|
|
54
|
-
(modelId:
|
|
62
|
+
(modelId: AssemblyAITranscriptionModelId, settings?: {}): {
|
|
55
63
|
transcription: AssemblyAITranscriptionModel;
|
|
56
64
|
};
|
|
57
65
|
/**
|
|
@@ -100,27 +108,53 @@ declare const assemblyaiTranscriptionModelOptionsSchema: z.ZodObject<{
|
|
|
100
108
|
to: z.ZodString;
|
|
101
109
|
}, z.core.$strip>>>>;
|
|
102
110
|
disfluencies: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
111
|
+
domain: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
103
112
|
entityDetection: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
104
113
|
filterProfanity: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
105
114
|
formatText: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
106
115
|
iabCategories: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
116
|
+
keytermsPrompt: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
107
117
|
languageCode: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodLiteral<"en">, z.ZodString]>>>;
|
|
108
118
|
languageConfidenceThreshold: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
109
119
|
languageDetection: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
120
|
+
languageDetectionOptions: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
121
|
+
expectedLanguages: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
122
|
+
fallbackLanguage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
123
|
+
codeSwitching: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
124
|
+
codeSwitchingConfidenceThreshold: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
125
|
+
}, z.core.$strip>>>;
|
|
110
126
|
multichannel: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
127
|
+
prompt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
111
128
|
punctuate: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
112
129
|
redactPii: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
113
130
|
redactPiiAudio: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
131
|
+
redactPiiAudioOptions: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
132
|
+
returnRedactedNoSpeechAudio: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
133
|
+
overrideAudioRedactionMethod: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
134
|
+
silence: "silence";
|
|
135
|
+
}>>>;
|
|
136
|
+
}, z.core.$strip>>>;
|
|
114
137
|
redactPiiAudioQuality: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
115
138
|
redactPiiPolicies: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
139
|
+
redactPiiReturnUnredacted: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
116
140
|
redactPiiSub: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
141
|
+
redactStaticEntities: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>>;
|
|
142
|
+
removeAudioTags: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
143
|
+
all: "all";
|
|
144
|
+
speaker: "speaker";
|
|
145
|
+
}>>>;
|
|
117
146
|
sentimentAnalysis: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
118
147
|
speakerLabels: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
148
|
+
speakerOptions: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
149
|
+
minSpeakersExpected: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
150
|
+
maxSpeakersExpected: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
151
|
+
}, z.core.$strip>>>;
|
|
119
152
|
speakersExpected: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
120
153
|
speechThreshold: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
121
154
|
summarization: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
122
155
|
summaryModel: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
123
156
|
summaryType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
157
|
+
temperature: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
124
158
|
webhookAuthHeaderName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
125
159
|
webhookAuthHeaderValue: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
126
160
|
webhookUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
package/dist/index.js
CHANGED
|
@@ -55,8 +55,12 @@ var assemblyaiTranscriptionModelOptionsSchema = z2.object({
|
|
|
55
55
|
*/
|
|
56
56
|
autoHighlights: z2.boolean().nullish(),
|
|
57
57
|
/**
|
|
58
|
-
* Boost parameter for
|
|
58
|
+
* Boost parameter for word boost (used with `wordBoost`).
|
|
59
59
|
* Allowed values: 'low', 'default', 'high'.
|
|
60
|
+
*
|
|
61
|
+
* @deprecated Only applies to the deprecated `wordBoost` option. Use
|
|
62
|
+
* `keytermsPrompt` instead, which works with the recommended `universal-*`
|
|
63
|
+
* models.
|
|
60
64
|
*/
|
|
61
65
|
boostParam: z2.string().nullish(),
|
|
62
66
|
/**
|
|
@@ -80,6 +84,11 @@ var assemblyaiTranscriptionModelOptionsSchema = z2.object({
|
|
|
80
84
|
* Whether to include filler words (um, uh, etc.) in the transcription.
|
|
81
85
|
*/
|
|
82
86
|
disfluencies: z2.boolean().nullish(),
|
|
87
|
+
/**
|
|
88
|
+
* Enable a domain-specific model to improve accuracy for specialized
|
|
89
|
+
* terminology. Currently supports `'medical-v1'` (Medical Mode).
|
|
90
|
+
*/
|
|
91
|
+
domain: z2.string().nullish(),
|
|
83
92
|
/**
|
|
84
93
|
* Whether to enable entity detection.
|
|
85
94
|
*/
|
|
@@ -96,6 +105,13 @@ var assemblyaiTranscriptionModelOptionsSchema = z2.object({
|
|
|
96
105
|
* Whether to enable IAB categories detection.
|
|
97
106
|
*/
|
|
98
107
|
iabCategories: z2.boolean().nullish(),
|
|
108
|
+
/**
|
|
109
|
+
* Domain-specific keyterms to boost recognition for (max 6 words per phrase).
|
|
110
|
+
* Replaces `wordBoost` for newer models: supported by `universal-3-pro` /
|
|
111
|
+
* `universal-3-5-pro` and `slam-1` (and `universal-2` when metaphone is
|
|
112
|
+
* enabled for the account).
|
|
113
|
+
*/
|
|
114
|
+
keytermsPrompt: z2.array(z2.string()).nullish(),
|
|
99
115
|
/**
|
|
100
116
|
* Language code for the transcription.
|
|
101
117
|
*/
|
|
@@ -108,10 +124,28 @@ var assemblyaiTranscriptionModelOptionsSchema = z2.object({
|
|
|
108
124
|
* Whether to enable language detection.
|
|
109
125
|
*/
|
|
110
126
|
languageDetection: z2.boolean().nullish(),
|
|
127
|
+
/**
|
|
128
|
+
* Options for automatic language detection.
|
|
129
|
+
*/
|
|
130
|
+
languageDetectionOptions: z2.object({
|
|
131
|
+
/** List of languages expected in the audio file. */
|
|
132
|
+
expectedLanguages: z2.array(z2.string()).nullish(),
|
|
133
|
+
/** Fallback language if the detected language is not expected. */
|
|
134
|
+
fallbackLanguage: z2.string().nullish(),
|
|
135
|
+
/** Whether code switching should be detected. */
|
|
136
|
+
codeSwitching: z2.boolean().nullish(),
|
|
137
|
+
/** Confidence threshold for code switching detection (0-1). */
|
|
138
|
+
codeSwitchingConfidenceThreshold: z2.number().min(0).max(1).nullish()
|
|
139
|
+
}).nullish(),
|
|
111
140
|
/**
|
|
112
141
|
* Whether to process audio as multichannel.
|
|
113
142
|
*/
|
|
114
143
|
multichannel: z2.boolean().nullish(),
|
|
144
|
+
/**
|
|
145
|
+
* Provide natural-language context (up to 1,500 words) to steer the model.
|
|
146
|
+
* Only supported by `universal-3-pro` / `universal-3-5-pro` and `slam-1`.
|
|
147
|
+
*/
|
|
148
|
+
prompt: z2.string().nullish(),
|
|
115
149
|
/**
|
|
116
150
|
* Whether to add punctuation to the transcription.
|
|
117
151
|
*/
|
|
@@ -124,6 +158,15 @@ var assemblyaiTranscriptionModelOptionsSchema = z2.object({
|
|
|
124
158
|
* Whether to redact PII in the audio file.
|
|
125
159
|
*/
|
|
126
160
|
redactPiiAudio: z2.boolean().nullish(),
|
|
161
|
+
/**
|
|
162
|
+
* Options for PII-redacted audio files. Requires `redactPiiAudio`.
|
|
163
|
+
*/
|
|
164
|
+
redactPiiAudioOptions: z2.object({
|
|
165
|
+
/** Return redacted audio even for files without detected speech. */
|
|
166
|
+
returnRedactedNoSpeechAudio: z2.boolean().nullish(),
|
|
167
|
+
/** Redaction method; set to `'silence'` to replace PII with silence. */
|
|
168
|
+
overrideAudioRedactionMethod: z2.enum(["silence"]).nullish()
|
|
169
|
+
}).nullish(),
|
|
127
170
|
/**
|
|
128
171
|
* Audio format for PII redaction.
|
|
129
172
|
*/
|
|
@@ -132,10 +175,26 @@ var assemblyaiTranscriptionModelOptionsSchema = z2.object({
|
|
|
132
175
|
* List of PII types to redact.
|
|
133
176
|
*/
|
|
134
177
|
redactPiiPolicies: z2.array(z2.string()).nullish(),
|
|
178
|
+
/**
|
|
179
|
+
* Return the original unredacted transcript alongside the redacted one.
|
|
180
|
+
* Requires `redactPii`.
|
|
181
|
+
*/
|
|
182
|
+
redactPiiReturnUnredacted: z2.boolean().nullish(),
|
|
135
183
|
/**
|
|
136
184
|
* Substitution method for redacted PII.
|
|
137
185
|
*/
|
|
138
186
|
redactPiiSub: z2.string().nullish(),
|
|
187
|
+
/**
|
|
188
|
+
* Map of user-defined labels to exact terms to redact, e.g.
|
|
189
|
+
* `{ INTERNAL_TOOL: ['Bearclaw'] }`. Applied on top of standard PII redaction
|
|
190
|
+
* using `redactPiiSub`. Requires `redactPii`.
|
|
191
|
+
*/
|
|
192
|
+
redactStaticEntities: z2.record(z2.string(), z2.array(z2.string())).nullish(),
|
|
193
|
+
/**
|
|
194
|
+
* Remove inline annotations from rich transcripts. `'all'` removes all inline
|
|
195
|
+
* annotations; `'speaker'` removes only speaker cues. Universal-3 Pro models.
|
|
196
|
+
*/
|
|
197
|
+
removeAudioTags: z2.enum(["all", "speaker"]).nullish(),
|
|
139
198
|
/**
|
|
140
199
|
* Whether to enable sentiment analysis.
|
|
141
200
|
*/
|
|
@@ -144,6 +203,15 @@ var assemblyaiTranscriptionModelOptionsSchema = z2.object({
|
|
|
144
203
|
* Whether to identify different speakers in the audio.
|
|
145
204
|
*/
|
|
146
205
|
speakerLabels: z2.boolean().nullish(),
|
|
206
|
+
/**
|
|
207
|
+
* Options for speaker diarization, e.g. a range of possible speakers.
|
|
208
|
+
*/
|
|
209
|
+
speakerOptions: z2.object({
|
|
210
|
+
/** Minimum number of speakers expected in the audio file. */
|
|
211
|
+
minSpeakersExpected: z2.number().int().nullish(),
|
|
212
|
+
/** Maximum number of speakers expected in the audio file. */
|
|
213
|
+
maxSpeakersExpected: z2.number().int().nullish()
|
|
214
|
+
}).nullish(),
|
|
147
215
|
/**
|
|
148
216
|
* Number of speakers expected in the audio.
|
|
149
217
|
*/
|
|
@@ -164,6 +232,10 @@ var assemblyaiTranscriptionModelOptionsSchema = z2.object({
|
|
|
164
232
|
* Type of summary to generate.
|
|
165
233
|
*/
|
|
166
234
|
summaryType: z2.string().nullish(),
|
|
235
|
+
/**
|
|
236
|
+
* Sampling temperature (0-1) controlling randomness. Universal-3 Pro models.
|
|
237
|
+
*/
|
|
238
|
+
temperature: z2.number().min(0).max(1).nullish(),
|
|
167
239
|
/**
|
|
168
240
|
* Name of the authentication header for webhook requests.
|
|
169
241
|
*/
|
|
@@ -178,6 +250,10 @@ var assemblyaiTranscriptionModelOptionsSchema = z2.object({
|
|
|
178
250
|
webhookUrl: z2.string().nullish(),
|
|
179
251
|
/**
|
|
180
252
|
* List of words to boost recognition for.
|
|
253
|
+
*
|
|
254
|
+
* @deprecated `wordBoost` is rejected by `universal-3-pro` /
|
|
255
|
+
* `universal-3-5-pro` and `slam-1` (it only works on `universal-2`/`best`).
|
|
256
|
+
* Use `keytermsPrompt` instead.
|
|
181
257
|
*/
|
|
182
258
|
wordBoost: z2.array(z2.string()).nullish()
|
|
183
259
|
});
|
|
@@ -205,16 +281,31 @@ var AssemblyAITranscriptionModel = class _AssemblyAITranscriptionModel {
|
|
|
205
281
|
async getArgs({
|
|
206
282
|
providerOptions
|
|
207
283
|
}) {
|
|
208
|
-
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;
|
|
284
|
+
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, _O, _P, _Q, _R, _S, _T, _U, _V, _W;
|
|
209
285
|
const warnings = [];
|
|
210
286
|
const assemblyaiOptions = await parseProviderOptions({
|
|
211
287
|
provider: "assemblyai",
|
|
212
288
|
providerOptions,
|
|
213
289
|
schema: assemblyaiTranscriptionModelOptionsSchema
|
|
214
290
|
});
|
|
215
|
-
const body = {
|
|
216
|
-
|
|
217
|
-
|
|
291
|
+
const body = {};
|
|
292
|
+
if (this.modelId === "best") {
|
|
293
|
+
body.speech_model = this.modelId;
|
|
294
|
+
warnings.push({
|
|
295
|
+
type: "deprecated",
|
|
296
|
+
setting: `model '${this.modelId}'`,
|
|
297
|
+
message: "The 'best' model is a legacy AssemblyAI model. Use 'universal-3-5-pro' instead. See documentation: https://www.assemblyai.com/docs/pre-recorded-audio/select-the-speech-model"
|
|
298
|
+
});
|
|
299
|
+
} else {
|
|
300
|
+
body.speech_models = [this.modelId];
|
|
301
|
+
if (this.modelId === "universal-3-pro" || this.modelId === "universal-2") {
|
|
302
|
+
const docsUrl = "https://www.assemblyai.com/docs/pre-recorded-audio/select-the-speech-model";
|
|
303
|
+
warnings.push({
|
|
304
|
+
type: "other",
|
|
305
|
+
message: this.modelId === "universal-3-pro" ? `'universal-3-5-pro' is AssemblyAI's latest flagship model and is set to replace 'universal-3-pro'. See ${docsUrl}` : `'universal-3-5-pro' is AssemblyAI's latest flagship model. See ${docsUrl}`
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
}
|
|
218
309
|
if (assemblyaiOptions) {
|
|
219
310
|
body.audio_end_at = (_a = assemblyaiOptions.audioEndAt) != null ? _a : void 0;
|
|
220
311
|
body.audio_start_from = (_b = assemblyaiOptions.audioStartFrom) != null ? _b : void 0;
|
|
@@ -250,6 +341,65 @@ var AssemblyAITranscriptionModel = class _AssemblyAITranscriptionModel {
|
|
|
250
341
|
body.webhook_auth_header_value = (_F = assemblyaiOptions.webhookAuthHeaderValue) != null ? _F : void 0;
|
|
251
342
|
body.webhook_url = (_G = assemblyaiOptions.webhookUrl) != null ? _G : void 0;
|
|
252
343
|
body.word_boost = (_H = assemblyaiOptions.wordBoost) != null ? _H : void 0;
|
|
344
|
+
body.keyterms_prompt = (_I = assemblyaiOptions.keytermsPrompt) != null ? _I : void 0;
|
|
345
|
+
body.prompt = (_J = assemblyaiOptions.prompt) != null ? _J : void 0;
|
|
346
|
+
body.temperature = (_K = assemblyaiOptions.temperature) != null ? _K : void 0;
|
|
347
|
+
body.remove_audio_tags = (_L = assemblyaiOptions.removeAudioTags) != null ? _L : void 0;
|
|
348
|
+
body.domain = (_M = assemblyaiOptions.domain) != null ? _M : void 0;
|
|
349
|
+
body.redact_pii_return_unredacted = (_N = assemblyaiOptions.redactPiiReturnUnredacted) != null ? _N : void 0;
|
|
350
|
+
body.redact_static_entities = (_O = assemblyaiOptions.redactStaticEntities) != null ? _O : void 0;
|
|
351
|
+
if (assemblyaiOptions.speakerOptions) {
|
|
352
|
+
body.speaker_options = {
|
|
353
|
+
min_speakers_expected: (_P = assemblyaiOptions.speakerOptions.minSpeakersExpected) != null ? _P : void 0,
|
|
354
|
+
max_speakers_expected: (_Q = assemblyaiOptions.speakerOptions.maxSpeakersExpected) != null ? _Q : void 0
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
if (assemblyaiOptions.languageDetectionOptions) {
|
|
358
|
+
body.language_detection_options = {
|
|
359
|
+
expected_languages: (_R = assemblyaiOptions.languageDetectionOptions.expectedLanguages) != null ? _R : void 0,
|
|
360
|
+
fallback_language: (_S = assemblyaiOptions.languageDetectionOptions.fallbackLanguage) != null ? _S : void 0,
|
|
361
|
+
code_switching: (_T = assemblyaiOptions.languageDetectionOptions.codeSwitching) != null ? _T : void 0,
|
|
362
|
+
code_switching_confidence_threshold: (_U = assemblyaiOptions.languageDetectionOptions.codeSwitchingConfidenceThreshold) != null ? _U : void 0
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
if (assemblyaiOptions.redactPiiAudioOptions) {
|
|
366
|
+
body.redact_pii_audio_options = {
|
|
367
|
+
return_redacted_no_speech_audio: (_V = assemblyaiOptions.redactPiiAudioOptions.returnRedactedNoSpeechAudio) != null ? _V : void 0,
|
|
368
|
+
override_audio_redaction_method: (_W = assemblyaiOptions.redactPiiAudioOptions.overrideAudioRedactionMethod) != null ? _W : void 0
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
const deprecatedBoostOptions = [];
|
|
372
|
+
if (assemblyaiOptions.wordBoost != null) {
|
|
373
|
+
deprecatedBoostOptions.push("wordBoost");
|
|
374
|
+
}
|
|
375
|
+
if (assemblyaiOptions.boostParam != null) {
|
|
376
|
+
deprecatedBoostOptions.push("boostParam");
|
|
377
|
+
}
|
|
378
|
+
if (deprecatedBoostOptions.length > 0) {
|
|
379
|
+
warnings.push({
|
|
380
|
+
type: "deprecated",
|
|
381
|
+
setting: deprecatedBoostOptions.join(", "),
|
|
382
|
+
message: "'wordBoost' and 'boostParam' are deprecated and are rejected by 'universal-3-pro' / 'universal-3-5-pro' and 'slam-1'. Use 'keytermsPrompt' instead."
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
if ((assemblyaiOptions.redactPiiReturnUnredacted != null || assemblyaiOptions.redactStaticEntities != null) && !assemblyaiOptions.redactPii) {
|
|
386
|
+
warnings.push({
|
|
387
|
+
type: "other",
|
|
388
|
+
message: "'redactPiiReturnUnredacted' and 'redactStaticEntities' require 'redactPii' to be enabled; AssemblyAI rejects the request otherwise."
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
if (assemblyaiOptions.redactPiiAudioOptions != null && !assemblyaiOptions.redactPiiAudio) {
|
|
392
|
+
warnings.push({
|
|
393
|
+
type: "other",
|
|
394
|
+
message: "'redactPiiAudioOptions' only applies when 'redactPiiAudio' is enabled; it is otherwise ignored."
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
if (assemblyaiOptions.languageCode != null && assemblyaiOptions.languageDetection) {
|
|
398
|
+
warnings.push({
|
|
399
|
+
type: "other",
|
|
400
|
+
message: "'languageDetection' cannot be combined with an explicit 'languageCode'; AssemblyAI rejects requests that set both."
|
|
401
|
+
});
|
|
402
|
+
}
|
|
253
403
|
}
|
|
254
404
|
return {
|
|
255
405
|
body,
|
|
@@ -262,13 +412,14 @@ var AssemblyAITranscriptionModel = class _AssemblyAITranscriptionModel {
|
|
|
262
412
|
* @see https://www.assemblyai.com/docs/getting-started/transcribe-an-audio-file#step-33
|
|
263
413
|
*/
|
|
264
414
|
async waitForCompletion(transcriptId, headers, abortSignal) {
|
|
265
|
-
var _a, _b, _c, _d;
|
|
415
|
+
var _a, _b, _c, _d, _e;
|
|
266
416
|
const pollingInterval = (_a = this.config.pollingInterval) != null ? _a : this.POLLING_INTERVAL_MS;
|
|
417
|
+
const fetchImpl = (_b = this.config.fetch) != null ? _b : globalThis.fetch;
|
|
267
418
|
while (true) {
|
|
268
419
|
if (abortSignal == null ? void 0 : abortSignal.aborted) {
|
|
269
420
|
throw new Error("Transcription request was aborted");
|
|
270
421
|
}
|
|
271
|
-
const response = await
|
|
422
|
+
const response = await fetchImpl(
|
|
272
423
|
this.config.url({
|
|
273
424
|
path: `/v2/transcript/${transcriptId}`,
|
|
274
425
|
modelId: this.modelId
|
|
@@ -276,7 +427,7 @@ var AssemblyAITranscriptionModel = class _AssemblyAITranscriptionModel {
|
|
|
276
427
|
{
|
|
277
428
|
method: "GET",
|
|
278
429
|
headers: combineHeaders(
|
|
279
|
-
(
|
|
430
|
+
(_d = (_c = this.config).headers) == null ? void 0 : _d.call(_c),
|
|
280
431
|
headers
|
|
281
432
|
),
|
|
282
433
|
signal: abortSignal
|
|
@@ -292,25 +443,25 @@ var AssemblyAITranscriptionModel = class _AssemblyAITranscriptionModel {
|
|
|
292
443
|
requestBodyValues: {}
|
|
293
444
|
});
|
|
294
445
|
}
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
);
|
|
446
|
+
const rawTranscript = await response.json();
|
|
447
|
+
const transcript = assemblyaiTranscriptionResponseSchema.parse(rawTranscript);
|
|
298
448
|
if (transcript.status === "completed") {
|
|
299
449
|
return {
|
|
300
450
|
transcript,
|
|
451
|
+
rawTranscript,
|
|
301
452
|
responseHeaders: extractResponseHeaders(response)
|
|
302
453
|
};
|
|
303
454
|
}
|
|
304
455
|
if (transcript.status === "error") {
|
|
305
456
|
throw new Error(
|
|
306
|
-
`Transcription failed: ${(
|
|
457
|
+
`Transcription failed: ${(_e = transcript.error) != null ? _e : "Unknown error"}`
|
|
307
458
|
);
|
|
308
459
|
}
|
|
309
460
|
await new Promise((resolve) => setTimeout(resolve, pollingInterval));
|
|
310
461
|
}
|
|
311
462
|
}
|
|
312
463
|
async doGenerate(options) {
|
|
313
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n
|
|
464
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
314
465
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
315
466
|
const { value: uploadResponse } = await postToApi({
|
|
316
467
|
url: this.config.url({
|
|
@@ -350,28 +501,56 @@ var AssemblyAITranscriptionModel = class _AssemblyAITranscriptionModel {
|
|
|
350
501
|
abortSignal: options.abortSignal,
|
|
351
502
|
fetch: this.config.fetch
|
|
352
503
|
});
|
|
353
|
-
const { transcript, responseHeaders } = await this.waitForCompletion(
|
|
504
|
+
const { transcript, rawTranscript, responseHeaders } = await this.waitForCompletion(
|
|
354
505
|
submitResponse.id,
|
|
355
506
|
options.headers,
|
|
356
507
|
options.abortSignal
|
|
357
508
|
);
|
|
509
|
+
const raw = rawTranscript != null ? rawTranscript : {};
|
|
510
|
+
const assemblyaiMetadata = {};
|
|
511
|
+
if (transcript.utterances != null) {
|
|
512
|
+
assemblyaiMetadata.utterances = raw.utterances;
|
|
513
|
+
}
|
|
514
|
+
if (transcript.sentiment_analysis_results != null) {
|
|
515
|
+
assemblyaiMetadata.sentimentAnalysisResults = raw.sentiment_analysis_results;
|
|
516
|
+
}
|
|
517
|
+
if (transcript.entities != null) {
|
|
518
|
+
assemblyaiMetadata.entities = raw.entities;
|
|
519
|
+
}
|
|
520
|
+
if (transcript.content_safety_labels != null) {
|
|
521
|
+
assemblyaiMetadata.contentSafetyLabels = raw.content_safety_labels;
|
|
522
|
+
}
|
|
523
|
+
if (transcript.iab_categories_result != null) {
|
|
524
|
+
assemblyaiMetadata.iabCategoriesResult = raw.iab_categories_result;
|
|
525
|
+
}
|
|
526
|
+
if (transcript.auto_highlights_result != null) {
|
|
527
|
+
assemblyaiMetadata.autoHighlightsResult = raw.auto_highlights_result;
|
|
528
|
+
}
|
|
529
|
+
const lastWordEndMs = (_i = (_h = transcript.words) == null ? void 0 : _h.at(-1)) == null ? void 0 : _i.end;
|
|
358
530
|
return {
|
|
359
|
-
text: (
|
|
360
|
-
|
|
531
|
+
text: (_j = transcript.text) != null ? _j : "",
|
|
532
|
+
// AssemblyAI returns word timings in milliseconds; the AI SDK reports
|
|
533
|
+
// segment timings in seconds.
|
|
534
|
+
segments: (_l = (_k = transcript.words) == null ? void 0 : _k.map((word) => ({
|
|
361
535
|
text: word.text,
|
|
362
|
-
startSecond: word.start,
|
|
363
|
-
endSecond: word.end
|
|
364
|
-
}))) != null ?
|
|
365
|
-
language: (
|
|
366
|
-
durationInSeconds: (
|
|
536
|
+
startSecond: word.start / 1e3,
|
|
537
|
+
endSecond: word.end / 1e3
|
|
538
|
+
}))) != null ? _l : [],
|
|
539
|
+
language: (_m = transcript.language_code) != null ? _m : void 0,
|
|
540
|
+
durationInSeconds: (_n = transcript.audio_duration) != null ? _n : lastWordEndMs != null ? lastWordEndMs / 1e3 : void 0,
|
|
367
541
|
warnings,
|
|
542
|
+
...Object.keys(assemblyaiMetadata).length > 0 && {
|
|
543
|
+
providerMetadata: {
|
|
544
|
+
assemblyai: assemblyaiMetadata
|
|
545
|
+
}
|
|
546
|
+
},
|
|
368
547
|
response: {
|
|
369
548
|
timestamp: currentDate,
|
|
370
549
|
modelId: this.modelId,
|
|
371
550
|
headers: responseHeaders,
|
|
372
551
|
// Headers from final GET request
|
|
373
|
-
body:
|
|
374
|
-
//
|
|
552
|
+
body: rawTranscript
|
|
553
|
+
// Full raw response from final GET request
|
|
375
554
|
}
|
|
376
555
|
};
|
|
377
556
|
}
|
|
@@ -383,24 +562,64 @@ var assemblyaiSubmitResponseSchema = z3.object({
|
|
|
383
562
|
id: z3.string(),
|
|
384
563
|
status: z3.enum(["queued", "processing", "completed", "error"])
|
|
385
564
|
});
|
|
565
|
+
var assemblyaiWordSchema = z3.object({
|
|
566
|
+
start: z3.number(),
|
|
567
|
+
end: z3.number(),
|
|
568
|
+
text: z3.string(),
|
|
569
|
+
confidence: z3.number().nullish(),
|
|
570
|
+
// Speaker label (e.g. 'A', 'B') when speaker diarization is enabled, else null.
|
|
571
|
+
speaker: z3.string().nullish(),
|
|
572
|
+
channel: z3.string().nullish()
|
|
573
|
+
});
|
|
386
574
|
var assemblyaiTranscriptionResponseSchema = z3.object({
|
|
387
575
|
id: z3.string(),
|
|
388
576
|
status: z3.enum(["queued", "processing", "completed", "error"]),
|
|
389
577
|
text: z3.string().nullish(),
|
|
390
578
|
language_code: z3.string().nullish(),
|
|
391
|
-
|
|
579
|
+
speech_model_used: z3.string().nullish(),
|
|
580
|
+
words: z3.array(assemblyaiWordSchema).nullish(),
|
|
581
|
+
// Speaker-diarized utterances (present when `speaker_labels` is enabled).
|
|
582
|
+
utterances: z3.array(
|
|
392
583
|
z3.object({
|
|
393
584
|
start: z3.number(),
|
|
394
585
|
end: z3.number(),
|
|
395
|
-
text: z3.string()
|
|
586
|
+
text: z3.string(),
|
|
587
|
+
confidence: z3.number().nullish(),
|
|
588
|
+
speaker: z3.string().nullish(),
|
|
589
|
+
channel: z3.string().nullish(),
|
|
590
|
+
words: z3.array(assemblyaiWordSchema).nullish()
|
|
591
|
+
})
|
|
592
|
+
).nullish(),
|
|
593
|
+
// Audio-intelligence results, present only when the matching feature is
|
|
594
|
+
// enabled. Kept intentionally permissive (the full structures are also
|
|
595
|
+
// available on the raw `response.body`).
|
|
596
|
+
sentiment_analysis_results: z3.array(
|
|
597
|
+
z3.object({
|
|
598
|
+
text: z3.string(),
|
|
599
|
+
start: z3.number().nullish(),
|
|
600
|
+
end: z3.number().nullish(),
|
|
601
|
+
sentiment: z3.string(),
|
|
602
|
+
confidence: z3.number().nullish(),
|
|
603
|
+
speaker: z3.string().nullish()
|
|
604
|
+
})
|
|
605
|
+
).nullish(),
|
|
606
|
+
entities: z3.array(
|
|
607
|
+
z3.object({
|
|
608
|
+
entity_type: z3.string(),
|
|
609
|
+
text: z3.string(),
|
|
610
|
+
start: z3.number().nullish(),
|
|
611
|
+
end: z3.number().nullish()
|
|
396
612
|
})
|
|
397
613
|
).nullish(),
|
|
614
|
+
content_safety_labels: z3.record(z3.string(), z3.any()).nullish(),
|
|
615
|
+
iab_categories_result: z3.record(z3.string(), z3.any()).nullish(),
|
|
616
|
+
auto_highlights_result: z3.record(z3.string(), z3.any()).nullish(),
|
|
398
617
|
audio_duration: z3.number().nullish(),
|
|
399
618
|
error: z3.string().nullish()
|
|
400
619
|
});
|
|
401
620
|
|
|
402
621
|
// src/version.ts
|
|
403
|
-
var VERSION = true ? "3.0.
|
|
622
|
+
var VERSION = true ? "3.0.4" : "0.0.0-test";
|
|
404
623
|
|
|
405
624
|
// src/assemblyai-provider.ts
|
|
406
625
|
function createAssemblyAI(options = {}) {
|