@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
|
@@ -1838,6 +1838,23 @@ declare function getSummaryAndTags(assetId: string, options?: SummarizationOptio
|
|
|
1838
1838
|
|
|
1839
1839
|
/** What happened to the audio-only static rendition `translateAudio` created as dubbing input. */
|
|
1840
1840
|
type StaticRenditionCleanupOutcome = "deleted" | "delete_failed" | "kept" | "not_created";
|
|
1841
|
+
/** Transcript staging and optional subtitle attachment are independent of a successful dub. */
|
|
1842
|
+
type DubbedCaptionsOutcome = {
|
|
1843
|
+
status: "available";
|
|
1844
|
+
} | {
|
|
1845
|
+
status: "unavailable";
|
|
1846
|
+
message: string;
|
|
1847
|
+
retryable: boolean;
|
|
1848
|
+
} | {
|
|
1849
|
+
status: "created";
|
|
1850
|
+
trackId: string;
|
|
1851
|
+
replacedTracks: TextTrackSummary[];
|
|
1852
|
+
} | {
|
|
1853
|
+
status: "failed";
|
|
1854
|
+
message: string;
|
|
1855
|
+
retryable: boolean;
|
|
1856
|
+
replacedTracks: TextTrackSummary[];
|
|
1857
|
+
};
|
|
1841
1858
|
/** Output returned from `translateAudio`. */
|
|
1842
1859
|
interface AudioTranslationResult {
|
|
1843
1860
|
assetId: string;
|
|
@@ -1861,6 +1878,8 @@ interface AudioTranslationResult {
|
|
|
1861
1878
|
captionsTrackId?: string;
|
|
1862
1879
|
/** Presigned URL for the dub's translated transcript (WebVTT) staged to S3. */
|
|
1863
1880
|
captionsPresignedUrl?: string;
|
|
1881
|
+
/** Recorded when transcript staging was attempted, including non-fatal failures. */
|
|
1882
|
+
captionsOutcome?: DubbedCaptionsOutcome;
|
|
1864
1883
|
/** ID of the audio-only static rendition this run created, `undefined` when a usable rendition already existed. */
|
|
1865
1884
|
createdStaticRenditionId?: string;
|
|
1866
1885
|
/** Outcome of cleaning up the static rendition this run created (`not_created` when it reused an existing one). */
|
|
@@ -1905,19 +1924,27 @@ interface AudioTranslationOptions extends MuxAIOptions {
|
|
|
1905
1924
|
* When true the dub's translated transcript (the same translation that was
|
|
1906
1925
|
* voiced) is attached as a subtitles text track on the Mux asset. Implies
|
|
1907
1926
|
* `uploadToS3: true`. Defaults to false. Existing text tracks are handled
|
|
1908
|
-
* according to `
|
|
1927
|
+
* according to `captionsReplaceExistingTracks` (falling back to
|
|
1928
|
+
* `replaceExistingTracks`). Caption conflicts are reported in `captionsOutcome`
|
|
1929
|
+
* without failing the dub.
|
|
1909
1930
|
*/
|
|
1910
1931
|
uploadCaptionsToMux?: boolean;
|
|
1932
|
+
/** Subtitle name override. Defaults to `trackName`, then the generated audio track name. */
|
|
1933
|
+
captionsTrackName?: string;
|
|
1934
|
+
/** Subtitle conflict policy override. Defaults to `replaceExistingTracks`. */
|
|
1935
|
+
captionsReplaceExistingTracks?: ReplaceExistingTracksPolicy;
|
|
1911
1936
|
/**
|
|
1912
|
-
* What to do when the asset already has an audio track
|
|
1913
|
-
*
|
|
1914
|
-
*
|
|
1937
|
+
* What to do when the asset already has an audio track in the target language
|
|
1938
|
+
* or with the target name. Defaults to `"fail"`, which rejects before dubbing
|
|
1939
|
+
* starts. Also the subtitle policy unless `captionsReplaceExistingTracks` is set;
|
|
1940
|
+
* subtitle conflicts only fail caption attachment.
|
|
1915
1941
|
* The asset's primary audio track is never deleted under any policy.
|
|
1916
1942
|
*/
|
|
1917
1943
|
replaceExistingTracks?: ReplaceExistingTracksPolicy;
|
|
1918
1944
|
/**
|
|
1919
1945
|
* Name for the created Mux tracks. Audio and text tracks are separate name
|
|
1920
|
-
* groups, so the same name is used
|
|
1946
|
+
* groups, so the same name is used unless `captionsTrackName` overrides
|
|
1947
|
+
* the subtitle name. Defaults to
|
|
1921
1948
|
* "<Language> (Auto-dubbed)", e.g. "Spanish (Auto-dubbed)".
|
|
1922
1949
|
*/
|
|
1923
1950
|
trackName?: string;
|
|
@@ -2156,6 +2183,7 @@ declare const index_DEFAULT_DESCRIPTION_LENGTH: typeof DEFAULT_DESCRIPTION_LENGT
|
|
|
2156
2183
|
declare const index_DEFAULT_SUMMARY_KEYWORD_LIMIT: typeof DEFAULT_SUMMARY_KEYWORD_LIMIT;
|
|
2157
2184
|
declare const index_DEFAULT_TITLE_LENGTH: typeof DEFAULT_TITLE_LENGTH;
|
|
2158
2185
|
declare const index_DEFAULT_TRANSCRIPT_WINDOWING: typeof DEFAULT_TRANSCRIPT_WINDOWING;
|
|
2186
|
+
type index_DubbedCaptionsOutcome = DubbedCaptionsOutcome;
|
|
2159
2187
|
type index_EditCaptionsOptions<P extends SupportedProvider = SupportedProvider> = EditCaptionsOptions<P>;
|
|
2160
2188
|
type index_EditCaptionsResult = EditCaptionsResult;
|
|
2161
2189
|
type index_EmbeddingsOptions = EmbeddingsOptions;
|
|
@@ -2277,7 +2305,7 @@ declare const index_translationSchema: typeof translationSchema;
|
|
|
2277
2305
|
declare const index_validateNeverTranslateTerms: typeof validateNeverTranslateTerms;
|
|
2278
2306
|
declare const index_verifyNeverTranslateTerms: typeof verifyNeverTranslateTerms;
|
|
2279
2307
|
declare namespace index {
|
|
2280
|
-
export { index_ASK_QUESTIONS_DEFAULT_MAX_ANSWER_OPTION_LENGTH as ASK_QUESTIONS_DEFAULT_MAX_ANSWER_OPTION_LENGTH, index_ASK_QUESTIONS_DEFAULT_MAX_FREE_FORM_ANSWER_LENGTH as ASK_QUESTIONS_DEFAULT_MAX_FREE_FORM_ANSWER_LENGTH, index_ASK_QUESTIONS_MAX_QUESTIONS_PER_CALL as ASK_QUESTIONS_MAX_QUESTIONS_PER_CALL, index_ASK_QUESTIONS_MAX_QUESTION_LENGTH as ASK_QUESTIONS_MAX_QUESTION_LENGTH, type index_AskQuestionsOptions as AskQuestionsOptions, type index_AskQuestionsResult as AskQuestionsResult, type index_AskQuestionsType as AskQuestionsType, type index_AudioTranslationOptions as AudioTranslationOptions, type index_AudioTranslationResult as AudioTranslationResult, type index_AutoCensorProfanityOptions as AutoCensorProfanityOptions, type index_BurnedInCaptionsAnalysis as BurnedInCaptionsAnalysis, type index_BurnedInCaptionsOptions as BurnedInCaptionsOptions, type index_BurnedInCaptionsPromptOverrides as BurnedInCaptionsPromptOverrides, type index_BurnedInCaptionsPromptSections as BurnedInCaptionsPromptSections, type index_BurnedInCaptionsResult as BurnedInCaptionsResult, type index_CaptionReplacement as CaptionReplacement, type index_CensorMode as CensorMode, type index_Chapter as Chapter, type index_ChapterSystemPromptSections as ChapterSystemPromptSections, type index_ChaptersOptions as ChaptersOptions, type index_ChaptersPromptOverrides as ChaptersPromptOverrides, type index_ChaptersPromptSections as ChaptersPromptSections, type index_ChaptersResult as ChaptersResult, type index_ChaptersType as ChaptersType, index_DEFAULT_DESCRIPTION_LENGTH as DEFAULT_DESCRIPTION_LENGTH, index_DEFAULT_SUMMARY_KEYWORD_LIMIT as DEFAULT_SUMMARY_KEYWORD_LIMIT, index_DEFAULT_TITLE_LENGTH as DEFAULT_TITLE_LENGTH, index_DEFAULT_TRANSCRIPT_WINDOWING as DEFAULT_TRANSCRIPT_WINDOWING, type index_EditCaptionsOptions as EditCaptionsOptions, type index_EditCaptionsResult as EditCaptionsResult, type index_EmbeddingsOptions as EmbeddingsOptions, type index_EmbeddingsResult as EmbeddingsResult, type index_EngagementInsightsOptions as EngagementInsightsOptions, type index_EngagementInsightsResult as EngagementInsightsResult, index_GENERATE_TEXT_CALLS_TO_ACTION as GENERATE_TEXT_CALLS_TO_ACTION, index_GENERATE_TEXT_CHANNELS as GENERATE_TEXT_CHANNELS, index_GENERATE_TEXT_CHANNEL_CEILINGS as GENERATE_TEXT_CHANNEL_CEILINGS, index_GENERATE_TEXT_FORMATS as GENERATE_TEXT_FORMATS, index_GENERATE_TEXT_LENGTH_BOUNDS as GENERATE_TEXT_LENGTH_BOUNDS, index_GENERATE_TEXT_MAX_ARTIFACTS as GENERATE_TEXT_MAX_ARTIFACTS, index_GENERATE_TEXT_MAX_AUDIENCE_CHARS as GENERATE_TEXT_MAX_AUDIENCE_CHARS, index_GENERATE_TEXT_MAX_BRAND_TERMS as GENERATE_TEXT_MAX_BRAND_TERMS, index_GENERATE_TEXT_MAX_BRAND_TERMS_TOTAL_CHARS as GENERATE_TEXT_MAX_BRAND_TERMS_TOTAL_CHARS, index_GENERATE_TEXT_MAX_BRAND_TERM_CHARS as GENERATE_TEXT_MAX_BRAND_TERM_CHARS, index_GENERATE_TEXT_MAX_CONCURRENT_GENERATIONS as GENERATE_TEXT_MAX_CONCURRENT_GENERATIONS, index_GENERATE_TEXT_MAX_INSTRUCTIONS_CHARS as GENERATE_TEXT_MAX_INSTRUCTIONS_CHARS, index_GENERATE_TEXT_MAX_SHOT_FRAMES as GENERATE_TEXT_MAX_SHOT_FRAMES, index_GENERATE_TEXT_MAX_VARIANTS as GENERATE_TEXT_MAX_VARIANTS, index_GENERATE_TEXT_VOICES as GENERATE_TEXT_VOICES, index_GOOGLE_VISION_LIKELIHOOD_TO_SCORE as GOOGLE_VISION_LIKELIHOOD_TO_SCORE, type index_GenerateTextArtifact as GenerateTextArtifact, type index_GenerateTextCallToAction as GenerateTextCallToAction, type index_GenerateTextChannel as GenerateTextChannel, type index_GenerateTextFormat as GenerateTextFormat, type index_GenerateTextKeyedItem as GenerateTextKeyedItem, type index_GenerateTextLengthLimit as GenerateTextLengthLimit, type index_GenerateTextOptions as GenerateTextOptions, type index_GenerateTextResult as GenerateTextResult, type index_GenerateTextVariant as GenerateTextVariant, type index_GenerateTextVoice as GenerateTextVoice, type index_GeneratedTextArtifact as GeneratedTextArtifact, type index_GeneratedTextVariant as GeneratedTextVariant, index_HIVE_SEXUAL_CATEGORIES as HIVE_SEXUAL_CATEGORIES, index_HIVE_VIOLENCE_CATEGORIES as HIVE_VIOLENCE_CATEGORIES, type index_HiveModerationOutput as HiveModerationOutput, type index_HiveModerationSource as HiveModerationSource, type index_ModerationOptions as ModerationOptions, type index_ModerationProvider as ModerationProvider, type index_ModerationResult as ModerationResult, type index_ModerationSurfaceStatus as ModerationSurfaceStatus, type index_MomentInsight as MomentInsight, type index_OverallInsight as OverallInsight, type index_ProfanityDetectionPayload as ProfanityDetectionPayload, type index_Question as Question, type index_QuestionAnswer as QuestionAnswer, type index_QuestionAnswerType as QuestionAnswerType, type index_RepairAttempt as RepairAttempt, type index_RepairCall as RepairCall, type index_RepairOptions as RepairOptions, type index_RepairPlan as RepairPlan, type index_RepairResult as RepairResult, type index_RepairSpan as RepairSpan, type index_ReplacementRecord as ReplacementRecord, type index_SpeakerReplacement as SpeakerReplacement, type index_StaticRenditionCleanupOutcome as StaticRenditionCleanupOutcome, type index_SummarizationOptions as SummarizationOptions, type index_SummarizationPromptOverrides as SummarizationPromptOverrides, type index_SummarizationPromptSections as SummarizationPromptSections, type index_SummaryAndTagsResult as SummaryAndTagsResult, type index_SummaryType as SummaryType, type index_TextLengthLimit as TextLengthLimit, type index_TextRepairModelOptions as TextRepairModelOptions, type index_ThumbnailModerationScore as ThumbnailModerationScore, type index_ThumbnailModerationSkipReason as ThumbnailModerationSkipReason, type index_ThumbnailModerationStatus as ThumbnailModerationStatus, type index_TranscriptModerationScore as TranscriptModerationScore, type index_TranscriptModerationSkipReason as TranscriptModerationSkipReason, type index_TranscriptModerationStatus as TranscriptModerationStatus, type index_TranslationChunkingOptions as TranslationChunkingOptions, type index_TranslationOptions as TranslationOptions, type index_TranslationPayload as TranslationPayload, type index_TranslationResult as TranslationResult, index_aggregateTokenUsage as aggregateTokenUsage, index_applyOverrideLists as applyOverrideLists, index_applyReplacements as applyReplacements, index_applySpeakerReplacements as applySpeakerReplacements, index_applyTextRepair as applyTextRepair, index_askQuestions as askQuestions, index_buildReplacementRegex as buildReplacementRegex, index_buildTranscriptWindows as buildTranscriptWindows, index_burnedInCaptionsSchema as burnedInCaptionsSchema, index_censorVttContent as censorVttContent, index_chapterSchema as chapterSchema, index_chaptersSchema as chaptersSchema, index_createReplacer as createReplacer, index_createTextRepairGenerator as createTextRepairGenerator, index_editCaptions as editCaptions, index_extractTranscriptSegmentsForHotspots as extractTranscriptSegmentsForHotspots, index_findGenerateTextLengthViolation as findGenerateTextLengthViolation, index_generateChapters as generateChapters, index_generateEmbeddings as generateEmbeddings, index_generateEngagementInsights as generateEngagementInsights, index_generateText as generateText, index_generateVideoEmbeddings as generateVideoEmbeddings, index_getModerationScores as getModerationScores, index_getSummaryAndTags as getSummaryAndTags, index_hasBurnedInCaptions as hasBurnedInCaptions, index_mapShotsToHotspots as mapShotsToHotspots, index_measureGenerateTextLength as measureGenerateTextLength, index_normalizeTranslatedVtt as normalizeTranslatedVtt, index_planTextRepair as planTextRepair, index_profanityDetectionSchema as profanityDetectionSchema, index_questionAnswerSchema as questionAnswerSchema, index_repairJsonSchema as repairJsonSchema, index_repairText as repairText, index_resolveGenerateTextLengthLimit as resolveGenerateTextLengthLimit, index_resolveGenerateTextLengthLimits as resolveGenerateTextLengthLimits, index_resolveGenerateTextOptions as resolveGenerateTextOptions, index_runTextRepairLoop as runTextRepairLoop, index_selectGenerateTextShotFrames as selectGenerateTextShotFrames, index_shouldSplitChunkTranslationError as shouldSplitChunkTranslationError, index_summarySchema as summarySchema, index_transformCueText as transformCueText, index_translateAudio as translateAudio, index_translateCaptions as translateCaptions, index_translationSchema as translationSchema, index_validateNeverTranslateTerms as validateNeverTranslateTerms, index_verifyNeverTranslateTerms as verifyNeverTranslateTerms };
|
|
2308
|
+
export { index_ASK_QUESTIONS_DEFAULT_MAX_ANSWER_OPTION_LENGTH as ASK_QUESTIONS_DEFAULT_MAX_ANSWER_OPTION_LENGTH, index_ASK_QUESTIONS_DEFAULT_MAX_FREE_FORM_ANSWER_LENGTH as ASK_QUESTIONS_DEFAULT_MAX_FREE_FORM_ANSWER_LENGTH, index_ASK_QUESTIONS_MAX_QUESTIONS_PER_CALL as ASK_QUESTIONS_MAX_QUESTIONS_PER_CALL, index_ASK_QUESTIONS_MAX_QUESTION_LENGTH as ASK_QUESTIONS_MAX_QUESTION_LENGTH, type index_AskQuestionsOptions as AskQuestionsOptions, type index_AskQuestionsResult as AskQuestionsResult, type index_AskQuestionsType as AskQuestionsType, type index_AudioTranslationOptions as AudioTranslationOptions, type index_AudioTranslationResult as AudioTranslationResult, type index_AutoCensorProfanityOptions as AutoCensorProfanityOptions, type index_BurnedInCaptionsAnalysis as BurnedInCaptionsAnalysis, type index_BurnedInCaptionsOptions as BurnedInCaptionsOptions, type index_BurnedInCaptionsPromptOverrides as BurnedInCaptionsPromptOverrides, type index_BurnedInCaptionsPromptSections as BurnedInCaptionsPromptSections, type index_BurnedInCaptionsResult as BurnedInCaptionsResult, type index_CaptionReplacement as CaptionReplacement, type index_CensorMode as CensorMode, type index_Chapter as Chapter, type index_ChapterSystemPromptSections as ChapterSystemPromptSections, type index_ChaptersOptions as ChaptersOptions, type index_ChaptersPromptOverrides as ChaptersPromptOverrides, type index_ChaptersPromptSections as ChaptersPromptSections, type index_ChaptersResult as ChaptersResult, type index_ChaptersType as ChaptersType, index_DEFAULT_DESCRIPTION_LENGTH as DEFAULT_DESCRIPTION_LENGTH, index_DEFAULT_SUMMARY_KEYWORD_LIMIT as DEFAULT_SUMMARY_KEYWORD_LIMIT, index_DEFAULT_TITLE_LENGTH as DEFAULT_TITLE_LENGTH, index_DEFAULT_TRANSCRIPT_WINDOWING as DEFAULT_TRANSCRIPT_WINDOWING, type index_DubbedCaptionsOutcome as DubbedCaptionsOutcome, type index_EditCaptionsOptions as EditCaptionsOptions, type index_EditCaptionsResult as EditCaptionsResult, type index_EmbeddingsOptions as EmbeddingsOptions, type index_EmbeddingsResult as EmbeddingsResult, type index_EngagementInsightsOptions as EngagementInsightsOptions, type index_EngagementInsightsResult as EngagementInsightsResult, index_GENERATE_TEXT_CALLS_TO_ACTION as GENERATE_TEXT_CALLS_TO_ACTION, index_GENERATE_TEXT_CHANNELS as GENERATE_TEXT_CHANNELS, index_GENERATE_TEXT_CHANNEL_CEILINGS as GENERATE_TEXT_CHANNEL_CEILINGS, index_GENERATE_TEXT_FORMATS as GENERATE_TEXT_FORMATS, index_GENERATE_TEXT_LENGTH_BOUNDS as GENERATE_TEXT_LENGTH_BOUNDS, index_GENERATE_TEXT_MAX_ARTIFACTS as GENERATE_TEXT_MAX_ARTIFACTS, index_GENERATE_TEXT_MAX_AUDIENCE_CHARS as GENERATE_TEXT_MAX_AUDIENCE_CHARS, index_GENERATE_TEXT_MAX_BRAND_TERMS as GENERATE_TEXT_MAX_BRAND_TERMS, index_GENERATE_TEXT_MAX_BRAND_TERMS_TOTAL_CHARS as GENERATE_TEXT_MAX_BRAND_TERMS_TOTAL_CHARS, index_GENERATE_TEXT_MAX_BRAND_TERM_CHARS as GENERATE_TEXT_MAX_BRAND_TERM_CHARS, index_GENERATE_TEXT_MAX_CONCURRENT_GENERATIONS as GENERATE_TEXT_MAX_CONCURRENT_GENERATIONS, index_GENERATE_TEXT_MAX_INSTRUCTIONS_CHARS as GENERATE_TEXT_MAX_INSTRUCTIONS_CHARS, index_GENERATE_TEXT_MAX_SHOT_FRAMES as GENERATE_TEXT_MAX_SHOT_FRAMES, index_GENERATE_TEXT_MAX_VARIANTS as GENERATE_TEXT_MAX_VARIANTS, index_GENERATE_TEXT_VOICES as GENERATE_TEXT_VOICES, index_GOOGLE_VISION_LIKELIHOOD_TO_SCORE as GOOGLE_VISION_LIKELIHOOD_TO_SCORE, type index_GenerateTextArtifact as GenerateTextArtifact, type index_GenerateTextCallToAction as GenerateTextCallToAction, type index_GenerateTextChannel as GenerateTextChannel, type index_GenerateTextFormat as GenerateTextFormat, type index_GenerateTextKeyedItem as GenerateTextKeyedItem, type index_GenerateTextLengthLimit as GenerateTextLengthLimit, type index_GenerateTextOptions as GenerateTextOptions, type index_GenerateTextResult as GenerateTextResult, type index_GenerateTextVariant as GenerateTextVariant, type index_GenerateTextVoice as GenerateTextVoice, type index_GeneratedTextArtifact as GeneratedTextArtifact, type index_GeneratedTextVariant as GeneratedTextVariant, index_HIVE_SEXUAL_CATEGORIES as HIVE_SEXUAL_CATEGORIES, index_HIVE_VIOLENCE_CATEGORIES as HIVE_VIOLENCE_CATEGORIES, type index_HiveModerationOutput as HiveModerationOutput, type index_HiveModerationSource as HiveModerationSource, type index_ModerationOptions as ModerationOptions, type index_ModerationProvider as ModerationProvider, type index_ModerationResult as ModerationResult, type index_ModerationSurfaceStatus as ModerationSurfaceStatus, type index_MomentInsight as MomentInsight, type index_OverallInsight as OverallInsight, type index_ProfanityDetectionPayload as ProfanityDetectionPayload, type index_Question as Question, type index_QuestionAnswer as QuestionAnswer, type index_QuestionAnswerType as QuestionAnswerType, type index_RepairAttempt as RepairAttempt, type index_RepairCall as RepairCall, type index_RepairOptions as RepairOptions, type index_RepairPlan as RepairPlan, type index_RepairResult as RepairResult, type index_RepairSpan as RepairSpan, type index_ReplacementRecord as ReplacementRecord, type index_SpeakerReplacement as SpeakerReplacement, type index_StaticRenditionCleanupOutcome as StaticRenditionCleanupOutcome, type index_SummarizationOptions as SummarizationOptions, type index_SummarizationPromptOverrides as SummarizationPromptOverrides, type index_SummarizationPromptSections as SummarizationPromptSections, type index_SummaryAndTagsResult as SummaryAndTagsResult, type index_SummaryType as SummaryType, type index_TextLengthLimit as TextLengthLimit, type index_TextRepairModelOptions as TextRepairModelOptions, type index_ThumbnailModerationScore as ThumbnailModerationScore, type index_ThumbnailModerationSkipReason as ThumbnailModerationSkipReason, type index_ThumbnailModerationStatus as ThumbnailModerationStatus, type index_TranscriptModerationScore as TranscriptModerationScore, type index_TranscriptModerationSkipReason as TranscriptModerationSkipReason, type index_TranscriptModerationStatus as TranscriptModerationStatus, type index_TranslationChunkingOptions as TranslationChunkingOptions, type index_TranslationOptions as TranslationOptions, type index_TranslationPayload as TranslationPayload, type index_TranslationResult as TranslationResult, index_aggregateTokenUsage as aggregateTokenUsage, index_applyOverrideLists as applyOverrideLists, index_applyReplacements as applyReplacements, index_applySpeakerReplacements as applySpeakerReplacements, index_applyTextRepair as applyTextRepair, index_askQuestions as askQuestions, index_buildReplacementRegex as buildReplacementRegex, index_buildTranscriptWindows as buildTranscriptWindows, index_burnedInCaptionsSchema as burnedInCaptionsSchema, index_censorVttContent as censorVttContent, index_chapterSchema as chapterSchema, index_chaptersSchema as chaptersSchema, index_createReplacer as createReplacer, index_createTextRepairGenerator as createTextRepairGenerator, index_editCaptions as editCaptions, index_extractTranscriptSegmentsForHotspots as extractTranscriptSegmentsForHotspots, index_findGenerateTextLengthViolation as findGenerateTextLengthViolation, index_generateChapters as generateChapters, index_generateEmbeddings as generateEmbeddings, index_generateEngagementInsights as generateEngagementInsights, index_generateText as generateText, index_generateVideoEmbeddings as generateVideoEmbeddings, index_getModerationScores as getModerationScores, index_getSummaryAndTags as getSummaryAndTags, index_hasBurnedInCaptions as hasBurnedInCaptions, index_mapShotsToHotspots as mapShotsToHotspots, index_measureGenerateTextLength as measureGenerateTextLength, index_normalizeTranslatedVtt as normalizeTranslatedVtt, index_planTextRepair as planTextRepair, index_profanityDetectionSchema as profanityDetectionSchema, index_questionAnswerSchema as questionAnswerSchema, index_repairJsonSchema as repairJsonSchema, index_repairText as repairText, index_resolveGenerateTextLengthLimit as resolveGenerateTextLengthLimit, index_resolveGenerateTextLengthLimits as resolveGenerateTextLengthLimits, index_resolveGenerateTextOptions as resolveGenerateTextOptions, index_runTextRepairLoop as runTextRepairLoop, index_selectGenerateTextShotFrames as selectGenerateTextShotFrames, index_shouldSplitChunkTranslationError as shouldSplitChunkTranslationError, index_summarySchema as summarySchema, index_transformCueText as transformCueText, index_translateAudio as translateAudio, index_translateCaptions as translateCaptions, index_translationSchema as translationSchema, index_validateNeverTranslateTerms as validateNeverTranslateTerms, index_verifyNeverTranslateTerms as verifyNeverTranslateTerms };
|
|
2281
2309
|
}
|
|
2282
2310
|
|
|
2283
|
-
export { type BurnedInCaptionsPromptSections as $, replaceAndCreateTextTrack as A, replaceAndCreateTrack as B, replaceSourceTrack as C, summarizeTextTrack as D, toISO639_1 as E, toISO639_3 as F, validateTrackPassthrough as G, index as H, type ISO639_1 as I, ASK_QUESTIONS_DEFAULT_MAX_ANSWER_OPTION_LENGTH as J, ASK_QUESTIONS_DEFAULT_MAX_FREE_FORM_ANSWER_LENGTH as K, type LanguageCodePair as L, MUX_TRACK_PASSTHROUGH_MAX_CHARS as M, ASK_QUESTIONS_MAX_QUESTIONS_PER_CALL as N, ASK_QUESTIONS_MAX_QUESTION_LENGTH as O, type AskQuestionsOptions as P, type AskQuestionsResult as Q, type ReplaceAndCreateTextTrackInput as R, type SourceTrackReplacementPolicy as S, type TextTrackReplacementPlan as T, type AskQuestionsType as U, type AudioTranslationOptions as V, type AudioTranslationResult as W, type AutoCensorProfanityOptions as X, type BurnedInCaptionsAnalysis as Y, type BurnedInCaptionsOptions as Z, type BurnedInCaptionsPromptOverrides as _, type ISO639_3 as a, type
|
|
2311
|
+
export { type BurnedInCaptionsPromptSections as $, replaceAndCreateTextTrack as A, replaceAndCreateTrack as B, replaceSourceTrack as C, summarizeTextTrack as D, toISO639_1 as E, toISO639_3 as F, validateTrackPassthrough as G, index as H, type ISO639_1 as I, ASK_QUESTIONS_DEFAULT_MAX_ANSWER_OPTION_LENGTH as J, ASK_QUESTIONS_DEFAULT_MAX_FREE_FORM_ANSWER_LENGTH as K, type LanguageCodePair as L, MUX_TRACK_PASSTHROUGH_MAX_CHARS as M, ASK_QUESTIONS_MAX_QUESTIONS_PER_CALL as N, ASK_QUESTIONS_MAX_QUESTION_LENGTH as O, type AskQuestionsOptions as P, type AskQuestionsResult as Q, type ReplaceAndCreateTextTrackInput as R, type SourceTrackReplacementPolicy as S, type TextTrackReplacementPlan as T, type AskQuestionsType as U, type AudioTranslationOptions as V, type AudioTranslationResult as W, type AutoCensorProfanityOptions as X, type BurnedInCaptionsAnalysis as Y, type BurnedInCaptionsOptions as Z, type BurnedInCaptionsPromptOverrides as _, type ISO639_3 as a, type RepairPlan as a$, type BurnedInCaptionsResult as a0, type CaptionReplacement as a1, type CensorMode as a2, type Chapter as a3, type ChapterSystemPromptSections as a4, type ChaptersOptions as a5, type ChaptersPromptOverrides as a6, type ChaptersPromptSections as a7, type ChaptersResult as a8, type ChaptersType as a9, type GenerateTextChannel as aA, type GenerateTextFormat as aB, type GenerateTextKeyedItem as aC, type GenerateTextLengthLimit as aD, type GenerateTextOptions as aE, type GenerateTextResult as aF, type GenerateTextVariant as aG, type GenerateTextVoice as aH, type GeneratedTextArtifact as aI, type GeneratedTextVariant as aJ, HIVE_SEXUAL_CATEGORIES as aK, HIVE_VIOLENCE_CATEGORIES as aL, type HiveModerationOutput as aM, type HiveModerationSource as aN, type ModerationOptions as aO, type ModerationProvider as aP, type ModerationResult as aQ, type ModerationSurfaceStatus as aR, type MomentInsight as aS, type OverallInsight as aT, type ProfanityDetectionPayload as aU, type Question as aV, type QuestionAnswer as aW, type QuestionAnswerType as aX, type RepairAttempt as aY, type RepairCall as aZ, type RepairOptions as a_, DEFAULT_TRANSCRIPT_WINDOWING as aa, type DubbedCaptionsOutcome as ab, type EditCaptionsOptions as ac, type EditCaptionsResult as ad, type EmbeddingsOptions as ae, type EmbeddingsResult as af, type EngagementInsightsOptions as ag, type EngagementInsightsResult as ah, GENERATE_TEXT_CALLS_TO_ACTION as ai, GENERATE_TEXT_CHANNELS as aj, GENERATE_TEXT_CHANNEL_CEILINGS as ak, GENERATE_TEXT_FORMATS as al, GENERATE_TEXT_LENGTH_BOUNDS as am, GENERATE_TEXT_MAX_ARTIFACTS as an, GENERATE_TEXT_MAX_AUDIENCE_CHARS as ao, GENERATE_TEXT_MAX_BRAND_TERMS as ap, GENERATE_TEXT_MAX_BRAND_TERMS_TOTAL_CHARS as aq, GENERATE_TEXT_MAX_BRAND_TERM_CHARS as ar, GENERATE_TEXT_MAX_CONCURRENT_GENERATIONS as as, GENERATE_TEXT_MAX_INSTRUCTIONS_CHARS as at, GENERATE_TEXT_MAX_SHOT_FRAMES as au, GENERATE_TEXT_MAX_VARIANTS as av, GENERATE_TEXT_VOICES as aw, GOOGLE_VISION_LIKELIHOOD_TO_SCORE as ax, type GenerateTextArtifact as ay, type GenerateTextCallToAction as az, type ReplaceAndCreateTextTrackResult as b, translateAudio as b$, type RepairResult as b0, type RepairSpan as b1, type ReplacementRecord as b2, type SpeakerReplacement as b3, type StaticRenditionCleanupOutcome as b4, type SummarizationOptions as b5, type SummarizationPromptOverrides as b6, type SummarizationPromptSections as b7, type SummaryAndTagsResult as b8, type SummaryType as b9, editCaptions as bA, extractTranscriptSegmentsForHotspots as bB, findGenerateTextLengthViolation as bC, generateChapters as bD, generateEmbeddings as bE, generateEngagementInsights as bF, generateText as bG, generateVideoEmbeddings as bH, getModerationScores as bI, getSummaryAndTags as bJ, hasBurnedInCaptions as bK, mapShotsToHotspots as bL, measureGenerateTextLength as bM, normalizeTranslatedVtt as bN, planTextRepair as bO, profanityDetectionSchema as bP, questionAnswerSchema as bQ, repairJsonSchema as bR, repairText as bS, resolveGenerateTextLengthLimit as bT, resolveGenerateTextLengthLimits as bU, resolveGenerateTextOptions as bV, runTextRepairLoop as bW, selectGenerateTextShotFrames as bX, shouldSplitChunkTranslationError as bY, summarySchema as bZ, transformCueText as b_, type TextLengthLimit as ba, type TextRepairModelOptions as bb, type ThumbnailModerationScore as bc, type ThumbnailModerationSkipReason as bd, type ThumbnailModerationStatus as be, type TranscriptModerationScore as bf, type TranscriptModerationSkipReason as bg, type TranscriptModerationStatus as bh, type TranslationChunkingOptions as bi, type TranslationOptions as bj, type TranslationPayload as bk, type TranslationResult as bl, aggregateTokenUsage as bm, applyOverrideLists as bn, applyReplacements as bo, applySpeakerReplacements as bp, applyTextRepair as bq, askQuestions as br, buildReplacementRegex as bs, buildTranscriptWindows as bt, burnedInCaptionsSchema as bu, censorVttContent as bv, chapterSchema as bw, chaptersSchema as bx, createReplacer as by, createTextRepairGenerator as bz, type ReplaceAndCreateTrackInput as c, translateCaptions as c0, translationSchema as c1, validateNeverTranslateTerms as c2, verifyNeverTranslateTerms as c3, type ReplaceExistingTracksPolicy as d, type ReplaceSourceTrackInput as e, type ReplaceableTrackType as f, type SupportedISO639_1 as g, type SupportedISO639_3 as h, type TextTrackSummary as i, type TextTrackTarget as j, type TrackSummary as k, type TrackTarget as l, buildMuxAiTrackPassthrough as m, findNameCollisionTextTracks as n, findSameLanguageTextTracks as o, getLanguageCodePair as p, getLanguageName as q, isDuplicateTrackNameError as r, isMuxGeneratedTextTrack as s, isUndeterminedLanguageCode as t, isValidISO639_1 as u, isValidISO639_3 as v, normalizeTrackLanguageCode as w, normalizeTrackName as x, planSourceTrackReplacement as y, planTextTrackReplacement as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { I as ISO639_1, a as ISO639_3, L as LanguageCodePair, M as MUX_TRACK_PASSTHROUGH_MAX_CHARS, R as ReplaceAndCreateTextTrackInput, b as ReplaceAndCreateTextTrackResult, c as ReplaceAndCreateTrackInput, d as ReplaceExistingTracksPolicy, e as ReplaceSourceTrackInput, f as ReplaceableTrackType, S as SourceTrackReplacementPolicy, g as SupportedISO639_1, h as SupportedISO639_3, T as TextTrackReplacementPlan, i as TextTrackSummary, j as TextTrackTarget, k as TrackSummary, l as TrackTarget, m as buildMuxAiTrackPassthrough, n as findNameCollisionTextTracks, o as findSameLanguageTextTracks, p as getLanguageCodePair, q as getLanguageName, r as isDuplicateTrackNameError, s as isMuxGeneratedTextTrack, t as isUndeterminedLanguageCode, u as isValidISO639_1, v as isValidISO639_3, w as normalizeTrackLanguageCode, x as normalizeTrackName, y as planSourceTrackReplacement, z as planTextTrackReplacement, A as replaceAndCreateTextTrack, B as replaceAndCreateTrack, C as replaceSourceTrack, D as summarizeTextTrack, E as toISO639_1, F as toISO639_3, G as validateTrackPassthrough, H as workflows } from './index-
|
|
1
|
+
export { I as ISO639_1, a as ISO639_3, L as LanguageCodePair, M as MUX_TRACK_PASSTHROUGH_MAX_CHARS, R as ReplaceAndCreateTextTrackInput, b as ReplaceAndCreateTextTrackResult, c as ReplaceAndCreateTrackInput, d as ReplaceExistingTracksPolicy, e as ReplaceSourceTrackInput, f as ReplaceableTrackType, S as SourceTrackReplacementPolicy, g as SupportedISO639_1, h as SupportedISO639_3, T as TextTrackReplacementPlan, i as TextTrackSummary, j as TextTrackTarget, k as TrackSummary, l as TrackTarget, m as buildMuxAiTrackPassthrough, n as findNameCollisionTextTracks, o as findSameLanguageTextTracks, p as getLanguageCodePair, q as getLanguageName, r as isDuplicateTrackNameError, s as isMuxGeneratedTextTrack, t as isUndeterminedLanguageCode, u as isValidISO639_1, v as isValidISO639_3, w as normalizeTrackLanguageCode, x as normalizeTrackName, y as planSourceTrackReplacement, z as planTextTrackReplacement, A as replaceAndCreateTextTrack, B as replaceAndCreateTrack, C as replaceSourceTrack, D as summarizeTextTrack, E as toISO639_1, F as toISO639_3, G as validateTrackPassthrough, H as workflows } from './index-bdbFMlhA.js';
|
|
2
2
|
import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@workflow/serde';
|
|
3
3
|
import { T as TokenUsage, M as MuxAsset, W as WorkflowCredentials, S as StoragePutObjectInput, a as StoragePresignGetObjectInput } from './transcripts-Brw74qlV.js';
|
|
4
4
|
export { A as AssetTextTrack, C as ChunkEmbedding, b as ChunkingStrategy, E as Encrypted, c as EncryptedPayload, I as ImageSubmissionMode, d as MuxAIOptions, P as PlaybackAsset, e as PlaybackPolicy, f as ScopedMuxAIOptions, g as StorageAdapter, h as TextChunk, i as TokenChunkingConfig, j as ToneType, U as UsageMetadata, V as VTTChunkingConfig, k as VideoEmbeddingsResult, l as WorkflowCredentialsInput, m as WorkflowMuxClient, n as WorkflowScope, o as decryptFromWorkflow, p as encryptForWorkflow } from './transcripts-Brw74qlV.js';
|
|
@@ -11,7 +11,7 @@ import '@ai-sdk/google';
|
|
|
11
11
|
import '@ai-sdk/openai';
|
|
12
12
|
import '@mux/ts';
|
|
13
13
|
|
|
14
|
-
var version = "0.
|
|
14
|
+
var version = "0.58.0";
|
|
15
15
|
|
|
16
16
|
type MuxAiErrorType = "validation_error" | "processing_error" | "timeout_error" | "content_policy_error";
|
|
17
17
|
interface ModelCallDiagnostics {
|
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.58.0";
|
|
9
9
|
|
|
10
10
|
// src/lib/language-codes.ts
|
|
11
11
|
var ISO639_1_TO_3 = {
|
|
@@ -9314,6 +9314,8 @@ function parseElevenLabsErrorBody(body) {
|
|
|
9314
9314
|
}
|
|
9315
9315
|
|
|
9316
9316
|
// src/workflows/translate-audio.ts
|
|
9317
|
+
var CAPTIONS_UNAVAILABLE_MESSAGE = "The dub completed, but its subtitles could not be retrieved.";
|
|
9318
|
+
var CAPTIONS_ATTACHMENT_FAILED_MESSAGE = "Dub subtitles could not be attached to the Mux asset.";
|
|
9317
9319
|
var STATIC_RENDITION_POLL_INTERVAL_MS = 1e4;
|
|
9318
9320
|
var STATIC_RENDITION_MAX_ATTEMPTS = 180;
|
|
9319
9321
|
var MAX_DUBBING_SOURCE_BYTES = 1e9;
|
|
@@ -9649,38 +9651,56 @@ async function downloadAndUploadDubTranscript({
|
|
|
9649
9651
|
credentials
|
|
9650
9652
|
}) {
|
|
9651
9653
|
"use step";
|
|
9652
|
-
|
|
9653
|
-
|
|
9654
|
-
|
|
9654
|
+
try {
|
|
9655
|
+
const fetched = await fetchDubbingOutput(dubbingId, languageId, "subtitles", credentials);
|
|
9656
|
+
if (fetched.kind === "failed") {
|
|
9657
|
+
return fetched;
|
|
9658
|
+
}
|
|
9659
|
+
const transcriptVtt = await fetched.response.text();
|
|
9660
|
+
if (!transcriptVtt.trim()) {
|
|
9661
|
+
return { kind: "failed", failure: { retryable: false, detail: "Dub transcript response did not include webvtt content" } };
|
|
9662
|
+
}
|
|
9663
|
+
const s3AccessKeyId = env_default.S3_ACCESS_KEY_ID;
|
|
9664
|
+
const s3SecretAccessKey = env_default.S3_SECRET_ACCESS_KEY;
|
|
9665
|
+
const vttKey = `audio-translations/${assetId}/auto-to-${toLanguageCode}-${Date.now()}.vtt`;
|
|
9666
|
+
await putObjectWithStorageAdapter({
|
|
9667
|
+
accessKeyId: s3AccessKeyId,
|
|
9668
|
+
secretAccessKey: s3SecretAccessKey,
|
|
9669
|
+
endpoint: s3Endpoint,
|
|
9670
|
+
region: s3Region,
|
|
9671
|
+
bucket: s3Bucket,
|
|
9672
|
+
key: vttKey,
|
|
9673
|
+
body: transcriptVtt,
|
|
9674
|
+
contentType: "text/vtt"
|
|
9675
|
+
}, storageAdapter);
|
|
9676
|
+
const presignedUrl = await createPresignedGetUrlWithStorageAdapter({
|
|
9677
|
+
accessKeyId: s3AccessKeyId,
|
|
9678
|
+
secretAccessKey: s3SecretAccessKey,
|
|
9679
|
+
endpoint: s3Endpoint,
|
|
9680
|
+
region: s3Region,
|
|
9681
|
+
bucket: s3Bucket,
|
|
9682
|
+
key: vttKey,
|
|
9683
|
+
expiresInSeconds: s3SignedUrlExpirySeconds ?? 86400
|
|
9684
|
+
}, storageAdapter);
|
|
9685
|
+
console.warn(`\u2705 Dub transcript uploaded successfully to: ${vttKey}`);
|
|
9686
|
+
return { kind: "staged", presignedUrl };
|
|
9687
|
+
} catch (error) {
|
|
9688
|
+
return { kind: "failed", failure: { retryable: true, detail: extractErrorDetail(error) } };
|
|
9655
9689
|
}
|
|
9656
|
-
|
|
9657
|
-
|
|
9658
|
-
|
|
9690
|
+
}
|
|
9691
|
+
async function attachDubbedCaptions(input) {
|
|
9692
|
+
"use step";
|
|
9693
|
+
try {
|
|
9694
|
+
const outcome = await replaceAndCreateTrack(input);
|
|
9695
|
+
if (outcome.kind === "created") {
|
|
9696
|
+
return { status: "created", trackId: outcome.trackId, replacedTracks: outcome.deleted };
|
|
9697
|
+
}
|
|
9698
|
+
console.warn(`\u26A0\uFE0F Failed to attach dubbed captions: ${outcome.reason}`);
|
|
9699
|
+
return { status: "failed", message: outcome.kind === "blocked" ? outcome.reason : CAPTIONS_ATTACHMENT_FAILED_MESSAGE, retryable: outcome.kind === "create_failed", replacedTracks: outcome.deleted };
|
|
9700
|
+
} catch (error) {
|
|
9701
|
+
console.warn(`\u26A0\uFE0F Failed to attach dubbed captions: ${extractErrorDetail(error)}`);
|
|
9702
|
+
return { status: "failed", message: CAPTIONS_ATTACHMENT_FAILED_MESSAGE, retryable: true, replacedTracks: [] };
|
|
9659
9703
|
}
|
|
9660
|
-
const s3AccessKeyId = env_default.S3_ACCESS_KEY_ID;
|
|
9661
|
-
const s3SecretAccessKey = env_default.S3_SECRET_ACCESS_KEY;
|
|
9662
|
-
const vttKey = `audio-translations/${assetId}/auto-to-${toLanguageCode}-${Date.now()}.vtt`;
|
|
9663
|
-
await putObjectWithStorageAdapter({
|
|
9664
|
-
accessKeyId: s3AccessKeyId,
|
|
9665
|
-
secretAccessKey: s3SecretAccessKey,
|
|
9666
|
-
endpoint: s3Endpoint,
|
|
9667
|
-
region: s3Region,
|
|
9668
|
-
bucket: s3Bucket,
|
|
9669
|
-
key: vttKey,
|
|
9670
|
-
body: transcriptVtt,
|
|
9671
|
-
contentType: "text/vtt"
|
|
9672
|
-
}, storageAdapter);
|
|
9673
|
-
const presignedUrl = await createPresignedGetUrlWithStorageAdapter({
|
|
9674
|
-
accessKeyId: s3AccessKeyId,
|
|
9675
|
-
secretAccessKey: s3SecretAccessKey,
|
|
9676
|
-
endpoint: s3Endpoint,
|
|
9677
|
-
region: s3Region,
|
|
9678
|
-
bucket: s3Bucket,
|
|
9679
|
-
key: vttKey,
|
|
9680
|
-
expiresInSeconds: s3SignedUrlExpirySeconds ?? 86400
|
|
9681
|
-
}, storageAdapter);
|
|
9682
|
-
console.warn(`\u2705 Dub transcript uploaded successfully to: ${vttKey}`);
|
|
9683
|
-
return { kind: "staged", presignedUrl };
|
|
9684
9704
|
}
|
|
9685
9705
|
async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
9686
9706
|
"use workflow";
|
|
@@ -9696,6 +9716,7 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
9696
9716
|
storageAdapter,
|
|
9697
9717
|
credentials: providedCredentials,
|
|
9698
9718
|
replaceExistingTracks = "fail",
|
|
9719
|
+
captionsReplaceExistingTracks = replaceExistingTracks,
|
|
9699
9720
|
trackName: providedTrackName,
|
|
9700
9721
|
trackPassthrough: providedTrackPassthrough
|
|
9701
9722
|
} = options;
|
|
@@ -9714,7 +9735,7 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
9714
9735
|
const muxLangCode = targetLanguageCode;
|
|
9715
9736
|
const trackName = providedTrackName ?? `${getLanguageName(muxLangCode) ?? muxLangCode.toUpperCase()} (Auto-dubbed)`;
|
|
9716
9737
|
const audioTrackTarget = { type: "audio", languageCode: muxLangCode, name: trackName };
|
|
9717
|
-
const captionsTrackTarget = { type: "text", languageCode: muxLangCode, name: trackName };
|
|
9738
|
+
const captionsTrackTarget = { type: "text", languageCode: muxLangCode, name: options.captionsTrackName ?? trackName };
|
|
9718
9739
|
const s3Endpoint = options.s3Endpoint ?? env_default.S3_ENDPOINT;
|
|
9719
9740
|
const s3Region = options.s3Region ?? env_default.S3_REGION ?? "auto";
|
|
9720
9741
|
const s3Bucket = options.s3Bucket ?? env_default.S3_BUCKET;
|
|
@@ -9732,11 +9753,8 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
9732
9753
|
if (audioTrackUnsupported) {
|
|
9733
9754
|
throw new MuxAiError(`Asset ${assetId} ${audioTrackUnsupported}`, { type: "validation_error" });
|
|
9734
9755
|
}
|
|
9735
|
-
|
|
9736
|
-
|
|
9737
|
-
...uploadCaptionsToMux ? [captionsTrackTarget] : []
|
|
9738
|
-
]) {
|
|
9739
|
-
const plan = planTextTrackReplacement(initialAsset, target, replaceExistingTracks);
|
|
9756
|
+
if (uploadToMux) {
|
|
9757
|
+
const plan = planTextTrackReplacement(initialAsset, audioTrackTarget, replaceExistingTracks);
|
|
9740
9758
|
if (plan.kind === "blocked") {
|
|
9741
9759
|
throw new MuxAiError(plan.reason, { type: "validation_error" });
|
|
9742
9760
|
}
|
|
@@ -9761,6 +9779,7 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
9761
9779
|
let replacedTracks;
|
|
9762
9780
|
let captionsPresignedUrl;
|
|
9763
9781
|
let captionsTrackId;
|
|
9782
|
+
let captionsOutcome;
|
|
9764
9783
|
try {
|
|
9765
9784
|
let sourceRenditionName = "audio.m4a";
|
|
9766
9785
|
if (isLegacyMp4SupportAsset) {
|
|
@@ -9939,30 +9958,35 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
9939
9958
|
credentials
|
|
9940
9959
|
});
|
|
9941
9960
|
if (transcript.kind === "failed") {
|
|
9942
|
-
|
|
9961
|
+
captionsOutcome = { status: "unavailable", message: CAPTIONS_UNAVAILABLE_MESSAGE, retryable: transcript.failure.retryable };
|
|
9962
|
+
console.warn(`\u26A0\uFE0F Failed to retrieve dubbed captions: ${transcript.failure.detail}`);
|
|
9963
|
+
} else {
|
|
9964
|
+
captionsPresignedUrl = transcript.presignedUrl;
|
|
9965
|
+
captionsOutcome = { status: "available" };
|
|
9943
9966
|
}
|
|
9944
|
-
captionsPresignedUrl
|
|
9945
|
-
if (uploadCaptionsToMux) {
|
|
9967
|
+
if (uploadCaptionsToMux && captionsPresignedUrl) {
|
|
9946
9968
|
console.warn("\u{1F4F9} Adding dubbed captions track to Mux asset...");
|
|
9947
|
-
|
|
9969
|
+
captionsOutcome = await attachDubbedCaptions({
|
|
9948
9970
|
assetId,
|
|
9949
9971
|
target: captionsTrackTarget,
|
|
9950
|
-
policy:
|
|
9972
|
+
policy: captionsReplaceExistingTracks,
|
|
9951
9973
|
presignedUrl: captionsPresignedUrl,
|
|
9952
9974
|
passthrough: trackPassthrough,
|
|
9953
9975
|
credentials
|
|
9954
9976
|
});
|
|
9955
|
-
if (captionsOutcome.
|
|
9956
|
-
replacedTracks = [...replacedTracks ?? [], ...captionsOutcome.
|
|
9977
|
+
if (captionsOutcome.replacedTracks.length > 0) {
|
|
9978
|
+
replacedTracks = [...replacedTracks ?? [], ...captionsOutcome.replacedTracks];
|
|
9957
9979
|
}
|
|
9958
|
-
if (captionsOutcome.
|
|
9959
|
-
|
|
9980
|
+
if (captionsOutcome.status === "created") {
|
|
9981
|
+
captionsTrackId = captionsOutcome.trackId;
|
|
9982
|
+
console.warn(`\u2705 Captions track added to Mux asset with ID: ${captionsTrackId}`);
|
|
9983
|
+
} else {
|
|
9984
|
+
console.warn(`\u26A0\uFE0F Failed to attach dubbed captions: ${captionsOutcome.message}`);
|
|
9960
9985
|
}
|
|
9961
|
-
captionsTrackId = captionsOutcome.trackId;
|
|
9962
|
-
console.warn(`\u2705 Captions track added to Mux asset with ID: ${captionsTrackId}`);
|
|
9963
9986
|
}
|
|
9964
9987
|
} catch (error) {
|
|
9965
|
-
|
|
9988
|
+
captionsOutcome = captionsPresignedUrl ? { status: "failed", message: CAPTIONS_ATTACHMENT_FAILED_MESSAGE, retryable: true, replacedTracks: [] } : { status: "unavailable", message: CAPTIONS_UNAVAILABLE_MESSAGE, retryable: true };
|
|
9989
|
+
console.warn(`\u26A0\uFE0F Failed to attach dubbed captions: ${extractErrorDetail(error)}`);
|
|
9966
9990
|
if (captionsPresignedUrl) {
|
|
9967
9991
|
console.warn("\u{1F517} You can manually add the captions track using this presigned URL:");
|
|
9968
9992
|
console.warn(captionsPresignedUrl);
|
|
@@ -9992,6 +10016,7 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
9992
10016
|
replacedTracks,
|
|
9993
10017
|
captionsTrackId,
|
|
9994
10018
|
captionsPresignedUrl,
|
|
10019
|
+
captionsOutcome,
|
|
9995
10020
|
createdStaticRenditionId,
|
|
9996
10021
|
staticRenditionCleanup,
|
|
9997
10022
|
usage: {
|