@mux/ai 0.36.0 → 0.37.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/README.md +3 -0
- package/dist/{index-C2FORyvQ.d.ts → index-BupL84pY.d.ts} +23 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +48 -3
- package/dist/index.js.map +1 -1
- package/dist/workflows/index.d.ts +1 -1
- package/dist/workflows/index.js +47 -2
- package/dist/workflows/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -124,6 +124,9 @@ const result = await editCaptions("your-asset-id", "track-id", {
|
|
|
124
124
|
replacements: [
|
|
125
125
|
{ find: "Mucks", replace: "Mux" },
|
|
126
126
|
],
|
|
127
|
+
speakerReplacements: [
|
|
128
|
+
{ find: "speaker_0", replace: "Alice" },
|
|
129
|
+
],
|
|
127
130
|
});
|
|
128
131
|
|
|
129
132
|
console.log(result.totalReplacementCount); // 8
|
|
@@ -740,6 +740,12 @@ interface CaptionReplacement {
|
|
|
740
740
|
/** Match `find` with case-sensitivity. Defaults to `true`. */
|
|
741
741
|
caseSensitive?: boolean;
|
|
742
742
|
}
|
|
743
|
+
interface SpeakerReplacement {
|
|
744
|
+
/** Current speaker label, without the surrounding square brackets. */
|
|
745
|
+
find: string;
|
|
746
|
+
/** New speaker label, without the surrounding square brackets. */
|
|
747
|
+
replace: string;
|
|
748
|
+
}
|
|
743
749
|
interface ReplacementRecord {
|
|
744
750
|
cueStartTime: number;
|
|
745
751
|
before: string;
|
|
@@ -755,6 +761,8 @@ interface EditCaptionsOptions<P extends SupportedProvider = SupportedProvider> e
|
|
|
755
761
|
autoCensorProfanity?: AutoCensorProfanityOptions;
|
|
756
762
|
/** Static find/replace pairs (no LLM needed). */
|
|
757
763
|
replacements?: CaptionReplacement[];
|
|
764
|
+
/** Replacements applied only to bracketed speaker labels at the start of cues. */
|
|
765
|
+
speakerReplacements?: SpeakerReplacement[];
|
|
758
766
|
/** Delete the original track after creating the edited one. Defaults to true. */
|
|
759
767
|
deleteOriginalTrack?: boolean;
|
|
760
768
|
/**
|
|
@@ -795,6 +803,9 @@ interface EditCaptionsResult {
|
|
|
795
803
|
replacements?: {
|
|
796
804
|
replacements: ReplacementRecord[];
|
|
797
805
|
};
|
|
806
|
+
speakerReplacements?: {
|
|
807
|
+
replacements: ReplacementRecord[];
|
|
808
|
+
};
|
|
798
809
|
uploadedTrackId?: string;
|
|
799
810
|
presignedUrl?: string;
|
|
800
811
|
usage?: TokenUsage;
|
|
@@ -880,6 +891,14 @@ declare function applyReplacements(rawVtt: string, replacements: CaptionReplacem
|
|
|
880
891
|
editedVtt: string;
|
|
881
892
|
replacements: ReplacementRecord[];
|
|
882
893
|
};
|
|
894
|
+
/**
|
|
895
|
+
* Replaces bracketed speaker labels only when they appear at the start of a cue.
|
|
896
|
+
* Spoken text that happens to contain the same value is left unchanged.
|
|
897
|
+
*/
|
|
898
|
+
declare function applySpeakerReplacements(rawVtt: string, speakerReplacements: SpeakerReplacement[]): {
|
|
899
|
+
editedVtt: string;
|
|
900
|
+
replacements: ReplacementRecord[];
|
|
901
|
+
};
|
|
883
902
|
declare function editCaptions<P extends SupportedProvider = SupportedProvider>(assetId: string, trackId: string, options: EditCaptionsOptions<P>): Promise<EditCaptionsResult>;
|
|
884
903
|
|
|
885
904
|
/** Configuration accepted by `generateEmbeddings`. */
|
|
@@ -1545,6 +1564,7 @@ type index_Question = Question;
|
|
|
1545
1564
|
type index_QuestionAnswer = QuestionAnswer;
|
|
1546
1565
|
type index_QuestionAnswerType = QuestionAnswerType;
|
|
1547
1566
|
type index_ReplacementRecord = ReplacementRecord;
|
|
1567
|
+
type index_SpeakerReplacement = SpeakerReplacement;
|
|
1548
1568
|
type index_StaticRenditionCleanupOutcome = StaticRenditionCleanupOutcome;
|
|
1549
1569
|
type index_SummarizationOptions = SummarizationOptions;
|
|
1550
1570
|
type index_SummarizationPromptOverrides = SummarizationPromptOverrides;
|
|
@@ -1559,6 +1579,7 @@ type index_TranslationResult = TranslationResult;
|
|
|
1559
1579
|
declare const index_aggregateTokenUsage: typeof aggregateTokenUsage;
|
|
1560
1580
|
declare const index_applyOverrideLists: typeof applyOverrideLists;
|
|
1561
1581
|
declare const index_applyReplacements: typeof applyReplacements;
|
|
1582
|
+
declare const index_applySpeakerReplacements: typeof applySpeakerReplacements;
|
|
1562
1583
|
declare const index_askQuestions: typeof askQuestions;
|
|
1563
1584
|
declare const index_buildReplacementRegex: typeof buildReplacementRegex;
|
|
1564
1585
|
declare const index_burnedInCaptionsSchema: typeof burnedInCaptionsSchema;
|
|
@@ -1588,7 +1609,7 @@ declare const index_translationSchema: typeof translationSchema;
|
|
|
1588
1609
|
declare const index_validateNeverTranslateTerms: typeof validateNeverTranslateTerms;
|
|
1589
1610
|
declare const index_verifyNeverTranslateTerms: typeof verifyNeverTranslateTerms;
|
|
1590
1611
|
declare namespace index {
|
|
1591
|
-
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_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, 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_GOOGLE_VISION_LIKELIHOOD_TO_SCORE as GOOGLE_VISION_LIKELIHOOD_TO_SCORE, 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_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_ReplacementRecord as ReplacementRecord, 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_ThumbnailModerationScore as ThumbnailModerationScore, 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_askQuestions as askQuestions, index_buildReplacementRegex as buildReplacementRegex, index_burnedInCaptionsSchema as burnedInCaptionsSchema, index_censorVttContent as censorVttContent, index_chapterSchema as chapterSchema, index_chaptersSchema as chaptersSchema, index_createReplacer as createReplacer, index_editCaptions as editCaptions, index_extractTranscriptSegmentsForHotspots as extractTranscriptSegmentsForHotspots, index_generateChapters as generateChapters, index_generateEmbeddings as generateEmbeddings, index_generateEngagementInsights as generateEngagementInsights, index_generateVideoEmbeddings as generateVideoEmbeddings, index_getModerationScores as getModerationScores, index_getSummaryAndTags as getSummaryAndTags, index_hasBurnedInCaptions as hasBurnedInCaptions, index_mapShotsToHotspots as mapShotsToHotspots, index_normalizeTranslatedVtt as normalizeTranslatedVtt, index_profanityDetectionSchema as profanityDetectionSchema, index_questionAnswerSchema as questionAnswerSchema, 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 };
|
|
1612
|
+
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_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, 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_GOOGLE_VISION_LIKELIHOOD_TO_SCORE as GOOGLE_VISION_LIKELIHOOD_TO_SCORE, 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_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_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_ThumbnailModerationScore as ThumbnailModerationScore, 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_askQuestions as askQuestions, index_buildReplacementRegex as buildReplacementRegex, index_burnedInCaptionsSchema as burnedInCaptionsSchema, index_censorVttContent as censorVttContent, index_chapterSchema as chapterSchema, index_chaptersSchema as chaptersSchema, index_createReplacer as createReplacer, index_editCaptions as editCaptions, index_extractTranscriptSegmentsForHotspots as extractTranscriptSegmentsForHotspots, index_generateChapters as generateChapters, index_generateEmbeddings as generateEmbeddings, index_generateEngagementInsights as generateEngagementInsights, index_generateVideoEmbeddings as generateVideoEmbeddings, index_getModerationScores as getModerationScores, index_getSummaryAndTags as getSummaryAndTags, index_hasBurnedInCaptions as hasBurnedInCaptions, index_mapShotsToHotspots as mapShotsToHotspots, index_normalizeTranslatedVtt as normalizeTranslatedVtt, index_profanityDetectionSchema as profanityDetectionSchema, index_questionAnswerSchema as questionAnswerSchema, 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 };
|
|
1592
1613
|
}
|
|
1593
1614
|
|
|
1594
|
-
export { type MomentInsight as $, ASK_QUESTIONS_DEFAULT_MAX_ANSWER_OPTION_LENGTH as A, type BurnedInCaptionsAnalysis as B, type CaptionReplacement as C, type ChaptersPromptOverrides as D, type ChaptersPromptSections as E, type ChaptersResult as F, type ChaptersType as G, DEFAULT_DESCRIPTION_LENGTH as H, type ISO639_1 as I, DEFAULT_SUMMARY_KEYWORD_LIMIT as J, DEFAULT_TITLE_LENGTH as K, type LanguageCodePair as L, type EditCaptionsOptions as M, type EditCaptionsResult as N, type EmbeddingsOptions as O, type EmbeddingsResult as P, type EngagementInsightsOptions as Q, type EngagementInsightsResult as R, type SupportedISO639_1 as S, GOOGLE_VISION_LIKELIHOOD_TO_SCORE as T, HIVE_SEXUAL_CATEGORIES as U, HIVE_VIOLENCE_CATEGORIES as V, type HiveModerationOutput as W, type HiveModerationSource as X, type ModerationOptions as Y, type ModerationProvider as Z, type ModerationResult as _, type ISO639_3 as a, type OverallInsight as a0, type ProfanityDetectionPayload as a1, type Question as a2, type QuestionAnswer as a3, type QuestionAnswerType as a4, type ReplacementRecord as a5, type
|
|
1615
|
+
export { type MomentInsight as $, ASK_QUESTIONS_DEFAULT_MAX_ANSWER_OPTION_LENGTH as A, type BurnedInCaptionsAnalysis as B, type CaptionReplacement as C, type ChaptersPromptOverrides as D, type ChaptersPromptSections as E, type ChaptersResult as F, type ChaptersType as G, DEFAULT_DESCRIPTION_LENGTH as H, type ISO639_1 as I, DEFAULT_SUMMARY_KEYWORD_LIMIT as J, DEFAULT_TITLE_LENGTH as K, type LanguageCodePair as L, type EditCaptionsOptions as M, type EditCaptionsResult as N, type EmbeddingsOptions as O, type EmbeddingsResult as P, type EngagementInsightsOptions as Q, type EngagementInsightsResult as R, type SupportedISO639_1 as S, GOOGLE_VISION_LIKELIHOOD_TO_SCORE as T, HIVE_SEXUAL_CATEGORIES as U, HIVE_VIOLENCE_CATEGORIES as V, type HiveModerationOutput as W, type HiveModerationSource as X, type ModerationOptions as Y, type ModerationProvider as Z, type ModerationResult as _, type ISO639_3 as a, type OverallInsight as a0, type ProfanityDetectionPayload as a1, type Question as a2, type QuestionAnswer as a3, type QuestionAnswerType as a4, type ReplacementRecord as a5, type SpeakerReplacement as a6, type StaticRenditionCleanupOutcome as a7, type SummarizationOptions as a8, type SummarizationPromptOverrides as a9, getSummaryAndTags as aA, hasBurnedInCaptions as aB, mapShotsToHotspots as aC, normalizeTranslatedVtt as aD, profanityDetectionSchema as aE, questionAnswerSchema as aF, shouldSplitChunkTranslationError as aG, summarySchema as aH, transformCueText as aI, translateAudio as aJ, translateCaptions as aK, translationSchema as aL, validateNeverTranslateTerms as aM, verifyNeverTranslateTerms as aN, type SummarizationPromptSections as aa, type SummaryAndTagsResult as ab, type SummaryType as ac, type ThumbnailModerationScore as ad, type TranslationChunkingOptions as ae, type TranslationOptions as af, type TranslationPayload as ag, type TranslationResult as ah, aggregateTokenUsage as ai, applyOverrideLists as aj, applyReplacements as ak, applySpeakerReplacements as al, askQuestions as am, buildReplacementRegex as an, burnedInCaptionsSchema as ao, censorVttContent as ap, chapterSchema as aq, chaptersSchema as ar, createReplacer as as, editCaptions as at, extractTranscriptSegmentsForHotspots as au, generateChapters as av, generateEmbeddings as aw, generateEngagementInsights as ax, generateVideoEmbeddings as ay, getModerationScores as az, type SupportedISO639_3 as b, getLanguageName as c, isValidISO639_1 as d, isValidISO639_3 as e, toISO639_3 as f, getLanguageCodePair as g, index as h, isUndeterminedLanguageCode as i, ASK_QUESTIONS_DEFAULT_MAX_FREE_FORM_ANSWER_LENGTH as j, ASK_QUESTIONS_MAX_QUESTION_LENGTH as k, type AskQuestionsOptions as l, type AskQuestionsResult as m, type AskQuestionsType as n, type AudioTranslationOptions as o, type AudioTranslationResult as p, type AutoCensorProfanityOptions as q, type BurnedInCaptionsOptions as r, type BurnedInCaptionsPromptOverrides as s, toISO639_1 as t, type BurnedInCaptionsPromptSections as u, type BurnedInCaptionsResult as v, type CensorMode as w, type Chapter as x, type ChapterSystemPromptSections as y, type ChaptersOptions 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, 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-BupL84pY.js';
|
|
2
2
|
import { W as WorkflowCredentials, S as StoragePutObjectInput, a as StoragePresignGetObjectInput } from './shots-CUI09Ohe.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 ScopedMuxAIOptions, g as StorageAdapter, T as TextChunk, h as TokenChunkingConfig, i as TokenUsage, 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 './shots-CUI09Ohe.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.37.0";
|
|
13
13
|
|
|
14
14
|
type MuxAiErrorType = "validation_error" | "processing_error" | "timeout_error" | "content_policy_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.37.0";
|
|
9
9
|
|
|
10
10
|
// src/lib/language-codes.ts
|
|
11
11
|
var ISO639_1_TO_3 = {
|
|
@@ -3022,6 +3022,7 @@ __export(workflows_exports, {
|
|
|
3022
3022
|
aggregateTokenUsage: () => aggregateTokenUsage,
|
|
3023
3023
|
applyOverrideLists: () => applyOverrideLists,
|
|
3024
3024
|
applyReplacements: () => applyReplacements,
|
|
3025
|
+
applySpeakerReplacements: () => applySpeakerReplacements,
|
|
3025
3026
|
askQuestions: () => askQuestions,
|
|
3026
3027
|
buildReplacementRegex: () => buildReplacementRegex,
|
|
3027
3028
|
burnedInCaptionsSchema: () => burnedInCaptionsSchema,
|
|
@@ -4962,6 +4963,27 @@ function applyReplacements(rawVtt, replacements) {
|
|
|
4962
4963
|
});
|
|
4963
4964
|
return { editedVtt, replacements: records };
|
|
4964
4965
|
}
|
|
4966
|
+
function applySpeakerReplacements(rawVtt, speakerReplacements) {
|
|
4967
|
+
const replacementsByLabel = new Map(
|
|
4968
|
+
speakerReplacements.filter((replacement) => replacement.find.length > 0).map((replacement) => [replacement.find, replacement.replace])
|
|
4969
|
+
);
|
|
4970
|
+
if (replacementsByLabel.size === 0) {
|
|
4971
|
+
return { editedVtt: rawVtt, replacements: [] };
|
|
4972
|
+
}
|
|
4973
|
+
const records = [];
|
|
4974
|
+
const editedVtt = transformCueTextBlocks(rawVtt, (cueText, cueStartTime) => {
|
|
4975
|
+
return cueText.replace(/^(\s*)\[([^\]\r\n]+)\](?=\s|$)/, (marker, leadingWhitespace, label) => {
|
|
4976
|
+
const replacement = replacementsByLabel.get(label);
|
|
4977
|
+
if (replacement === void 0)
|
|
4978
|
+
return marker;
|
|
4979
|
+
const before = `[${label}]`;
|
|
4980
|
+
const after = `[${replacement}]`;
|
|
4981
|
+
records.push({ cueStartTime, before, after });
|
|
4982
|
+
return `${leadingWhitespace}${after}`;
|
|
4983
|
+
});
|
|
4984
|
+
});
|
|
4985
|
+
return { editedVtt, replacements: records };
|
|
4986
|
+
}
|
|
4965
4987
|
async function identifyProfanityWithAI({
|
|
4966
4988
|
plainText,
|
|
4967
4989
|
provider,
|
|
@@ -5064,6 +5086,7 @@ async function editCaptionsInternal(assetId, trackId, options, collectedUsage) {
|
|
|
5064
5086
|
model,
|
|
5065
5087
|
autoCensorProfanity: autoCensorOption,
|
|
5066
5088
|
replacements: replacementsOption,
|
|
5089
|
+
speakerReplacements: speakerReplacementsOption,
|
|
5067
5090
|
deleteOriginalTrack,
|
|
5068
5091
|
uploadToS3: uploadToS3Option,
|
|
5069
5092
|
uploadToMux: uploadToMuxOption,
|
|
@@ -5076,8 +5099,9 @@ async function editCaptionsInternal(assetId, trackId, options, collectedUsage) {
|
|
|
5076
5099
|
} = options;
|
|
5077
5100
|
const hasAutoCensor = !!autoCensorOption;
|
|
5078
5101
|
const hasReplacements = !!replacementsOption && replacementsOption.length > 0;
|
|
5079
|
-
|
|
5080
|
-
|
|
5102
|
+
const hasSpeakerReplacements = !!speakerReplacementsOption && speakerReplacementsOption.length > 0;
|
|
5103
|
+
if (!hasAutoCensor && !hasReplacements && !hasSpeakerReplacements) {
|
|
5104
|
+
throw new MuxAiError("At least one of autoCensorProfanity, replacements, or speakerReplacements must be provided.", { type: "validation_error" });
|
|
5081
5105
|
}
|
|
5082
5106
|
if (autoCensorOption && !provider) {
|
|
5083
5107
|
throw new MuxAiError("provider is required when using autoCensorProfanity.", { type: "validation_error" });
|
|
@@ -5085,6 +5109,16 @@ async function editCaptionsInternal(assetId, trackId, options, collectedUsage) {
|
|
|
5085
5109
|
const deleteOriginal = deleteOriginalTrack !== false;
|
|
5086
5110
|
const uploadToMux = uploadToMuxOption !== false;
|
|
5087
5111
|
const uploadToS3 = uploadToS3Option || uploadToMux;
|
|
5112
|
+
for (const replacement of speakerReplacementsOption ?? []) {
|
|
5113
|
+
const hasInvalidFindCharacter = replacement.find.includes("[") || replacement.find.includes("]") || /[\r\n]/.test(replacement.find);
|
|
5114
|
+
const hasInvalidReplaceCharacter = replacement.replace.includes("[") || replacement.replace.includes("]") || /[\r\n]/.test(replacement.replace);
|
|
5115
|
+
if (!replacement.find || !replacement.replace || hasInvalidFindCharacter || hasInvalidReplaceCharacter) {
|
|
5116
|
+
throw new MuxAiError(
|
|
5117
|
+
"Speaker replacement labels must be non-empty and must not contain square brackets or newlines.",
|
|
5118
|
+
{ type: "validation_error" }
|
|
5119
|
+
);
|
|
5120
|
+
}
|
|
5121
|
+
}
|
|
5088
5122
|
const s3Endpoint = providedS3Endpoint ?? env_default.S3_ENDPOINT;
|
|
5089
5123
|
const s3Region = providedS3Region ?? env_default.S3_REGION ?? "auto";
|
|
5090
5124
|
const s3Bucket = providedS3Bucket ?? env_default.S3_BUCKET;
|
|
@@ -5166,6 +5200,16 @@ async function editCaptionsInternal(assetId, trackId, options, collectedUsage) {
|
|
|
5166
5200
|
totalReplacementCount += censorReplacements.length;
|
|
5167
5201
|
autoCensorResult = { replacements: censorReplacements };
|
|
5168
5202
|
}
|
|
5203
|
+
let speakerReplacementsResult;
|
|
5204
|
+
if (speakerReplacementsOption && speakerReplacementsOption.length > 0) {
|
|
5205
|
+
const { editedVtt: afterSpeakerReplacements, replacements: speakerReplacements } = applySpeakerReplacements(
|
|
5206
|
+
editedVtt,
|
|
5207
|
+
speakerReplacementsOption
|
|
5208
|
+
);
|
|
5209
|
+
editedVtt = afterSpeakerReplacements;
|
|
5210
|
+
totalReplacementCount += speakerReplacements.length;
|
|
5211
|
+
speakerReplacementsResult = { replacements: speakerReplacements };
|
|
5212
|
+
}
|
|
5169
5213
|
let replacementsResult;
|
|
5170
5214
|
if (replacementsOption && replacementsOption.length > 0) {
|
|
5171
5215
|
const { editedVtt: afterReplacements, replacements: staticReplacements } = applyReplacements(editedVtt, replacementsOption);
|
|
@@ -5228,6 +5272,7 @@ async function editCaptionsInternal(assetId, trackId, options, collectedUsage) {
|
|
|
5228
5272
|
totalReplacementCount,
|
|
5229
5273
|
autoCensorProfanity: autoCensorResult,
|
|
5230
5274
|
replacements: replacementsResult,
|
|
5275
|
+
speakerReplacements: speakerReplacementsResult,
|
|
5231
5276
|
uploadedTrackId,
|
|
5232
5277
|
presignedUrl,
|
|
5233
5278
|
usage: usageWithMetadata,
|