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.
- package/lib/actions/audio.js +5 -4
- package/lib/actions/captions.js +3 -2
- package/lib/actions/html.js +3 -2
- package/lib/actions/images.d.ts +2 -0
- package/lib/actions/images.js +18 -4
- package/lib/actions/markdown.js +3 -2
- package/lib/actions/movie.js +3 -2
- package/lib/actions/pdf.js +3 -2
- package/lib/actions/translate.js +3 -2
- package/lib/methods/mulmo_studio_context.d.ts +1 -1
- package/lib/methods/mulmo_studio_context.js +9 -4
- package/lib/types/type.d.ts +1 -0
- package/lib/utils/ffmpeg_utils.js +12 -5
- package/package.json +1 -1
package/lib/actions/audio.js
CHANGED
|
@@ -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
|
-
|
|
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
|
};
|
package/lib/actions/captions.js
CHANGED
|
@@ -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
|
-
|
|
91
|
-
MulmoStudioContextMethods.setSessionState(context, "caption", false);
|
|
91
|
+
catch (__error) {
|
|
92
|
+
MulmoStudioContextMethods.setSessionState(context, "caption", false, false);
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
return context;
|
package/lib/actions/html.js
CHANGED
|
@@ -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
|
-
|
|
82
|
-
MulmoStudioContextMethods.setSessionState(context, "html", false);
|
|
82
|
+
catch (__error) {
|
|
83
|
+
MulmoStudioContextMethods.setSessionState(context, "html", false, false);
|
|
83
84
|
}
|
|
84
85
|
};
|
package/lib/actions/images.d.ts
CHANGED
|
@@ -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: {
|
package/lib/actions/images.js
CHANGED
|
@@ -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
|
-
|
|
199
|
-
|
|
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
|
};
|
package/lib/actions/markdown.js
CHANGED
|
@@ -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
|
-
|
|
59
|
-
MulmoStudioContextMethods.setSessionState(context, "markdown", false);
|
|
59
|
+
catch (__error) {
|
|
60
|
+
MulmoStudioContextMethods.setSessionState(context, "markdown", false, false);
|
|
60
61
|
}
|
|
61
62
|
};
|
package/lib/actions/movie.js
CHANGED
|
@@ -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
|
-
|
|
256
|
-
MulmoStudioContextMethods.setSessionState(context, "video", false);
|
|
256
|
+
catch (__error) {
|
|
257
|
+
MulmoStudioContextMethods.setSessionState(context, "video", false, false);
|
|
257
258
|
}
|
|
258
259
|
};
|
package/lib/actions/pdf.js
CHANGED
|
@@ -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
|
-
|
|
164
|
-
MulmoStudioContextMethods.setSessionState(context, "pdf", false);
|
|
164
|
+
catch (__error) {
|
|
165
|
+
MulmoStudioContextMethods.setSessionState(context, "pdf", false, false);
|
|
165
166
|
}
|
|
166
167
|
};
|
package/lib/actions/translate.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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) {
|
package/lib/types/type.d.ts
CHANGED
|
@@ -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://")
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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) {
|