@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
|
@@ -1265,6 +1265,8 @@ interface AudioTranslationOptions extends MuxAIOptions {
|
|
|
1265
1265
|
storageAdapter?: StorageAdapter;
|
|
1266
1266
|
/** Expiry duration in seconds for S3 presigned GET URLs. Defaults to 86400 (24 hours). */
|
|
1267
1267
|
s3SignedUrlExpirySeconds?: number;
|
|
1268
|
+
/** Maximum time in seconds to wait before timing out. Defaults to 7200 (2 hours). */
|
|
1269
|
+
dubbingPollTimeoutSeconds?: number;
|
|
1268
1270
|
}
|
|
1269
1271
|
declare function translateAudio(assetId: string, toLanguageCode: string, options?: AudioTranslationOptions): Promise<AudioTranslationResult>;
|
|
1270
1272
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { I as ISO639_1, a as ISO639_3, L as LanguageCodePair, S as SupportedISO639_1, b as SupportedISO639_3, g as getLanguageCodePair, c as getLanguageName, i as isUndeterminedLanguageCode, d as isValidISO639_1, e as isValidISO639_3, t as toISO639_1, f as toISO639_3, h as workflows } from './index-
|
|
1
|
+
export { I as ISO639_1, a as ISO639_3, L as LanguageCodePair, S as SupportedISO639_1, b as SupportedISO639_3, g as getLanguageCodePair, c as getLanguageName, i as isUndeterminedLanguageCode, d as isValidISO639_1, e as isValidISO639_3, t as toISO639_1, f as toISO639_3, h as workflows } from './index-DUVBpnj5.js';
|
|
2
2
|
import { W as WorkflowCredentials, S as StoragePutObjectInput, a as StoragePresignGetObjectInput } from './shots-mGJfYGiO.js';
|
|
3
3
|
export { A as AssetTextTrack, C as ChunkEmbedding, b as ChunkingStrategy, E as Encrypted, c as EncryptedPayload, I as ImageSubmissionMode, M as MuxAIOptions, d as MuxAsset, P as PlaybackAsset, e as PlaybackPolicy, f as StorageAdapter, T as TextChunk, g as TokenChunkingConfig, h as TokenUsage, i as ToneType, U as UsageMetadata, V as VTTChunkingConfig, j as VideoEmbeddingsResult, k as WorkflowCredentialsInput, l as WorkflowMuxClient, m as decryptFromWorkflow, n as encryptForWorkflow } from './shots-mGJfYGiO.js';
|
|
4
4
|
import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@workflow/serde';
|
|
@@ -9,7 +9,7 @@ import '@ai-sdk/google';
|
|
|
9
9
|
import '@ai-sdk/openai';
|
|
10
10
|
import '@mux/mux-node';
|
|
11
11
|
|
|
12
|
-
var version = "0.
|
|
12
|
+
var version = "0.28.1";
|
|
13
13
|
|
|
14
14
|
type MuxAiErrorType = "validation_error" | "processing_error" | "timeout_error";
|
|
15
15
|
/**
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var __export = (target, all) => {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// package.json
|
|
8
|
-
var version = "0.
|
|
8
|
+
var version = "0.28.1";
|
|
9
9
|
|
|
10
10
|
// src/lib/language-codes.ts
|
|
11
11
|
var ISO639_1_TO_3 = {
|
|
@@ -6589,6 +6589,8 @@ async function getSummaryAndTagsInternal(assetId, options, collectedUsage) {
|
|
|
6589
6589
|
import { sleep as sleep2 } from "workflow";
|
|
6590
6590
|
var STATIC_RENDITION_POLL_INTERVAL_MS = 5e3;
|
|
6591
6591
|
var STATIC_RENDITION_MAX_ATTEMPTS = 36;
|
|
6592
|
+
var DUBBING_POLL_INTERVAL_MS = 1e4;
|
|
6593
|
+
var DEFAULT_DUBBING_POLL_TIMEOUT_SECONDS = 7200;
|
|
6592
6594
|
function getReadyAudioStaticRendition(asset) {
|
|
6593
6595
|
const files = asset.static_renditions?.files;
|
|
6594
6596
|
if (!files || files.length === 0) {
|
|
@@ -6727,9 +6729,16 @@ async function checkElevenLabsDubbingStatus({
|
|
|
6727
6729
|
targetLanguages: statusData.target_languages ?? []
|
|
6728
6730
|
};
|
|
6729
6731
|
}
|
|
6730
|
-
async function
|
|
6732
|
+
async function downloadAndUploadDubbedAudio({
|
|
6731
6733
|
dubbingId,
|
|
6732
6734
|
languageCode,
|
|
6735
|
+
assetId,
|
|
6736
|
+
toLanguageCode,
|
|
6737
|
+
s3Endpoint,
|
|
6738
|
+
s3Region,
|
|
6739
|
+
s3Bucket,
|
|
6740
|
+
storageAdapter,
|
|
6741
|
+
s3SignedUrlExpirySeconds,
|
|
6733
6742
|
credentials
|
|
6734
6743
|
}) {
|
|
6735
6744
|
"use step";
|
|
@@ -6743,19 +6752,7 @@ async function downloadDubbedAudioFromElevenLabs({
|
|
|
6743
6752
|
if (!audioResponse.ok) {
|
|
6744
6753
|
throw new Error(`Failed to fetch dubbed audio: ${audioResponse.statusText}`);
|
|
6745
6754
|
}
|
|
6746
|
-
|
|
6747
|
-
}
|
|
6748
|
-
async function uploadDubbedAudioToS3({
|
|
6749
|
-
dubbedAudioBuffer,
|
|
6750
|
-
assetId,
|
|
6751
|
-
toLanguageCode,
|
|
6752
|
-
s3Endpoint,
|
|
6753
|
-
s3Region,
|
|
6754
|
-
s3Bucket,
|
|
6755
|
-
storageAdapter,
|
|
6756
|
-
s3SignedUrlExpirySeconds
|
|
6757
|
-
}) {
|
|
6758
|
-
"use step";
|
|
6755
|
+
const dubbedAudio = new Uint8Array(await audioResponse.arrayBuffer());
|
|
6759
6756
|
const s3AccessKeyId = env_default.S3_ACCESS_KEY_ID;
|
|
6760
6757
|
const s3SecretAccessKey = env_default.S3_SECRET_ACCESS_KEY;
|
|
6761
6758
|
const audioKey = `audio-translations/${assetId}/auto-to-${toLanguageCode}-${Date.now()}.m4a`;
|
|
@@ -6766,7 +6763,7 @@ async function uploadDubbedAudioToS3({
|
|
|
6766
6763
|
region: s3Region,
|
|
6767
6764
|
bucket: s3Bucket,
|
|
6768
6765
|
key: audioKey,
|
|
6769
|
-
body:
|
|
6766
|
+
body: dubbedAudio,
|
|
6770
6767
|
contentType: "audio/mp4"
|
|
6771
6768
|
}, storageAdapter);
|
|
6772
6769
|
const presignedUrl = await createPresignedGetUrlWithStorageAdapter({
|
|
@@ -6871,12 +6868,13 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
6871
6868
|
wrapError(error, "Failed to create ElevenLabs dubbing job");
|
|
6872
6869
|
}
|
|
6873
6870
|
console.warn("\u23F3 Waiting for dubbing to complete...");
|
|
6871
|
+
const dubbingPollTimeoutSeconds = options.dubbingPollTimeoutSeconds ?? DEFAULT_DUBBING_POLL_TIMEOUT_SECONDS;
|
|
6872
|
+
const maxPollAttempts = Math.max(1, Math.ceil(dubbingPollTimeoutSeconds * 1e3 / DUBBING_POLL_INTERVAL_MS));
|
|
6874
6873
|
let dubbingStatus = "dubbing";
|
|
6875
6874
|
let pollAttempts = 0;
|
|
6876
|
-
const maxPollAttempts = 180;
|
|
6877
6875
|
let targetLanguages = [];
|
|
6878
6876
|
while (dubbingStatus !== "dubbed" && pollAttempts < maxPollAttempts) {
|
|
6879
|
-
await sleep2(
|
|
6877
|
+
await sleep2(DUBBING_POLL_INTERVAL_MS);
|
|
6880
6878
|
pollAttempts++;
|
|
6881
6879
|
try {
|
|
6882
6880
|
const statusResult = await checkElevenLabsDubbingStatus({
|
|
@@ -6899,46 +6897,24 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
6899
6897
|
let presignedUrl;
|
|
6900
6898
|
let uploadedTrackId;
|
|
6901
6899
|
if (uploadToS3) {
|
|
6902
|
-
console.warn("\u{1F4E5} Downloading dubbed audio from ElevenLabs...");
|
|
6903
|
-
let dubbedAudioBuffer;
|
|
6900
|
+
console.warn("\u{1F4E5} Downloading dubbed audio from ElevenLabs and staging to S3...");
|
|
6904
6901
|
try {
|
|
6905
|
-
const
|
|
6906
|
-
|
|
6907
|
-
(lang) => lang === requestedLangCode
|
|
6908
|
-
) ?? targetLanguages.find(
|
|
6909
|
-
(lang) => lang.toLowerCase() === requestedLangCode.toLowerCase()
|
|
6910
|
-
);
|
|
6911
|
-
if (!downloadLangCode && targetLanguages.length > 0) {
|
|
6912
|
-
downloadLangCode = targetLanguages[0];
|
|
6913
|
-
console.warn(`\u26A0\uFE0F Requested language "${requestedLangCode}" not found in target_languages. Using "${downloadLangCode}" instead.`);
|
|
6914
|
-
}
|
|
6915
|
-
if (!downloadLangCode) {
|
|
6916
|
-
downloadLangCode = requestedLangCode;
|
|
6917
|
-
console.warn(`\u26A0\uFE0F No target_languages available from ElevenLabs status. Using requested language code: ${requestedLangCode}`);
|
|
6918
|
-
}
|
|
6919
|
-
dubbedAudioBuffer = await downloadDubbedAudioFromElevenLabs({
|
|
6902
|
+
const downloadLangCode = targetLanguages[0] ?? toISO639_1(toLanguageCode);
|
|
6903
|
+
presignedUrl = await downloadAndUploadDubbedAudio({
|
|
6920
6904
|
dubbingId,
|
|
6921
6905
|
languageCode: downloadLangCode,
|
|
6922
|
-
credentials
|
|
6923
|
-
});
|
|
6924
|
-
console.warn("\u2705 Dubbed audio downloaded successfully!");
|
|
6925
|
-
} catch (error) {
|
|
6926
|
-
wrapError(error, "Failed to download dubbed audio");
|
|
6927
|
-
}
|
|
6928
|
-
console.warn("\u{1F4E4} Uploading dubbed audio to S3-compatible storage...");
|
|
6929
|
-
try {
|
|
6930
|
-
presignedUrl = await uploadDubbedAudioToS3({
|
|
6931
|
-
dubbedAudioBuffer,
|
|
6932
6906
|
assetId,
|
|
6933
6907
|
toLanguageCode,
|
|
6934
6908
|
s3Endpoint,
|
|
6935
6909
|
s3Region,
|
|
6936
6910
|
s3Bucket,
|
|
6937
6911
|
storageAdapter: effectiveStorageAdapter,
|
|
6938
|
-
s3SignedUrlExpirySeconds: options.s3SignedUrlExpirySeconds
|
|
6912
|
+
s3SignedUrlExpirySeconds: options.s3SignedUrlExpirySeconds,
|
|
6913
|
+
credentials
|
|
6939
6914
|
});
|
|
6915
|
+
console.warn("\u2705 Dubbed audio staged to S3 successfully!");
|
|
6940
6916
|
} catch (error) {
|
|
6941
|
-
wrapError(error, "Failed to upload audio
|
|
6917
|
+
wrapError(error, "Failed to download and upload dubbed audio");
|
|
6942
6918
|
}
|
|
6943
6919
|
if (uploadToMux) {
|
|
6944
6920
|
console.warn("\u{1F4F9} Adding dubbed audio track to Mux asset...");
|