mulmocast 1.2.7 → 1.2.9

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.
@@ -5,7 +5,7 @@ import * as agents from "@graphai/vanilla";
5
5
  import { openAIAgent } from "@graphai/openai_agent";
6
6
  import { fileWriteAgent } from "@graphai/vanilla_node_agents";
7
7
  import { splitText } from "../utils/string.js";
8
- import { settings2GraphAIConfig } from "../utils/utils.js";
8
+ import { settings2GraphAIConfig, beatId, multiLingualObjectToArray } from "../utils/utils.js";
9
9
  import { getMultiLingual } from "../utils/context.js";
10
10
  import { currentMulmoScriptVersion } from "../utils/const.js";
11
11
  import { getOutputMultilingualFilePath, mkdir, writingMessage, hashSHA256 } from "../utils/file.js";
@@ -68,9 +68,10 @@ const beatGraph = {
68
68
  // for cache
69
69
  multiLingual: {
70
70
  agent: (namedInputs) => {
71
- const { multiLinguals, beatIndex, text } = namedInputs;
71
+ const { multiLinguals, beatIndex, text, beat } = namedInputs;
72
+ const key = beatId(beat?.id, beatIndex);
72
73
  const cacheKey = hashSHA256(text ?? "");
73
- const multiLingual = multiLinguals?.[beatIndex];
74
+ const multiLingual = multiLinguals?.[key];
74
75
  if (!multiLingual) {
75
76
  return { cacheKey, multiLingualTexts: {} };
76
77
  }
@@ -86,6 +87,7 @@ const beatGraph = {
86
87
  },
87
88
  inputs: {
88
89
  text: ":beat.text",
90
+ beat: ":beat",
89
91
  beatIndex: ":__mapIndex",
90
92
  multiLinguals: ":context.multiLingual",
91
93
  },
@@ -141,10 +143,21 @@ const translateGraph = {
141
143
  targetLangs: {},
142
144
  mergeStudioResult: {
143
145
  isResult: true,
144
- agent: "copyAgent",
146
+ agent: (namedInputs) => {
147
+ const { multiLingual, beats } = namedInputs;
148
+ const multiLingualObject = beats.reduce((tmp, beat, beatIndex) => {
149
+ const key = beatId(beat?.id, beatIndex);
150
+ tmp[key] = multiLingual[beatIndex];
151
+ return tmp;
152
+ }, {});
153
+ return {
154
+ version: "1.1",
155
+ multiLingual: multiLingualObject,
156
+ };
157
+ },
145
158
  inputs: {
146
- version: "1.1",
147
159
  multiLingual: ":beatsMap.mergeMultiLingualData",
160
+ beats: ":context.studio.script.beats",
148
161
  },
149
162
  },
150
163
  beatsMap: {
@@ -229,8 +242,9 @@ export const translateBeat = async (index, context, targetLangs, args) => {
229
242
  });
230
243
  }
231
244
  const results = await graph.run();
232
- const multiLingual = getMultiLingual(outputMultilingualFilePath, context.studio.beats.length);
233
- multiLingual[index] = results.mergeMultiLingualData;
245
+ const multiLingual = getMultiLingual(outputMultilingualFilePath, context.studio.beats);
246
+ const key = beatId(context.studio.script.beats[index]?.id, index);
247
+ multiLingual[key] = results.mergeMultiLingualData;
234
248
  const data = {
235
249
  version: currentMulmoScriptVersion,
236
250
  multiLingual,
@@ -263,7 +277,7 @@ export const translate = async (context, args) => {
263
277
  const results = await graph.run();
264
278
  writingMessage(outputMultilingualFilePath);
265
279
  if (results.mergeStudioResult) {
266
- context.multiLingual = results.mergeStudioResult.multiLingual;
280
+ context.multiLingual = multiLingualObjectToArray(results?.mergeStudioResult?.multiLingual, context.studio.script.beats);
267
281
  }
268
282
  }
269
283
  finally {
@@ -1,7 +1,7 @@
1
- import { type MulmoScript, type MulmoStudioMultiLingual } from "../types/index.js";
1
+ import { type MulmoStudioBeat, type MulmoScript, type MulmoStudioMultiLingual } from "../types/index.js";
2
2
  export declare const MulmoScriptMethods: {
3
3
  validate(script: any): MulmoScript;
4
4
  };
5
5
  export declare const MulmoStudioMultiLingualMethod: {
6
- validate(jsonData: any, studioBeatsLength: number): MulmoStudioMultiLingual;
6
+ validate(jsonData: any, beats: MulmoStudioBeat[]): MulmoStudioMultiLingual;
7
7
  };
@@ -1,5 +1,6 @@
1
1
  import { GraphAILogger } from "graphai";
2
2
  import { mulmoScriptSchema, mulmoStudioMultiLingualFileSchema } from "../types/index.js";
3
+ import { beatId } from "../utils/utils.js";
3
4
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
5
  const validate_1_0 = (script) => {
5
6
  if (script.speechParams?.provider) {
@@ -35,17 +36,19 @@ export const MulmoScriptMethods = {
35
36
  };
36
37
  export const MulmoStudioMultiLingualMethod = {
37
38
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
- validate(jsonData, studioBeatsLength) {
39
+ validate(jsonData, beats) {
39
40
  // TODO version check
40
41
  const result = mulmoStudioMultiLingualFileSchema.safeParse(jsonData);
41
42
  if (!result.success) {
42
43
  GraphAILogger.warn("multiLingual file validation failed.");
43
44
  }
44
- const dataSet = result.success ? result.data.multiLingual : [];
45
- while (dataSet.length < studioBeatsLength) {
46
- dataSet.push({ multiLingualTexts: {} });
47
- }
48
- dataSet.length = studioBeatsLength;
49
- return dataSet;
45
+ const multiLingual = result.success ? result.data.multiLingual : {};
46
+ beats.forEach((beat, index) => {
47
+ const key = beatId(beat?.id, index);
48
+ if (!multiLingual[key]) {
49
+ multiLingual[key] = { multiLingualTexts: {} };
50
+ }
51
+ });
52
+ return multiLingual;
50
53
  },
51
54
  };
@@ -1,4 +1,5 @@
1
1
  import path from "path";
2
+ import { beatId } from "../utils/utils.js";
2
3
  import { GraphAILogger } from "graphai";
3
4
  const sessionProgressCallbacks = new Set();
4
5
  export const addSessionProgressCallback = (cb) => {
@@ -51,7 +52,7 @@ export const MulmoStudioContextMethods = {
51
52
  notifyStateChange(context, sessionType);
52
53
  },
53
54
  setBeatSessionState(context, sessionType, index, id, value) {
54
- const key = id ?? `__index__${index}`;
55
+ const key = beatId(id, index);
55
56
  if (value) {
56
57
  if (!context.sessionState.inBeatSession[sessionType]) {
57
58
  context.sessionState.inBeatSession[sessionType] = {};
@@ -5689,6 +5689,7 @@ export declare const mulmoScriptSchema: z.ZodObject<{
5689
5689
  __test_invalid__?: boolean | undefined;
5690
5690
  }>;
5691
5691
  export declare const mulmoStudioBeatSchema: z.ZodObject<{
5692
+ id: z.ZodOptional<z.ZodString>;
5692
5693
  hash: z.ZodOptional<z.ZodString>;
5693
5694
  duration: z.ZodOptional<z.ZodNumber>;
5694
5695
  startAt: z.ZodOptional<z.ZodNumber>;
@@ -5705,6 +5706,7 @@ export declare const mulmoStudioBeatSchema: z.ZodObject<{
5705
5706
  htmlImageFile: z.ZodOptional<z.ZodString>;
5706
5707
  }, "strict", z.ZodTypeAny, {
5707
5708
  duration?: number | undefined;
5709
+ id?: string | undefined;
5708
5710
  startAt?: number | undefined;
5709
5711
  hash?: string | undefined;
5710
5712
  audioDuration?: number | undefined;
@@ -5720,6 +5722,7 @@ export declare const mulmoStudioBeatSchema: z.ZodObject<{
5720
5722
  htmlImageFile?: string | undefined;
5721
5723
  }, {
5722
5724
  duration?: number | undefined;
5725
+ id?: string | undefined;
5723
5726
  startAt?: number | undefined;
5724
5727
  hash?: string | undefined;
5725
5728
  audioDuration?: number | undefined;
@@ -5779,7 +5782,7 @@ export declare const mulmoStudioMultiLingualDataSchema: z.ZodObject<{
5779
5782
  }>;
5780
5783
  cacheKey?: string | undefined;
5781
5784
  }>;
5782
- export declare const mulmoStudioMultiLingualSchema: z.ZodArray<z.ZodObject<{
5785
+ export declare const mulmoStudioMultiLingualArraySchema: z.ZodArray<z.ZodObject<{
5783
5786
  multiLingualTexts: z.ZodRecord<z.ZodString, z.ZodObject<{
5784
5787
  text: z.ZodString;
5785
5788
  lang: z.ZodString;
@@ -5824,9 +5827,54 @@ export declare const mulmoStudioMultiLingualSchema: z.ZodArray<z.ZodObject<{
5824
5827
  }>;
5825
5828
  cacheKey?: string | undefined;
5826
5829
  }>, "many">;
5830
+ export declare const mulmoStudioMultiLingualSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
5831
+ multiLingualTexts: z.ZodRecord<z.ZodString, z.ZodObject<{
5832
+ text: z.ZodString;
5833
+ lang: z.ZodString;
5834
+ texts: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
5835
+ ttsTexts: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
5836
+ cacheKey: z.ZodString;
5837
+ duration: z.ZodOptional<z.ZodNumber>;
5838
+ }, "strict", z.ZodTypeAny, {
5839
+ text: string;
5840
+ lang: string;
5841
+ cacheKey: string;
5842
+ texts?: string[] | undefined;
5843
+ ttsTexts?: string[] | undefined;
5844
+ duration?: number | undefined;
5845
+ }, {
5846
+ text: string;
5847
+ lang: string;
5848
+ cacheKey: string;
5849
+ texts?: string[] | undefined;
5850
+ ttsTexts?: string[] | undefined;
5851
+ duration?: number | undefined;
5852
+ }>>;
5853
+ cacheKey: z.ZodOptional<z.ZodString>;
5854
+ }, "strip", z.ZodTypeAny, {
5855
+ multiLingualTexts: Record<string, {
5856
+ text: string;
5857
+ lang: string;
5858
+ cacheKey: string;
5859
+ texts?: string[] | undefined;
5860
+ ttsTexts?: string[] | undefined;
5861
+ duration?: number | undefined;
5862
+ }>;
5863
+ cacheKey?: string | undefined;
5864
+ }, {
5865
+ multiLingualTexts: Record<string, {
5866
+ text: string;
5867
+ lang: string;
5868
+ cacheKey: string;
5869
+ texts?: string[] | undefined;
5870
+ ttsTexts?: string[] | undefined;
5871
+ duration?: number | undefined;
5872
+ }>;
5873
+ cacheKey?: string | undefined;
5874
+ }>>;
5827
5875
  export declare const mulmoStudioMultiLingualFileSchema: z.ZodObject<{
5828
5876
  version: z.ZodLiteral<"1.1">;
5829
- multiLingual: z.ZodArray<z.ZodObject<{
5877
+ multiLingual: z.ZodRecord<z.ZodString, z.ZodObject<{
5830
5878
  multiLingualTexts: z.ZodRecord<z.ZodString, z.ZodObject<{
5831
5879
  text: z.ZodString;
5832
5880
  lang: z.ZodString;
@@ -5870,10 +5918,10 @@ export declare const mulmoStudioMultiLingualFileSchema: z.ZodObject<{
5870
5918
  duration?: number | undefined;
5871
5919
  }>;
5872
5920
  cacheKey?: string | undefined;
5873
- }>, "many">;
5921
+ }>>;
5874
5922
  }, "strip", z.ZodTypeAny, {
5875
5923
  version: "1.1";
5876
- multiLingual: {
5924
+ multiLingual: Record<string, {
5877
5925
  multiLingualTexts: Record<string, {
5878
5926
  text: string;
5879
5927
  lang: string;
@@ -5883,10 +5931,10 @@ export declare const mulmoStudioMultiLingualFileSchema: z.ZodObject<{
5883
5931
  duration?: number | undefined;
5884
5932
  }>;
5885
5933
  cacheKey?: string | undefined;
5886
- }[];
5934
+ }>;
5887
5935
  }, {
5888
5936
  version: "1.1";
5889
- multiLingual: {
5937
+ multiLingual: Record<string, {
5890
5938
  multiLingualTexts: Record<string, {
5891
5939
  text: string;
5892
5940
  lang: string;
@@ -5896,7 +5944,7 @@ export declare const mulmoStudioMultiLingualFileSchema: z.ZodObject<{
5896
5944
  duration?: number | undefined;
5897
5945
  }>;
5898
5946
  cacheKey?: string | undefined;
5899
- }[];
5947
+ }>;
5900
5948
  }>;
5901
5949
  export declare const mulmoSessionStateSchema: z.ZodObject<{
5902
5950
  inSession: z.ZodObject<{
@@ -8315,6 +8363,7 @@ export declare const mulmoStudioSchema: z.ZodObject<{
8315
8363
  }>;
8316
8364
  filename: z.ZodString;
8317
8365
  beats: z.ZodArray<z.ZodObject<{
8366
+ id: z.ZodOptional<z.ZodString>;
8318
8367
  hash: z.ZodOptional<z.ZodString>;
8319
8368
  duration: z.ZodOptional<z.ZodNumber>;
8320
8369
  startAt: z.ZodOptional<z.ZodNumber>;
@@ -8331,6 +8380,7 @@ export declare const mulmoStudioSchema: z.ZodObject<{
8331
8380
  htmlImageFile: z.ZodOptional<z.ZodString>;
8332
8381
  }, "strict", z.ZodTypeAny, {
8333
8382
  duration?: number | undefined;
8383
+ id?: string | undefined;
8334
8384
  startAt?: number | undefined;
8335
8385
  hash?: string | undefined;
8336
8386
  audioDuration?: number | undefined;
@@ -8346,6 +8396,7 @@ export declare const mulmoStudioSchema: z.ZodObject<{
8346
8396
  htmlImageFile?: string | undefined;
8347
8397
  }, {
8348
8398
  duration?: number | undefined;
8399
+ id?: string | undefined;
8349
8400
  startAt?: number | undefined;
8350
8401
  hash?: string | undefined;
8351
8402
  audioDuration?: number | undefined;
@@ -8363,6 +8414,7 @@ export declare const mulmoStudioSchema: z.ZodObject<{
8363
8414
  }, "strict", z.ZodTypeAny, {
8364
8415
  beats: {
8365
8416
  duration?: number | undefined;
8417
+ id?: string | undefined;
8366
8418
  startAt?: number | undefined;
8367
8419
  hash?: string | undefined;
8368
8420
  audioDuration?: number | undefined;
@@ -8705,6 +8757,7 @@ export declare const mulmoStudioSchema: z.ZodObject<{
8705
8757
  }, {
8706
8758
  beats: {
8707
8759
  duration?: number | undefined;
8760
+ id?: string | undefined;
8708
8761
  startAt?: number | undefined;
8709
8762
  hash?: string | undefined;
8710
8763
  audioDuration?: number | undefined;
@@ -383,6 +383,7 @@ export const mulmoScriptSchema = mulmoPresentationStyleSchema
383
383
  .strict();
384
384
  export const mulmoStudioBeatSchema = z
385
385
  .object({
386
+ id: z.string().optional().describe("Unique identifier for the beat."),
386
387
  hash: z.string().optional(),
387
388
  duration: z.number().optional(),
388
389
  startAt: z.number().optional(),
@@ -403,7 +404,8 @@ export const mulmoStudioMultiLingualDataSchema = z.object({
403
404
  multiLingualTexts: multiLingualTextsSchema,
404
405
  cacheKey: z.string().optional(),
405
406
  });
406
- export const mulmoStudioMultiLingualSchema = z.array(mulmoStudioMultiLingualDataSchema).min(1);
407
+ export const mulmoStudioMultiLingualArraySchema = z.array(mulmoStudioMultiLingualDataSchema).min(1);
408
+ export const mulmoStudioMultiLingualSchema = z.record(z.string(), mulmoStudioMultiLingualDataSchema);
407
409
  export const mulmoStudioMultiLingualFileSchema = z.object({
408
410
  version: z.literal(currentMulmoScriptVersion),
409
411
  multiLingual: mulmoStudioMultiLingualSchema,
@@ -1,5 +1,5 @@
1
1
  import { type CallbackFunction } from "graphai";
2
- import { langSchema, localizedTextSchema, mulmoBeatSchema, mulmoScriptSchema, mulmoStudioSchema, mulmoStudioBeatSchema, mulmoStoryboardSchema, mulmoStoryboardSceneSchema, mulmoStudioMultiLingualSchema, mulmoStudioMultiLingualDataSchema, mulmoStudioMultiLingualFileSchema, speakerDictionarySchema, mulmoImageParamsSchema, mulmoImageParamsImagesSchema, mulmoFillOptionSchema, mulmoMovieParamsSchema, textSlideParamsSchema, speechOptionsSchema, speakerDataSchema, mulmoCanvasDimensionSchema, mulmoPromptTemplateSchema, mulmoPromptTemplateFileSchema, text2ImageProviderSchema, text2HtmlImageProviderSchema, text2MovieProviderSchema, text2SpeechProviderSchema, mulmoPresentationStyleSchema, multiLingualTextsSchema, mulmoImageAssetSchema, mulmoMermaidMediaSchema, mulmoTextSlideMediaSchema, mulmoMarkdownMediaSchema, mulmoImageMediaSchema, mulmoChartMediaSchema, mediaSourceSchema, mulmoSessionStateSchema, mulmoOpenAIImageModelSchema, mulmoGoogleImageModelSchema, mulmoGoogleMovieModelSchema, mulmoReplicateMovieModelSchema, mulmoImagePromptMediaSchema } from "./schema.js";
2
+ import { langSchema, localizedTextSchema, mulmoBeatSchema, mulmoScriptSchema, mulmoStudioSchema, mulmoStudioBeatSchema, mulmoStoryboardSchema, mulmoStoryboardSceneSchema, mulmoStudioMultiLingualSchema, mulmoStudioMultiLingualArraySchema, mulmoStudioMultiLingualDataSchema, mulmoStudioMultiLingualFileSchema, speakerDictionarySchema, mulmoImageParamsSchema, mulmoImageParamsImagesSchema, mulmoFillOptionSchema, mulmoMovieParamsSchema, textSlideParamsSchema, speechOptionsSchema, speakerDataSchema, mulmoCanvasDimensionSchema, mulmoPromptTemplateSchema, mulmoPromptTemplateFileSchema, text2ImageProviderSchema, text2HtmlImageProviderSchema, text2MovieProviderSchema, text2SpeechProviderSchema, mulmoPresentationStyleSchema, multiLingualTextsSchema, mulmoImageAssetSchema, mulmoMermaidMediaSchema, mulmoTextSlideMediaSchema, mulmoMarkdownMediaSchema, mulmoImageMediaSchema, mulmoChartMediaSchema, mediaSourceSchema, mulmoSessionStateSchema, mulmoOpenAIImageModelSchema, mulmoGoogleImageModelSchema, mulmoGoogleMovieModelSchema, mulmoReplicateMovieModelSchema, mulmoImagePromptMediaSchema } from "./schema.js";
3
3
  import { pdf_modes, pdf_sizes, storyToScriptGenerateMode } from "../utils/const.js";
4
4
  import type { LLM } from "../utils/provider2agent.js";
5
5
  import { z } from "zod";
@@ -28,6 +28,7 @@ export type MulmoStudio = z.infer<typeof mulmoStudioSchema>;
28
28
  export type MulmoPromptTemplate = z.infer<typeof mulmoPromptTemplateSchema>;
29
29
  export type MulmoPromptTemplateFile = z.infer<typeof mulmoPromptTemplateFileSchema>;
30
30
  export type MulmoStudioMultiLingual = z.infer<typeof mulmoStudioMultiLingualSchema>;
31
+ export type MulmoStudioMultiLingualArray = z.infer<typeof mulmoStudioMultiLingualArraySchema>;
31
32
  export type MulmoStudioMultiLingualData = z.infer<typeof mulmoStudioMultiLingualDataSchema>;
32
33
  export type MulmoStudioMultiLingualFile = z.infer<typeof mulmoStudioMultiLingualFileSchema>;
33
34
  export type MultiLingualTexts = z.infer<typeof multiLingualTextsSchema>;
@@ -59,7 +60,7 @@ export type MulmoStudioContext = {
59
60
  force: boolean;
60
61
  sessionState: MulmoSessionState;
61
62
  presentationStyle: MulmoPresentationStyle;
62
- multiLingual: MulmoStudioMultiLingual;
63
+ multiLingual: MulmoStudioMultiLingualArray;
63
64
  };
64
65
  export type ScriptingParams = {
65
66
  urls: string[];
@@ -1,7 +1,8 @@
1
- import type { MulmoScript, MulmoPresentationStyle, MulmoStudioMultiLingual, FileObject } from "../types/type.js";
1
+ import type { MulmoStudioBeat, MulmoScript, MulmoPresentationStyle, MulmoStudioMultiLingual, FileObject } from "../types/type.js";
2
2
  export declare const createStudioData: (_mulmoScript: MulmoScript, fileName: string, videoCaptionLang?: string, presentationStyle?: MulmoPresentationStyle | null) => {
3
3
  beats: {
4
4
  duration?: number | undefined;
5
+ id?: string | undefined;
5
6
  startAt?: number | undefined;
6
7
  hash?: string | undefined;
7
8
  audioDuration?: number | undefined;
@@ -343,12 +344,13 @@ export declare const createStudioData: (_mulmoScript: MulmoScript, fileName: str
343
344
  filename: string;
344
345
  };
345
346
  export declare const fetchScript: (isHttpPath: boolean, mulmoFilePath: string, fileOrUrl: string) => Promise<MulmoScript | null>;
346
- export declare const getMultiLingual: (multilingualFilePath: string, studioBeatsLength: number) => MulmoStudioMultiLingual;
347
+ export declare const getMultiLingual: (multilingualFilePath: string, beats: MulmoStudioBeat[]) => MulmoStudioMultiLingual;
347
348
  export declare const getPresentationStyle: (presentationStylePath: string | undefined) => MulmoPresentationStyle | null;
348
349
  export declare const initializeContextFromFiles: (files: FileObject, raiseError: boolean, force?: boolean, captionLang?: string, targetLang?: string) => Promise<{
349
350
  studio: {
350
351
  beats: {
351
352
  duration?: number | undefined;
353
+ id?: string | undefined;
352
354
  startAt?: number | undefined;
353
355
  hash?: string | undefined;
354
356
  audioDuration?: number | undefined;
@@ -1,6 +1,7 @@
1
1
  import { GraphAILogger } from "graphai";
2
2
  import fs from "fs";
3
3
  import { readMulmoScriptFile, fetchMulmoScriptFile } from "./file.js";
4
+ import { beatId, multiLingualObjectToArray } from "./utils.js";
4
5
  import { mulmoStudioSchema, mulmoCaptionParamsSchema, mulmoPresentationStyleSchema } from "../types/schema.js";
5
6
  import { MulmoPresentationStyleMethods, MulmoScriptMethods, MulmoStudioMultiLingualMethod } from "../methods/index.js";
6
7
  const mulmoCredit = (speaker) => {
@@ -87,12 +88,16 @@ export const fetchScript = async (isHttpPath, mulmoFilePath, fileOrUrl) => {
87
88
  }
88
89
  return readMulmoScriptFile(mulmoFilePath, "ERROR: File does not exist " + mulmoFilePath)?.mulmoData ?? null;
89
90
  };
90
- export const getMultiLingual = (multilingualFilePath, studioBeatsLength) => {
91
+ export const getMultiLingual = (multilingualFilePath, beats) => {
91
92
  if (!fs.existsSync(multilingualFilePath)) {
92
- return [...Array(studioBeatsLength)].map(() => ({ multiLingualTexts: {} }));
93
+ return beats.reduce((tmp, beat, index) => {
94
+ const key = beatId(beat?.id, index);
95
+ tmp[key] = { multiLingualTexts: {} };
96
+ return tmp;
97
+ }, {});
93
98
  }
94
99
  const jsonData = readMulmoScriptFile(multilingualFilePath, "ERROR: File does not exist " + multilingualFilePath)?.mulmoData ?? null;
95
- return MulmoStudioMultiLingualMethod.validate(jsonData, studioBeatsLength);
100
+ return MulmoStudioMultiLingualMethod.validate(jsonData, beats);
96
101
  };
97
102
  export const getPresentationStyle = (presentationStylePath) => {
98
103
  if (!presentationStylePath) {
@@ -113,10 +118,10 @@ export const initializeContextFromFiles = async (files, raiseError, force, capti
113
118
  try {
114
119
  const presentationStyle = getPresentationStyle(presentationStylePath);
115
120
  const studio = createStudioData(mulmoScript, fileName, captionLang, presentationStyle);
116
- const multiLingual = getMultiLingual(outputMultilingualFilePath, studio.beats.length);
121
+ const multiLingual = getMultiLingual(outputMultilingualFilePath, studio.script.beats);
117
122
  return {
118
123
  studio,
119
- multiLingual,
124
+ multiLingual: multiLingualObjectToArray(multiLingual, studio.script.beats),
120
125
  fileDirs: files,
121
126
  presentationStyle: presentationStyle ?? studio.script,
122
127
  sessionState: initSessionState(),
@@ -51,8 +51,8 @@ export const FfmpegContextGenerateOutput = (context, output, options = []) => {
51
51
  GraphAILogger.error("Error occurred:", err);
52
52
  GraphAILogger.error("FFmpeg stdout:", stdout);
53
53
  GraphAILogger.error("FFmpeg stderr:", stderr);
54
- GraphAILogger.info("Video/Audio creation failed. An unexpected error occurred.");
55
- reject();
54
+ GraphAILogger.info("Video/Audio creation failed.", err.message);
55
+ reject(err);
56
56
  })
57
57
  .on("end", () => {
58
58
  resolve(0);
@@ -1,5 +1,5 @@
1
1
  import type { ConfigDataDictionary, DefaultConfigData } from "graphai";
2
- import { MulmoBeat, MulmoStudioMultiLingualData } from "../types/index.js";
2
+ import { MulmoBeat, MulmoStudioBeat, MulmoStudioMultiLingual, MulmoStudioMultiLingualData } from "../types/index.js";
3
3
  import type { LLM } from "./provider2agent.js";
4
4
  export declare const llmPair: (_llm?: LLM, _model?: string) => {
5
5
  agent: "mediaMockAgent" | "openAIAgent" | "anthropicAgent" | "geminiAgent" | "groqAgent";
@@ -19,4 +19,16 @@ type CleanableObject = {
19
19
  [key: string]: CleanableValue;
20
20
  };
21
21
  export declare const deepClean: <T extends CleanableValue>(input: T) => T | undefined;
22
+ export declare const beatId: (id: string | undefined, index: number) => string;
23
+ export declare const multiLingualObjectToArray: (multiLingual: MulmoStudioMultiLingual | undefined, beats: MulmoStudioBeat[]) => {
24
+ multiLingualTexts: Record<string, {
25
+ text: string;
26
+ lang: string;
27
+ cacheKey: string;
28
+ texts?: string[] | undefined;
29
+ ttsTexts?: string[] | undefined;
30
+ duration?: number | undefined;
31
+ }>;
32
+ cacheKey?: string | undefined;
33
+ }[];
22
34
  export {};
@@ -117,3 +117,16 @@ export const deepClean = (input) => {
117
117
  }
118
118
  return input;
119
119
  };
120
+ export const beatId = (id, index) => {
121
+ const key = id ?? `__index__${index}`;
122
+ return key;
123
+ };
124
+ export const multiLingualObjectToArray = (multiLingual, beats) => {
125
+ return beats.map((beat, index) => {
126
+ const key = beatId(beat?.id, index);
127
+ if (multiLingual?.[key]) {
128
+ return multiLingual[key];
129
+ }
130
+ return { multiLingualTexts: {} };
131
+ });
132
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mulmocast",
3
- "version": "1.2.7",
3
+ "version": "1.2.9",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "lib/index.node.js",
@@ -77,9 +77,9 @@
77
77
  "@graphai/stream_agent_filter": "^2.0.2",
78
78
  "@graphai/vanilla": "^2.0.12",
79
79
  "@graphai/vanilla_node_agents": "^2.0.4",
80
- "@inquirer/input": "^4.2.1",
81
- "@inquirer/select": "^4.3.1",
82
- "@modelcontextprotocol/sdk": "^1.17.3",
80
+ "@inquirer/input": "^4.2.2",
81
+ "@inquirer/select": "^4.3.2",
82
+ "@modelcontextprotocol/sdk": "^1.17.4",
83
83
  "@tavily/core": "^0.5.11",
84
84
  "canvas": "^3.2.0",
85
85
  "clipboardy": "^4.0.0",
@@ -101,15 +101,15 @@
101
101
  "@receptron/test_utils": "^2.0.3",
102
102
  "@types/fluent-ffmpeg": "^2.1.26",
103
103
  "@types/yargs": "^17.0.33",
104
- "eslint": "^9.33.0",
104
+ "eslint": "^9.34.0",
105
105
  "eslint-config-prettier": "^10.1.8",
106
106
  "eslint-plugin-prettier": "^5.5.4",
107
- "eslint-plugin-sonarjs": "^3.0.4",
107
+ "eslint-plugin-sonarjs": "^3.0.5",
108
108
  "prettier": "^3.6.2",
109
109
  "ts-node": "^10.9.2",
110
- "tsx": "^4.20.4",
110
+ "tsx": "^4.20.5",
111
111
  "typescript": "^5.9.2",
112
- "typescript-eslint": "^8.40.0"
112
+ "typescript-eslint": "^8.41.0"
113
113
  },
114
114
  "engines": {
115
115
  "node": ">=18.0.0"
@@ -18,10 +18,12 @@
18
18
  "lang": "en",
19
19
  "beats": [
20
20
  {
21
+ "id": "beat1",
21
22
  "speaker": "Host",
22
23
  "text": "Welcome to Mulmocast Tech Insights."
23
24
  },
24
25
  {
26
+ "id": "beat2",
25
27
  "speaker": "Host",
26
28
  "text": "AI-2028 is a project from the AI Futures Project."
27
29
  }
@@ -0,0 +1,50 @@
1
+ {
2
+ "$mulmocast": {
3
+ "version": "1.1",
4
+ "credit": "closing"
5
+ },
6
+ "canvasSize": {
7
+ "width": 1024,
8
+ "height": 1
9
+ },
10
+ "speechParams": {
11
+ "speakers": {
12
+ "Presenter": {
13
+ "displayName": {
14
+ "en": "Presenter"
15
+ },
16
+ "voiceId": "shimmer"
17
+ }
18
+ }
19
+ },
20
+ "imageParams": {
21
+ "provider": "openai",
22
+ "quality": "low"
23
+ },
24
+ "movieParams": {
25
+ "provider": "replicate"
26
+ },
27
+ "soundEffectParams": {
28
+ "provider": "replicate"
29
+ },
30
+ "audioParams": {
31
+ "padding": 0.3,
32
+ "introPadding": 1,
33
+ "closingPadding": 0.8,
34
+ "outroPadding": 1,
35
+ "bgmVolume": 0.2,
36
+ "audioVolume": 1,
37
+ "suppressSpeech": false
38
+ },
39
+ "title": "1024 x 1",
40
+ "description": "mulmocast",
41
+ "lang": "en",
42
+ "beats": [
43
+ {
44
+ "speaker": "Presenter",
45
+ "text": "Hello World",
46
+ "id": "afbfa590-b787-472b-a250-fc9e9bda4610",
47
+ "imagePrompt": "A dog and a cat"
48
+ }
49
+ ]
50
+ }