mulmocast 1.2.37 → 1.2.39

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.
@@ -250,9 +250,10 @@ export const generateBeatAudio = async (index, context, args) => {
250
250
  });
251
251
  }
252
252
  await graph.run();
253
+ MulmoStudioContextMethods.setSessionState(context, "audio", false, true);
253
254
  }
254
- finally {
255
- MulmoStudioContextMethods.setSessionState(context, "audio", false);
255
+ catch (__error) {
256
+ MulmoStudioContextMethods.setSessionState(context, "audio", false, false);
256
257
  }
257
258
  };
258
259
  export const audio = async (context, args) => {
@@ -283,12 +284,12 @@ export const audio = async (context, args) => {
283
284
  }
284
285
  const result = await graph.run();
285
286
  writingMessage(audioCombinedFilePath);
286
- MulmoStudioContextMethods.setSessionState(context, "audio", false);
287
+ MulmoStudioContextMethods.setSessionState(context, "audio", false, true);
287
288
  writingMessage(audioArtifactFilePath);
288
289
  return result.combineFiles;
289
290
  }
290
291
  catch (__error) {
291
- MulmoStudioContextMethods.setSessionState(context, "audio", false);
292
+ MulmoStudioContextMethods.setSessionState(context, "audio", false, false);
292
293
  throw __error;
293
294
  }
294
295
  };
@@ -86,9 +86,10 @@ export const captions = async (context, args) => {
86
86
  });
87
87
  }
88
88
  await graph.run();
89
+ MulmoStudioContextMethods.setSessionState(context, "caption", false, true);
89
90
  }
90
- finally {
91
- MulmoStudioContextMethods.setSessionState(context, "caption", false);
91
+ catch (__error) {
92
+ MulmoStudioContextMethods.setSessionState(context, "caption", false, false);
92
93
  }
93
94
  }
94
95
  return context;
@@ -77,8 +77,9 @@ export const html = async (context, imageWidth) => {
77
77
  try {
78
78
  MulmoStudioContextMethods.setSessionState(context, "html", true);
79
79
  await generateHtml(context, imageWidth);
80
+ MulmoStudioContextMethods.setSessionState(context, "html", false, true);
80
81
  }
81
- finally {
82
- MulmoStudioContextMethods.setSessionState(context, "html", false);
82
+ catch (__error) {
83
+ MulmoStudioContextMethods.setSessionState(context, "html", false, false);
83
84
  }
84
85
  };
@@ -272,6 +272,7 @@ export declare const beat_graph_data: {
272
272
  movieFile: string;
273
273
  imageFile: string;
274
274
  soundEffectFile: string;
275
+ index: number;
275
276
  }) => Promise<{
276
277
  hasMovieAudio: boolean;
277
278
  }>;
@@ -280,6 +281,7 @@ export declare const beat_graph_data: {
280
281
  movieFile: string;
281
282
  imageFile: string;
282
283
  soundEffectFile: string;
284
+ index: string;
283
285
  };
284
286
  };
285
287
  soundEffectGenerator: {
@@ -195,14 +195,28 @@ export const beat_graph_data = {
195
195
  // no need to check if the file exists (ffmpegGetMediaDuration will check it if it is local file)
196
196
  return { hasMovieAudio: false };
197
197
  }
198
- const { hasAudio } = await ffmpegGetMediaDuration(sourceFile);
199
- return { hasMovieAudio: hasAudio };
198
+ try {
199
+ const { hasAudio } = await ffmpegGetMediaDuration(sourceFile);
200
+ return { hasMovieAudio: hasAudio };
201
+ }
202
+ catch (error) {
203
+ GraphAILogger.error(error);
204
+ throw new Error("audioChecker: ffmpegGetMediaDuration error.", {
205
+ cause: {
206
+ type: "FileNotExist",
207
+ action: "images",
208
+ agentName: "audioChecker",
209
+ beat_index: namedInputs.index,
210
+ },
211
+ });
212
+ }
200
213
  },
201
214
  inputs: {
202
215
  onComplete: [":movieGenerator", ":htmlImageGenerator", ":soundEffectGenerator"],
203
216
  movieFile: ":preprocessor.movieFile",
204
217
  imageFile: ":preprocessor.imagePath",
205
218
  soundEffectFile: ":preprocessor.soundEffectFile",
219
+ index: ":__mapIndex",
206
220
  },
207
221
  },
208
222
  soundEffectGenerator: {
@@ -425,11 +439,11 @@ export const images = async (context, args) => {
425
439
  try {
426
440
  MulmoStudioContextMethods.setSessionState(context, "image", true);
427
441
  const newContext = await generateImages(context, args);
428
- MulmoStudioContextMethods.setSessionState(context, "image", false);
442
+ MulmoStudioContextMethods.setSessionState(context, "image", false, true);
429
443
  return newContext;
430
444
  }
431
445
  catch (error) {
432
- MulmoStudioContextMethods.setSessionState(context, "image", false);
446
+ MulmoStudioContextMethods.setSessionState(context, "image", false, false);
433
447
  throw error;
434
448
  }
435
449
  };
@@ -54,8 +54,9 @@ export const markdown = async (context, imageWidth) => {
54
54
  try {
55
55
  MulmoStudioContextMethods.setSessionState(context, "markdown", true);
56
56
  await generateMarkdown(context, imageWidth);
57
+ MulmoStudioContextMethods.setSessionState(context, "markdown", false, true);
57
58
  }
58
- finally {
59
- MulmoStudioContextMethods.setSessionState(context, "markdown", false);
59
+ catch (__error) {
60
+ MulmoStudioContextMethods.setSessionState(context, "markdown", false, false);
60
61
  }
61
62
  };
@@ -251,8 +251,9 @@ export const movie = async (context) => {
251
251
  if (await createVideo(audioArtifactFilePath, outputVideoPath, context)) {
252
252
  writingMessage(outputVideoPath);
253
253
  }
254
+ MulmoStudioContextMethods.setSessionState(context, "video", false, true);
254
255
  }
255
- finally {
256
- MulmoStudioContextMethods.setSessionState(context, "video", false);
256
+ catch (__error) {
257
+ MulmoStudioContextMethods.setSessionState(context, "video", false, false);
257
258
  }
258
259
  };
@@ -159,8 +159,9 @@ export const pdf = async (context, pdfMode, pdfSize) => {
159
159
  try {
160
160
  MulmoStudioContextMethods.setSessionState(context, "pdf", true);
161
161
  await generatePDF(context, pdfMode, pdfSize);
162
+ MulmoStudioContextMethods.setSessionState(context, "pdf", false, true);
162
163
  }
163
- finally {
164
- MulmoStudioContextMethods.setSessionState(context, "pdf", false);
164
+ catch (__error) {
165
+ MulmoStudioContextMethods.setSessionState(context, "pdf", false, false);
165
166
  }
166
167
  };
@@ -292,9 +292,10 @@ export const translate = async (context, args) => {
292
292
  if (results.mergeStudioResult) {
293
293
  context.multiLingual = multiLingualObjectToArray(results?.mergeStudioResult?.multiLingual, context.studio.script.beats);
294
294
  }
295
+ MulmoStudioContextMethods.setSessionState(context, "multiLingual", false, true);
295
296
  }
296
- finally {
297
- MulmoStudioContextMethods.setSessionState(context, "multiLingual", false);
297
+ catch (__error) {
298
+ MulmoStudioContextMethods.setSessionState(context, "multiLingual", false, false);
298
299
  }
299
300
  return context;
300
301
  };
@@ -13,7 +13,7 @@ export declare const MulmoStudioContextMethods: {
13
13
  getOutDirPath(context: MulmoStudioContext): string;
14
14
  getFileName(context: MulmoStudioContext): string;
15
15
  getCaption(context: MulmoStudioContext): string | undefined;
16
- setSessionState(context: MulmoStudioContext, sessionType: SessionType, value: boolean): void;
16
+ setSessionState(context: MulmoStudioContext, sessionType: SessionType, value: boolean, result?: boolean): void;
17
17
  setBeatSessionState(context: MulmoStudioContext, sessionType: BeatSessionType | undefined, index: number, id: string | undefined, value: boolean): void;
18
18
  needTranslate(context: MulmoStudioContext, includeCaption?: boolean): boolean | "" | undefined;
19
19
  getIntroPadding(context: MulmoStudioContext): number;
@@ -14,12 +14,17 @@ export const addSessionProgressCallback = (cb) => {
14
14
  export const removeSessionProgressCallback = (cb) => {
15
15
  sessionProgressCallbacks.delete(cb);
16
16
  };
17
- const notifyStateChange = (context, sessionType) => {
17
+ const notifyStateChange = (context, sessionType, result) => {
18
18
  const inSession = context.sessionState.inSession[sessionType] ?? false;
19
19
  const prefix = inSession ? "<" : " >";
20
20
  GraphAILogger.info(`${prefix} ${sessionType}`);
21
21
  for (const callback of sessionProgressCallbacks) {
22
- callback({ kind: "session", sessionType, inSession });
22
+ if (result !== undefined) {
23
+ callback({ kind: "session", sessionType, inSession, result });
24
+ }
25
+ else {
26
+ callback({ kind: "session", sessionType, inSession });
27
+ }
23
28
  }
24
29
  };
25
30
  const notifyBeatStateChange = (context, sessionType, id) => {
@@ -50,9 +55,9 @@ export const MulmoStudioContextMethods = {
50
55
  getCaption(context) {
51
56
  return context.studio.script.captionParams?.lang;
52
57
  },
53
- setSessionState(context, sessionType, value) {
58
+ setSessionState(context, sessionType, value, result) {
54
59
  context.sessionState.inSession[sessionType] = value;
55
- notifyStateChange(context, sessionType);
60
+ notifyStateChange(context, sessionType, result);
56
61
  },
57
62
  setBeatSessionState(context, sessionType, index, id, value) {
58
63
  if (!sessionType) {
@@ -92,6 +92,7 @@ export type SessionProgressEvent = {
92
92
  kind: "session";
93
93
  sessionType: SessionType;
94
94
  inSession: boolean;
95
+ result?: boolean;
95
96
  } | {
96
97
  kind: "beat";
97
98
  sessionType: BeatSessionType;
@@ -63,11 +63,18 @@ export const FfmpegContextGenerateOutput = (context, output, options = []) => {
63
63
  export const ffmpegGetMediaDuration = (filePath) => {
64
64
  return new Promise((resolve, reject) => {
65
65
  // Only check file existence for local paths, not URLs
66
- if (!filePath.startsWith("http://") && !filePath.startsWith("https://") && !fs.existsSync(filePath)) {
67
- // NOTE: We don't reject here for scripts/test/test_hello_image.json, which uses mock image agent.
68
- // reject(new Error(`File not found: ${filePath}`));
69
- resolve({ duration: 0, hasAudio: false });
70
- return;
66
+ if (!filePath.startsWith("http://") && !filePath.startsWith("https://")) {
67
+ if (!fs.existsSync(filePath)) {
68
+ // NOTE: We don't reject here for scripts/test/test_hello_image.json, which uses mock image agent.
69
+ // reject(new Error(`File not found: ${filePath}`));
70
+ resolve({ duration: 0, hasAudio: false });
71
+ return;
72
+ }
73
+ const stat = fs.statSync(filePath);
74
+ if (!stat.isFile()) {
75
+ reject("ffmpegGetMediaDuration: path is not file");
76
+ return;
77
+ }
71
78
  }
72
79
  ffmpeg.ffprobe(filePath, (err, metadata) => {
73
80
  if (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mulmocast",
3
- "version": "1.2.37",
3
+ "version": "1.2.39",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "lib/index.node.js",