@mux/ai 0.57.0 → 0.58.0
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/dist/{index-CuL8ReZ7.d.ts → index-bdbFMlhA.d.ts} +35 -7
- package/dist/index.d.ts +2 -2
- package/dist/index.js +74 -49
- package/dist/index.js.map +1 -1
- package/dist/primitives/index.js.map +1 -1
- package/dist/workflows/index.d.ts +1 -1
- package/dist/workflows/index.js +73 -48
- package/dist/workflows/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { J as ASK_QUESTIONS_DEFAULT_MAX_ANSWER_OPTION_LENGTH, K as ASK_QUESTIONS_DEFAULT_MAX_FREE_FORM_ANSWER_LENGTH, N as ASK_QUESTIONS_MAX_QUESTIONS_PER_CALL, O as ASK_QUESTIONS_MAX_QUESTION_LENGTH, P as AskQuestionsOptions, Q as AskQuestionsResult, U as AskQuestionsType, V as AudioTranslationOptions, W as AudioTranslationResult, X as AutoCensorProfanityOptions, Y as BurnedInCaptionsAnalysis, Z as BurnedInCaptionsOptions, _ as BurnedInCaptionsPromptOverrides, $ as BurnedInCaptionsPromptSections, a0 as BurnedInCaptionsResult, a1 as CaptionReplacement, a2 as CensorMode, a3 as Chapter, a4 as ChapterSystemPromptSections, a5 as ChaptersOptions, a6 as ChaptersPromptOverrides, a7 as ChaptersPromptSections, a8 as ChaptersResult, a9 as ChaptersType, aa as DEFAULT_TRANSCRIPT_WINDOWING, ab as
|
|
1
|
+
export { J as ASK_QUESTIONS_DEFAULT_MAX_ANSWER_OPTION_LENGTH, K as ASK_QUESTIONS_DEFAULT_MAX_FREE_FORM_ANSWER_LENGTH, N as ASK_QUESTIONS_MAX_QUESTIONS_PER_CALL, O as ASK_QUESTIONS_MAX_QUESTION_LENGTH, P as AskQuestionsOptions, Q as AskQuestionsResult, U as AskQuestionsType, V as AudioTranslationOptions, W as AudioTranslationResult, X as AutoCensorProfanityOptions, Y as BurnedInCaptionsAnalysis, Z as BurnedInCaptionsOptions, _ as BurnedInCaptionsPromptOverrides, $ as BurnedInCaptionsPromptSections, a0 as BurnedInCaptionsResult, a1 as CaptionReplacement, a2 as CensorMode, a3 as Chapter, a4 as ChapterSystemPromptSections, a5 as ChaptersOptions, a6 as ChaptersPromptOverrides, a7 as ChaptersPromptSections, a8 as ChaptersResult, a9 as ChaptersType, aa as DEFAULT_TRANSCRIPT_WINDOWING, ab as DubbedCaptionsOutcome, ac as EditCaptionsOptions, ad as EditCaptionsResult, ae as EmbeddingsOptions, af as EmbeddingsResult, ag as EngagementInsightsOptions, ah as EngagementInsightsResult, ai as GENERATE_TEXT_CALLS_TO_ACTION, aj as GENERATE_TEXT_CHANNELS, ak as GENERATE_TEXT_CHANNEL_CEILINGS, al as GENERATE_TEXT_FORMATS, am as GENERATE_TEXT_LENGTH_BOUNDS, an as GENERATE_TEXT_MAX_ARTIFACTS, ao as GENERATE_TEXT_MAX_AUDIENCE_CHARS, ap as GENERATE_TEXT_MAX_BRAND_TERMS, aq as GENERATE_TEXT_MAX_BRAND_TERMS_TOTAL_CHARS, ar as GENERATE_TEXT_MAX_BRAND_TERM_CHARS, as as GENERATE_TEXT_MAX_CONCURRENT_GENERATIONS, at as GENERATE_TEXT_MAX_INSTRUCTIONS_CHARS, au as GENERATE_TEXT_MAX_SHOT_FRAMES, av as GENERATE_TEXT_MAX_VARIANTS, aw as GENERATE_TEXT_VOICES, ax as GOOGLE_VISION_LIKELIHOOD_TO_SCORE, ay as GenerateTextArtifact, az as GenerateTextCallToAction, aA as GenerateTextChannel, aB as GenerateTextFormat, aC as GenerateTextKeyedItem, aD as GenerateTextLengthLimit, aE as GenerateTextOptions, aF as GenerateTextResult, aG as GenerateTextVariant, aH as GenerateTextVoice, aI as GeneratedTextArtifact, aJ as GeneratedTextVariant, aK as HIVE_SEXUAL_CATEGORIES, aL as HIVE_VIOLENCE_CATEGORIES, aM as HiveModerationOutput, aN as HiveModerationSource, aO as ModerationOptions, aP as ModerationProvider, aQ as ModerationResult, aR as ModerationSurfaceStatus, aS as MomentInsight, aT as OverallInsight, aU as ProfanityDetectionPayload, aV as Question, aW as QuestionAnswer, aX as QuestionAnswerType, aY as RepairAttempt, aZ as RepairCall, a_ as RepairOptions, a$ as RepairPlan, b0 as RepairResult, b1 as RepairSpan, b2 as ReplacementRecord, b3 as SpeakerReplacement, b4 as StaticRenditionCleanupOutcome, b5 as SummarizationOptions, b6 as SummarizationPromptOverrides, b7 as SummarizationPromptSections, b8 as SummaryAndTagsResult, b9 as SummaryType, ba as TextLengthLimit, bb as TextRepairModelOptions, bc as ThumbnailModerationScore, bd as ThumbnailModerationSkipReason, be as ThumbnailModerationStatus, bf as TranscriptModerationScore, bg as TranscriptModerationSkipReason, bh as TranscriptModerationStatus, bi as TranslationChunkingOptions, bj as TranslationOptions, bk as TranslationPayload, bl as TranslationResult, bm as aggregateTokenUsage, bn as applyOverrideLists, bo as applyReplacements, bp as applySpeakerReplacements, bq as applyTextRepair, br as askQuestions, bs as buildReplacementRegex, bt as buildTranscriptWindows, bu as burnedInCaptionsSchema, bv as censorVttContent, bw as chapterSchema, bx as chaptersSchema, by as createReplacer, bz as createTextRepairGenerator, bA as editCaptions, bB as extractTranscriptSegmentsForHotspots, bC as findGenerateTextLengthViolation, bD as generateChapters, bE as generateEmbeddings, bF as generateEngagementInsights, bG as generateText, bH as generateVideoEmbeddings, bI as getModerationScores, bJ as getSummaryAndTags, bK as hasBurnedInCaptions, bL as mapShotsToHotspots, bM as measureGenerateTextLength, bN as normalizeTranslatedVtt, bO as planTextRepair, bP as profanityDetectionSchema, bQ as questionAnswerSchema, bR as repairJsonSchema, bS as repairText, bT as resolveGenerateTextLengthLimit, bU as resolveGenerateTextLengthLimits, bV as resolveGenerateTextOptions, bW as runTextRepairLoop, bX as selectGenerateTextShotFrames, bY as shouldSplitChunkTranslationError, bZ as summarySchema, b_ as transformCueText, b$ as translateAudio, c0 as translateCaptions, c1 as translationSchema, c2 as validateNeverTranslateTerms, c3 as verifyNeverTranslateTerms } from '../index-bdbFMlhA.js';
|
|
2
2
|
export { D as DEFAULT_DESCRIPTION_LENGTH, a as DEFAULT_SUMMARY_KEYWORD_LIMIT, b as DEFAULT_TITLE_LENGTH } from '../summarization-BFmhXeAu.js';
|
|
3
3
|
import 'ai';
|
|
4
4
|
import '../transcripts-Brw74qlV.js';
|
package/dist/workflows/index.js
CHANGED
|
@@ -8970,6 +8970,8 @@ function getLegacyMp4SupportRenditionSizeError(rendition, maxBytes) {
|
|
|
8970
8970
|
}
|
|
8971
8971
|
|
|
8972
8972
|
// src/workflows/translate-audio.ts
|
|
8973
|
+
var CAPTIONS_UNAVAILABLE_MESSAGE = "The dub completed, but its subtitles could not be retrieved.";
|
|
8974
|
+
var CAPTIONS_ATTACHMENT_FAILED_MESSAGE = "Dub subtitles could not be attached to the Mux asset.";
|
|
8973
8975
|
var STATIC_RENDITION_POLL_INTERVAL_MS = 1e4;
|
|
8974
8976
|
var STATIC_RENDITION_MAX_ATTEMPTS = 180;
|
|
8975
8977
|
var MAX_DUBBING_SOURCE_BYTES = 1e9;
|
|
@@ -9305,38 +9307,56 @@ async function downloadAndUploadDubTranscript({
|
|
|
9305
9307
|
credentials
|
|
9306
9308
|
}) {
|
|
9307
9309
|
"use step";
|
|
9308
|
-
|
|
9309
|
-
|
|
9310
|
-
|
|
9310
|
+
try {
|
|
9311
|
+
const fetched = await fetchDubbingOutput(dubbingId, languageId, "subtitles", credentials);
|
|
9312
|
+
if (fetched.kind === "failed") {
|
|
9313
|
+
return fetched;
|
|
9314
|
+
}
|
|
9315
|
+
const transcriptVtt = await fetched.response.text();
|
|
9316
|
+
if (!transcriptVtt.trim()) {
|
|
9317
|
+
return { kind: "failed", failure: { retryable: false, detail: "Dub transcript response did not include webvtt content" } };
|
|
9318
|
+
}
|
|
9319
|
+
const s3AccessKeyId = env_default.S3_ACCESS_KEY_ID;
|
|
9320
|
+
const s3SecretAccessKey = env_default.S3_SECRET_ACCESS_KEY;
|
|
9321
|
+
const vttKey = `audio-translations/${assetId}/auto-to-${toLanguageCode}-${Date.now()}.vtt`;
|
|
9322
|
+
await putObjectWithStorageAdapter({
|
|
9323
|
+
accessKeyId: s3AccessKeyId,
|
|
9324
|
+
secretAccessKey: s3SecretAccessKey,
|
|
9325
|
+
endpoint: s3Endpoint,
|
|
9326
|
+
region: s3Region,
|
|
9327
|
+
bucket: s3Bucket,
|
|
9328
|
+
key: vttKey,
|
|
9329
|
+
body: transcriptVtt,
|
|
9330
|
+
contentType: "text/vtt"
|
|
9331
|
+
}, storageAdapter);
|
|
9332
|
+
const presignedUrl = await createPresignedGetUrlWithStorageAdapter({
|
|
9333
|
+
accessKeyId: s3AccessKeyId,
|
|
9334
|
+
secretAccessKey: s3SecretAccessKey,
|
|
9335
|
+
endpoint: s3Endpoint,
|
|
9336
|
+
region: s3Region,
|
|
9337
|
+
bucket: s3Bucket,
|
|
9338
|
+
key: vttKey,
|
|
9339
|
+
expiresInSeconds: s3SignedUrlExpirySeconds ?? 86400
|
|
9340
|
+
}, storageAdapter);
|
|
9341
|
+
console.warn(`\u2705 Dub transcript uploaded successfully to: ${vttKey}`);
|
|
9342
|
+
return { kind: "staged", presignedUrl };
|
|
9343
|
+
} catch (error) {
|
|
9344
|
+
return { kind: "failed", failure: { retryable: true, detail: extractErrorDetail(error) } };
|
|
9311
9345
|
}
|
|
9312
|
-
|
|
9313
|
-
|
|
9314
|
-
|
|
9346
|
+
}
|
|
9347
|
+
async function attachDubbedCaptions(input) {
|
|
9348
|
+
"use step";
|
|
9349
|
+
try {
|
|
9350
|
+
const outcome = await replaceAndCreateTrack(input);
|
|
9351
|
+
if (outcome.kind === "created") {
|
|
9352
|
+
return { status: "created", trackId: outcome.trackId, replacedTracks: outcome.deleted };
|
|
9353
|
+
}
|
|
9354
|
+
console.warn(`\u26A0\uFE0F Failed to attach dubbed captions: ${outcome.reason}`);
|
|
9355
|
+
return { status: "failed", message: outcome.kind === "blocked" ? outcome.reason : CAPTIONS_ATTACHMENT_FAILED_MESSAGE, retryable: outcome.kind === "create_failed", replacedTracks: outcome.deleted };
|
|
9356
|
+
} catch (error) {
|
|
9357
|
+
console.warn(`\u26A0\uFE0F Failed to attach dubbed captions: ${extractErrorDetail(error)}`);
|
|
9358
|
+
return { status: "failed", message: CAPTIONS_ATTACHMENT_FAILED_MESSAGE, retryable: true, replacedTracks: [] };
|
|
9315
9359
|
}
|
|
9316
|
-
const s3AccessKeyId = env_default.S3_ACCESS_KEY_ID;
|
|
9317
|
-
const s3SecretAccessKey = env_default.S3_SECRET_ACCESS_KEY;
|
|
9318
|
-
const vttKey = `audio-translations/${assetId}/auto-to-${toLanguageCode}-${Date.now()}.vtt`;
|
|
9319
|
-
await putObjectWithStorageAdapter({
|
|
9320
|
-
accessKeyId: s3AccessKeyId,
|
|
9321
|
-
secretAccessKey: s3SecretAccessKey,
|
|
9322
|
-
endpoint: s3Endpoint,
|
|
9323
|
-
region: s3Region,
|
|
9324
|
-
bucket: s3Bucket,
|
|
9325
|
-
key: vttKey,
|
|
9326
|
-
body: transcriptVtt,
|
|
9327
|
-
contentType: "text/vtt"
|
|
9328
|
-
}, storageAdapter);
|
|
9329
|
-
const presignedUrl = await createPresignedGetUrlWithStorageAdapter({
|
|
9330
|
-
accessKeyId: s3AccessKeyId,
|
|
9331
|
-
secretAccessKey: s3SecretAccessKey,
|
|
9332
|
-
endpoint: s3Endpoint,
|
|
9333
|
-
region: s3Region,
|
|
9334
|
-
bucket: s3Bucket,
|
|
9335
|
-
key: vttKey,
|
|
9336
|
-
expiresInSeconds: s3SignedUrlExpirySeconds ?? 86400
|
|
9337
|
-
}, storageAdapter);
|
|
9338
|
-
console.warn(`\u2705 Dub transcript uploaded successfully to: ${vttKey}`);
|
|
9339
|
-
return { kind: "staged", presignedUrl };
|
|
9340
9360
|
}
|
|
9341
9361
|
async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
9342
9362
|
"use workflow";
|
|
@@ -9352,6 +9372,7 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
9352
9372
|
storageAdapter,
|
|
9353
9373
|
credentials: providedCredentials,
|
|
9354
9374
|
replaceExistingTracks = "fail",
|
|
9375
|
+
captionsReplaceExistingTracks = replaceExistingTracks,
|
|
9355
9376
|
trackName: providedTrackName,
|
|
9356
9377
|
trackPassthrough: providedTrackPassthrough
|
|
9357
9378
|
} = options;
|
|
@@ -9370,7 +9391,7 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
9370
9391
|
const muxLangCode = targetLanguageCode;
|
|
9371
9392
|
const trackName = providedTrackName ?? `${getLanguageName(muxLangCode) ?? muxLangCode.toUpperCase()} (Auto-dubbed)`;
|
|
9372
9393
|
const audioTrackTarget = { type: "audio", languageCode: muxLangCode, name: trackName };
|
|
9373
|
-
const captionsTrackTarget = { type: "text", languageCode: muxLangCode, name: trackName };
|
|
9394
|
+
const captionsTrackTarget = { type: "text", languageCode: muxLangCode, name: options.captionsTrackName ?? trackName };
|
|
9374
9395
|
const s3Endpoint = options.s3Endpoint ?? env_default.S3_ENDPOINT;
|
|
9375
9396
|
const s3Region = options.s3Region ?? env_default.S3_REGION ?? "auto";
|
|
9376
9397
|
const s3Bucket = options.s3Bucket ?? env_default.S3_BUCKET;
|
|
@@ -9388,11 +9409,8 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
9388
9409
|
if (audioTrackUnsupported) {
|
|
9389
9410
|
throw new MuxAiError(`Asset ${assetId} ${audioTrackUnsupported}`, { type: "validation_error" });
|
|
9390
9411
|
}
|
|
9391
|
-
|
|
9392
|
-
|
|
9393
|
-
...uploadCaptionsToMux ? [captionsTrackTarget] : []
|
|
9394
|
-
]) {
|
|
9395
|
-
const plan = planTextTrackReplacement(initialAsset, target, replaceExistingTracks);
|
|
9412
|
+
if (uploadToMux) {
|
|
9413
|
+
const plan = planTextTrackReplacement(initialAsset, audioTrackTarget, replaceExistingTracks);
|
|
9396
9414
|
if (plan.kind === "blocked") {
|
|
9397
9415
|
throw new MuxAiError(plan.reason, { type: "validation_error" });
|
|
9398
9416
|
}
|
|
@@ -9417,6 +9435,7 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
9417
9435
|
let replacedTracks;
|
|
9418
9436
|
let captionsPresignedUrl;
|
|
9419
9437
|
let captionsTrackId;
|
|
9438
|
+
let captionsOutcome;
|
|
9420
9439
|
try {
|
|
9421
9440
|
let sourceRenditionName = "audio.m4a";
|
|
9422
9441
|
if (isLegacyMp4SupportAsset) {
|
|
@@ -9595,30 +9614,35 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
9595
9614
|
credentials
|
|
9596
9615
|
});
|
|
9597
9616
|
if (transcript.kind === "failed") {
|
|
9598
|
-
|
|
9617
|
+
captionsOutcome = { status: "unavailable", message: CAPTIONS_UNAVAILABLE_MESSAGE, retryable: transcript.failure.retryable };
|
|
9618
|
+
console.warn(`\u26A0\uFE0F Failed to retrieve dubbed captions: ${transcript.failure.detail}`);
|
|
9619
|
+
} else {
|
|
9620
|
+
captionsPresignedUrl = transcript.presignedUrl;
|
|
9621
|
+
captionsOutcome = { status: "available" };
|
|
9599
9622
|
}
|
|
9600
|
-
captionsPresignedUrl
|
|
9601
|
-
if (uploadCaptionsToMux) {
|
|
9623
|
+
if (uploadCaptionsToMux && captionsPresignedUrl) {
|
|
9602
9624
|
console.warn("\u{1F4F9} Adding dubbed captions track to Mux asset...");
|
|
9603
|
-
|
|
9625
|
+
captionsOutcome = await attachDubbedCaptions({
|
|
9604
9626
|
assetId,
|
|
9605
9627
|
target: captionsTrackTarget,
|
|
9606
|
-
policy:
|
|
9628
|
+
policy: captionsReplaceExistingTracks,
|
|
9607
9629
|
presignedUrl: captionsPresignedUrl,
|
|
9608
9630
|
passthrough: trackPassthrough,
|
|
9609
9631
|
credentials
|
|
9610
9632
|
});
|
|
9611
|
-
if (captionsOutcome.
|
|
9612
|
-
replacedTracks = [...replacedTracks ?? [], ...captionsOutcome.
|
|
9633
|
+
if (captionsOutcome.replacedTracks.length > 0) {
|
|
9634
|
+
replacedTracks = [...replacedTracks ?? [], ...captionsOutcome.replacedTracks];
|
|
9613
9635
|
}
|
|
9614
|
-
if (captionsOutcome.
|
|
9615
|
-
|
|
9636
|
+
if (captionsOutcome.status === "created") {
|
|
9637
|
+
captionsTrackId = captionsOutcome.trackId;
|
|
9638
|
+
console.warn(`\u2705 Captions track added to Mux asset with ID: ${captionsTrackId}`);
|
|
9639
|
+
} else {
|
|
9640
|
+
console.warn(`\u26A0\uFE0F Failed to attach dubbed captions: ${captionsOutcome.message}`);
|
|
9616
9641
|
}
|
|
9617
|
-
captionsTrackId = captionsOutcome.trackId;
|
|
9618
|
-
console.warn(`\u2705 Captions track added to Mux asset with ID: ${captionsTrackId}`);
|
|
9619
9642
|
}
|
|
9620
9643
|
} catch (error) {
|
|
9621
|
-
|
|
9644
|
+
captionsOutcome = captionsPresignedUrl ? { status: "failed", message: CAPTIONS_ATTACHMENT_FAILED_MESSAGE, retryable: true, replacedTracks: [] } : { status: "unavailable", message: CAPTIONS_UNAVAILABLE_MESSAGE, retryable: true };
|
|
9645
|
+
console.warn(`\u26A0\uFE0F Failed to attach dubbed captions: ${extractErrorDetail(error)}`);
|
|
9622
9646
|
if (captionsPresignedUrl) {
|
|
9623
9647
|
console.warn("\u{1F517} You can manually add the captions track using this presigned URL:");
|
|
9624
9648
|
console.warn(captionsPresignedUrl);
|
|
@@ -9648,6 +9672,7 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
9648
9672
|
replacedTracks,
|
|
9649
9673
|
captionsTrackId,
|
|
9650
9674
|
captionsPresignedUrl,
|
|
9675
|
+
captionsOutcome,
|
|
9651
9676
|
createdStaticRenditionId,
|
|
9652
9677
|
staticRenditionCleanup,
|
|
9653
9678
|
usage: {
|