mulmocast 1.1.1 → 1.1.3

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.
@@ -28,6 +28,7 @@ export declare const imagePreprocessAgent: (namedInputs: {
28
28
  defaultModel: string;
29
29
  };
30
30
  audioFile?: string;
31
+ beatDuration?: number;
31
32
  htmlPrompt?: undefined;
32
33
  htmlPath?: undefined;
33
34
  htmlImageSystemPrompt?: undefined;
@@ -65,6 +66,7 @@ export declare const imagePreprocessAgent: (namedInputs: {
65
66
  defaultModel: string;
66
67
  };
67
68
  audioFile?: string;
69
+ beatDuration?: number;
68
70
  htmlPrompt?: undefined;
69
71
  htmlPath?: undefined;
70
72
  htmlImageSystemPrompt?: undefined;
@@ -105,6 +107,7 @@ export declare const imagePreprocessAgent: (namedInputs: {
105
107
  defaultModel: string;
106
108
  };
107
109
  audioFile?: string;
110
+ beatDuration?: number;
108
111
  htmlPrompt?: undefined;
109
112
  htmlPath?: undefined;
110
113
  htmlImageSystemPrompt?: undefined;
@@ -11,6 +11,7 @@ const htmlStyle = (context, beat) => {
11
11
  };
12
12
  export const imagePreprocessAgent = async (namedInputs) => {
13
13
  const { context, beat, index, imageRefs } = namedInputs;
14
+ const studioBeat = context.studio.beats[index];
14
15
  const imagePath = getBeatPngImagePath(context, index);
15
16
  if (beat.htmlPrompt) {
16
17
  const htmlPrompt = MulmoBeatMethods.getHtmlPrompt(beat);
@@ -22,6 +23,7 @@ export const imagePreprocessAgent = async (namedInputs) => {
22
23
  const returnValue = {
23
24
  imageParams: imageAgentInfo.imageParams,
24
25
  movieFile: beat.moviePrompt ? moviePaths.movieFile : undefined,
26
+ beatDuration: beat.duration ?? studioBeat?.duration,
25
27
  };
26
28
  if (beat.soundEffectPrompt) {
27
29
  returnValue.soundEffectAgentInfo = MulmoPresentationStyleMethods.getSoundEffectAgentInfo(context.presentationStyle, beat);
@@ -35,7 +37,7 @@ export const imagePreprocessAgent = async (namedInputs) => {
35
37
  returnValue.lipSyncModel = beat.lipSyncParams?.model ?? context.presentationStyle.lipSyncParams?.model ?? returnValue.lipSyncAgentInfo.defaultModel;
36
38
  returnValue.lipSyncFile = moviePaths.lipSyncFile;
37
39
  // Audio file will be set from the beat's audio file when available
38
- returnValue.audioFile = context.studio.beats[index]?.audioFile;
40
+ returnValue.audioFile = studioBeat?.audioFile;
39
41
  }
40
42
  if (beat.image) {
41
43
  const plugin = MulmoBeatMethods.getPlugin(beat);
@@ -155,7 +155,7 @@ const beat_graph_data = {
155
155
  },
156
156
  params: {
157
157
  model: ":preprocessor.movieAgentInfo.movieParams.model",
158
- duration: ":beat.duration",
158
+ duration: ":preprocessor.beatDuration",
159
159
  canvasSize: ":context.presentationStyle.canvasSize",
160
160
  },
161
161
  },
@@ -175,8 +175,8 @@ const beat_graph_data = {
175
175
  },
176
176
  audioChecker: {
177
177
  agent: async (namedInputs) => {
178
+ // NOTE: We intentinonally don't check lipSyncFile here.
178
179
  if (namedInputs.soundEffectFile) {
179
- // NOTE: We intentinonally don't check lipSyncFile here.
180
180
  return { hasMovieAudio: true };
181
181
  }
182
182
  const sourceFile = namedInputs.movieFile || namedInputs.imageFile;
@@ -187,7 +187,7 @@ const beat_graph_data = {
187
187
  return { hasMovieAudio: hasAudio };
188
188
  },
189
189
  inputs: {
190
- onComplete: [":movieGenerator", ":htmlImageGenerator", ":soundEffectGenerator"], // to wait for movieGenerator, htmlImageGenerator, soundEffectGenerator, and lipSyncGenerator to finish
190
+ onComplete: [":movieGenerator", ":htmlImageGenerator", ":soundEffectGenerator"],
191
191
  movieFile: ":preprocessor.movieFile",
192
192
  imageFile: ":preprocessor.imagePath",
193
193
  soundEffectFile: ":preprocessor.soundEffectFile",
@@ -203,7 +203,7 @@ const beat_graph_data = {
203
203
  soundEffectFile: ":preprocessor.soundEffectFile",
204
204
  params: {
205
205
  model: ":preprocessor.soundEffectModel",
206
- duration: ":beat.duration",
206
+ duration: ":preprocessor.beatDuration",
207
207
  },
208
208
  cache: {
209
209
  force: [":context.force"],
@@ -225,7 +225,7 @@ const beat_graph_data = {
225
225
  lipSyncFile: ":preprocessor.lipSyncFile",
226
226
  params: {
227
227
  model: ":preprocessor.lipSyncModel",
228
- duration: ":beat.duration",
228
+ duration: ":preprocessor.beatDuration",
229
229
  },
230
230
  cache: {
231
231
  force: [":context.force"],
@@ -17,12 +17,27 @@ export const lipSyncReplicateAgent = async ({ namedInputs, params, config, }) =>
17
17
  const videoUri = `data:video/quicktime;base64,${videoBuffer.toString("base64")}`;
18
18
  const audioUri = `data:audio/wav;base64,${audioBuffer.toString("base64")}`;
19
19
  const input = {
20
- video: videoUri,
21
- audio: audioUri,
22
- duration: params.duration,
20
+ video: undefined,
21
+ video_input: undefined,
22
+ video_url: undefined,
23
+ audio: undefined,
24
+ audio_input: undefined,
25
+ audio_file: undefined,
23
26
  };
27
+ const modelParams = provider2LipSyncAgent.replicate.modelParams[model];
28
+ if (!modelParams) {
29
+ throw new Error(`Model ${model} is not supported`);
30
+ }
31
+ const videoParam = modelParams.video;
32
+ const audioParam = modelParams.audio;
33
+ if (videoParam === "video" || videoParam === "video_input" || videoParam === "video_url") {
34
+ input[videoParam] = videoUri;
35
+ }
36
+ if (audioParam === "audio" || audioParam === "audio_input" || audioParam === "audio_file") {
37
+ input[audioParam] = audioUri;
38
+ }
39
+ const model_identifier = provider2LipSyncAgent.replicate.modelParams[model]?.identifier ?? model;
24
40
  try {
25
- const model_identifier = provider2LipSyncAgent.replicate.modelParams[model]?.identifier ?? model;
26
41
  const output = await replicate.run(model_identifier, {
27
42
  input,
28
43
  });
@@ -71,7 +71,16 @@ export const movieReplicateAgent = async ({ namedInputs, params, config, }) => {
71
71
  if (!provider2MovieAgent.replicate.modelParams[model]) {
72
72
  throw new Error(`Model ${model} is not supported`);
73
73
  }
74
- const duration = params.duration ?? provider2MovieAgent.replicate.modelParams[model].durations[0] ?? 5;
74
+ const duration = (() => {
75
+ const durations = provider2MovieAgent.replicate.modelParams[model].durations;
76
+ if (params.duration) {
77
+ const largerDurations = durations.filter((d) => d >= params.duration);
78
+ return largerDurations.length > 0 ? largerDurations[0] : durations[durations.length - 1];
79
+ }
80
+ else {
81
+ return durations[0];
82
+ }
83
+ })();
75
84
  if (!provider2MovieAgent.replicate.modelParams[model].durations.includes(duration)) {
76
85
  throw new Error(`Duration ${duration} is not supported for model ${model}. Supported durations: ${provider2MovieAgent.replicate.modelParams[model].durations.join(", ")}`);
77
86
  }
@@ -1,5 +1,5 @@
1
- import { getAvailableTemplates } from "../../../../utils/file.js";
2
- const availableTemplateNames = getAvailableTemplates().map((template) => template.filename);
1
+ import { getAvailablePromptTemplates } from "../../../../utils/file.js";
2
+ const availableTemplateNames = getAvailablePromptTemplates().map((template) => template.filename);
3
3
  export const builder = (yargs) => {
4
4
  return yargs.option("t", {
5
5
  alias: "template",
@@ -1,6 +1,6 @@
1
1
  import { llm } from "../../../../utils/provider2agent.js";
2
- import { getAvailableTemplates } from "../../../../utils/file.js";
3
- const availableTemplateNames = getAvailableTemplates().map((template) => template.filename);
2
+ import { getAvailablePromptTemplates } from "../../../../utils/file.js";
3
+ const availableTemplateNames = getAvailablePromptTemplates().map((template) => template.filename);
4
4
  export const builder = (yargs) => {
5
5
  return yargs
6
6
  .option("o", {
@@ -1,7 +1,7 @@
1
- import { getAvailableTemplates } from "../../../../utils/file.js";
1
+ import { getAvailablePromptTemplates } from "../../../../utils/file.js";
2
2
  import { llm } from "../../../../utils/provider2agent.js";
3
3
  import { storyToScriptGenerateMode } from "../../../../utils/const.js";
4
- const availableTemplateNames = getAvailableTemplates().map((template) => template.filename);
4
+ const availableTemplateNames = getAvailablePromptTemplates().map((template) => template.filename);
5
5
  export const builder = (yargs) => {
6
6
  return yargs
7
7
  .option("o", {