@mux/ai 0.27.1 → 0.28.1
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-Zwh0Bwq3.d.ts → index-DUVBpnj5.d.ts} +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +23 -47
- package/dist/index.js.map +1 -1
- package/dist/workflows/index.d.ts +1 -1
- package/dist/workflows/index.js +22 -46
- package/dist/workflows/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AskQuestionsOptions, j as AskQuestionsResult, k as AskQuestionsType, l as AudioTranslationOptions, m as AudioTranslationResult, n as AutoCensorProfanityOptions, B as BurnedInCaptionsAnalysis, o as BurnedInCaptionsOptions, p as BurnedInCaptionsPromptOverrides, q as BurnedInCaptionsPromptSections, r as BurnedInCaptionsResult, C as CaptionReplacement, s as CensorMode, u as Chapter, v as ChapterSystemPromptSections, w as ChaptersOptions, x as ChaptersPromptOverrides, y as ChaptersPromptSections, z as ChaptersResult, D as ChaptersType, E as DEFAULT_DESCRIPTION_LENGTH, F as DEFAULT_SUMMARY_KEYWORD_LIMIT, G as DEFAULT_TITLE_LENGTH, H as EditCaptionsOptions, J as EditCaptionsResult, K as EmbeddingsOptions, M as EmbeddingsResult, N as EngagementInsightsOptions, O as EngagementInsightsResult, P as GOOGLE_VISION_LIKELIHOOD_TO_SCORE, Q as HIVE_SEXUAL_CATEGORIES, R as HIVE_VIOLENCE_CATEGORIES, T as HiveModerationOutput, U as HiveModerationSource, V as ModerationOptions, W as ModerationProvider, X as ModerationResult, Y as MomentInsight, Z as OverallInsight, _ as ProfanityDetectionPayload, $ as Question, a0 as QuestionAnswer, a1 as QuestionAnswerType, a2 as ReplacementRecord, a3 as SummarizationOptions, a4 as SummarizationPromptOverrides, a5 as SummarizationPromptSections, a6 as SummaryAndTagsResult, a7 as SummaryType, a8 as ThumbnailModerationScore, a9 as TranslationChunkingOptions, aa as TranslationOptions, ab as TranslationPayload, ac as TranslationResult, ad as aggregateTokenUsage, ae as applyOverrideLists, af as applyReplacements, ag as askQuestions, ah as buildReplacementRegex, ai as burnedInCaptionsSchema, aj as censorVttContent, ak as chapterSchema, al as chaptersSchema, am as createReplacer, an as editCaptions, ao as extractTranscriptSegmentsForHotspots, ap as generateChapters, aq as generateEmbeddings, ar as generateEngagementInsights, as as generateVideoEmbeddings, at as getModerationScores, au as getSummaryAndTags, av as hasBurnedInCaptions, aw as mapShotsToHotspots, ax as normalizeTranslatedVtt, ay as profanityDetectionSchema, az as questionAnswerSchema, aA as shouldSplitChunkTranslationError, aB as summarySchema, aC as transformCueText, aD as translateAudio, aE as translateCaptions, aF as translationSchema } from '../index-
|
|
1
|
+
export { A as AskQuestionsOptions, j as AskQuestionsResult, k as AskQuestionsType, l as AudioTranslationOptions, m as AudioTranslationResult, n as AutoCensorProfanityOptions, B as BurnedInCaptionsAnalysis, o as BurnedInCaptionsOptions, p as BurnedInCaptionsPromptOverrides, q as BurnedInCaptionsPromptSections, r as BurnedInCaptionsResult, C as CaptionReplacement, s as CensorMode, u as Chapter, v as ChapterSystemPromptSections, w as ChaptersOptions, x as ChaptersPromptOverrides, y as ChaptersPromptSections, z as ChaptersResult, D as ChaptersType, E as DEFAULT_DESCRIPTION_LENGTH, F as DEFAULT_SUMMARY_KEYWORD_LIMIT, G as DEFAULT_TITLE_LENGTH, H as EditCaptionsOptions, J as EditCaptionsResult, K as EmbeddingsOptions, M as EmbeddingsResult, N as EngagementInsightsOptions, O as EngagementInsightsResult, P as GOOGLE_VISION_LIKELIHOOD_TO_SCORE, Q as HIVE_SEXUAL_CATEGORIES, R as HIVE_VIOLENCE_CATEGORIES, T as HiveModerationOutput, U as HiveModerationSource, V as ModerationOptions, W as ModerationProvider, X as ModerationResult, Y as MomentInsight, Z as OverallInsight, _ as ProfanityDetectionPayload, $ as Question, a0 as QuestionAnswer, a1 as QuestionAnswerType, a2 as ReplacementRecord, a3 as SummarizationOptions, a4 as SummarizationPromptOverrides, a5 as SummarizationPromptSections, a6 as SummaryAndTagsResult, a7 as SummaryType, a8 as ThumbnailModerationScore, a9 as TranslationChunkingOptions, aa as TranslationOptions, ab as TranslationPayload, ac as TranslationResult, ad as aggregateTokenUsage, ae as applyOverrideLists, af as applyReplacements, ag as askQuestions, ah as buildReplacementRegex, ai as burnedInCaptionsSchema, aj as censorVttContent, ak as chapterSchema, al as chaptersSchema, am as createReplacer, an as editCaptions, ao as extractTranscriptSegmentsForHotspots, ap as generateChapters, aq as generateEmbeddings, ar as generateEngagementInsights, as as generateVideoEmbeddings, at as getModerationScores, au as getSummaryAndTags, av as hasBurnedInCaptions, aw as mapShotsToHotspots, ax as normalizeTranslatedVtt, ay as profanityDetectionSchema, az as questionAnswerSchema, aA as shouldSplitChunkTranslationError, aB as summarySchema, aC as transformCueText, aD as translateAudio, aE as translateCaptions, aF as translationSchema } from '../index-DUVBpnj5.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import '@ai-sdk/anthropic';
|
|
4
4
|
import '@ai-sdk/google';
|
package/dist/workflows/index.js
CHANGED
|
@@ -6267,6 +6267,8 @@ async function getSummaryAndTagsInternal(assetId, options, collectedUsage) {
|
|
|
6267
6267
|
import { sleep } from "workflow";
|
|
6268
6268
|
var STATIC_RENDITION_POLL_INTERVAL_MS = 5e3;
|
|
6269
6269
|
var STATIC_RENDITION_MAX_ATTEMPTS = 36;
|
|
6270
|
+
var DUBBING_POLL_INTERVAL_MS = 1e4;
|
|
6271
|
+
var DEFAULT_DUBBING_POLL_TIMEOUT_SECONDS = 7200;
|
|
6270
6272
|
function getReadyAudioStaticRendition(asset) {
|
|
6271
6273
|
const files = asset.static_renditions?.files;
|
|
6272
6274
|
if (!files || files.length === 0) {
|
|
@@ -6405,9 +6407,16 @@ async function checkElevenLabsDubbingStatus({
|
|
|
6405
6407
|
targetLanguages: statusData.target_languages ?? []
|
|
6406
6408
|
};
|
|
6407
6409
|
}
|
|
6408
|
-
async function
|
|
6410
|
+
async function downloadAndUploadDubbedAudio({
|
|
6409
6411
|
dubbingId,
|
|
6410
6412
|
languageCode,
|
|
6413
|
+
assetId,
|
|
6414
|
+
toLanguageCode,
|
|
6415
|
+
s3Endpoint,
|
|
6416
|
+
s3Region,
|
|
6417
|
+
s3Bucket,
|
|
6418
|
+
storageAdapter,
|
|
6419
|
+
s3SignedUrlExpirySeconds,
|
|
6411
6420
|
credentials
|
|
6412
6421
|
}) {
|
|
6413
6422
|
"use step";
|
|
@@ -6421,19 +6430,7 @@ async function downloadDubbedAudioFromElevenLabs({
|
|
|
6421
6430
|
if (!audioResponse.ok) {
|
|
6422
6431
|
throw new Error(`Failed to fetch dubbed audio: ${audioResponse.statusText}`);
|
|
6423
6432
|
}
|
|
6424
|
-
|
|
6425
|
-
}
|
|
6426
|
-
async function uploadDubbedAudioToS3({
|
|
6427
|
-
dubbedAudioBuffer,
|
|
6428
|
-
assetId,
|
|
6429
|
-
toLanguageCode,
|
|
6430
|
-
s3Endpoint,
|
|
6431
|
-
s3Region,
|
|
6432
|
-
s3Bucket,
|
|
6433
|
-
storageAdapter,
|
|
6434
|
-
s3SignedUrlExpirySeconds
|
|
6435
|
-
}) {
|
|
6436
|
-
"use step";
|
|
6433
|
+
const dubbedAudio = new Uint8Array(await audioResponse.arrayBuffer());
|
|
6437
6434
|
const s3AccessKeyId = env_default.S3_ACCESS_KEY_ID;
|
|
6438
6435
|
const s3SecretAccessKey = env_default.S3_SECRET_ACCESS_KEY;
|
|
6439
6436
|
const audioKey = `audio-translations/${assetId}/auto-to-${toLanguageCode}-${Date.now()}.m4a`;
|
|
@@ -6444,7 +6441,7 @@ async function uploadDubbedAudioToS3({
|
|
|
6444
6441
|
region: s3Region,
|
|
6445
6442
|
bucket: s3Bucket,
|
|
6446
6443
|
key: audioKey,
|
|
6447
|
-
body:
|
|
6444
|
+
body: dubbedAudio,
|
|
6448
6445
|
contentType: "audio/mp4"
|
|
6449
6446
|
}, storageAdapter);
|
|
6450
6447
|
const presignedUrl = await createPresignedGetUrlWithStorageAdapter({
|
|
@@ -6549,12 +6546,13 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
6549
6546
|
wrapError(error, "Failed to create ElevenLabs dubbing job");
|
|
6550
6547
|
}
|
|
6551
6548
|
console.warn("\u23F3 Waiting for dubbing to complete...");
|
|
6549
|
+
const dubbingPollTimeoutSeconds = options.dubbingPollTimeoutSeconds ?? DEFAULT_DUBBING_POLL_TIMEOUT_SECONDS;
|
|
6550
|
+
const maxPollAttempts = Math.max(1, Math.ceil(dubbingPollTimeoutSeconds * 1e3 / DUBBING_POLL_INTERVAL_MS));
|
|
6552
6551
|
let dubbingStatus = "dubbing";
|
|
6553
6552
|
let pollAttempts = 0;
|
|
6554
|
-
const maxPollAttempts = 180;
|
|
6555
6553
|
let targetLanguages = [];
|
|
6556
6554
|
while (dubbingStatus !== "dubbed" && pollAttempts < maxPollAttempts) {
|
|
6557
|
-
await sleep(
|
|
6555
|
+
await sleep(DUBBING_POLL_INTERVAL_MS);
|
|
6558
6556
|
pollAttempts++;
|
|
6559
6557
|
try {
|
|
6560
6558
|
const statusResult = await checkElevenLabsDubbingStatus({
|
|
@@ -6577,46 +6575,24 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
6577
6575
|
let presignedUrl;
|
|
6578
6576
|
let uploadedTrackId;
|
|
6579
6577
|
if (uploadToS3) {
|
|
6580
|
-
console.warn("\u{1F4E5} Downloading dubbed audio from ElevenLabs...");
|
|
6581
|
-
let dubbedAudioBuffer;
|
|
6578
|
+
console.warn("\u{1F4E5} Downloading dubbed audio from ElevenLabs and staging to S3...");
|
|
6582
6579
|
try {
|
|
6583
|
-
const
|
|
6584
|
-
|
|
6585
|
-
(lang) => lang === requestedLangCode
|
|
6586
|
-
) ?? targetLanguages.find(
|
|
6587
|
-
(lang) => lang.toLowerCase() === requestedLangCode.toLowerCase()
|
|
6588
|
-
);
|
|
6589
|
-
if (!downloadLangCode && targetLanguages.length > 0) {
|
|
6590
|
-
downloadLangCode = targetLanguages[0];
|
|
6591
|
-
console.warn(`\u26A0\uFE0F Requested language "${requestedLangCode}" not found in target_languages. Using "${downloadLangCode}" instead.`);
|
|
6592
|
-
}
|
|
6593
|
-
if (!downloadLangCode) {
|
|
6594
|
-
downloadLangCode = requestedLangCode;
|
|
6595
|
-
console.warn(`\u26A0\uFE0F No target_languages available from ElevenLabs status. Using requested language code: ${requestedLangCode}`);
|
|
6596
|
-
}
|
|
6597
|
-
dubbedAudioBuffer = await downloadDubbedAudioFromElevenLabs({
|
|
6580
|
+
const downloadLangCode = targetLanguages[0] ?? toISO639_1(toLanguageCode);
|
|
6581
|
+
presignedUrl = await downloadAndUploadDubbedAudio({
|
|
6598
6582
|
dubbingId,
|
|
6599
6583
|
languageCode: downloadLangCode,
|
|
6600
|
-
credentials
|
|
6601
|
-
});
|
|
6602
|
-
console.warn("\u2705 Dubbed audio downloaded successfully!");
|
|
6603
|
-
} catch (error) {
|
|
6604
|
-
wrapError(error, "Failed to download dubbed audio");
|
|
6605
|
-
}
|
|
6606
|
-
console.warn("\u{1F4E4} Uploading dubbed audio to S3-compatible storage...");
|
|
6607
|
-
try {
|
|
6608
|
-
presignedUrl = await uploadDubbedAudioToS3({
|
|
6609
|
-
dubbedAudioBuffer,
|
|
6610
6584
|
assetId,
|
|
6611
6585
|
toLanguageCode,
|
|
6612
6586
|
s3Endpoint,
|
|
6613
6587
|
s3Region,
|
|
6614
6588
|
s3Bucket,
|
|
6615
6589
|
storageAdapter: effectiveStorageAdapter,
|
|
6616
|
-
s3SignedUrlExpirySeconds: options.s3SignedUrlExpirySeconds
|
|
6590
|
+
s3SignedUrlExpirySeconds: options.s3SignedUrlExpirySeconds,
|
|
6591
|
+
credentials
|
|
6617
6592
|
});
|
|
6593
|
+
console.warn("\u2705 Dubbed audio staged to S3 successfully!");
|
|
6618
6594
|
} catch (error) {
|
|
6619
|
-
wrapError(error, "Failed to upload audio
|
|
6595
|
+
wrapError(error, "Failed to download and upload dubbed audio");
|
|
6620
6596
|
}
|
|
6621
6597
|
if (uploadToMux) {
|
|
6622
6598
|
console.warn("\u{1F4F9} Adding dubbed audio track to Mux asset...");
|