mulmocast 0.0.5 → 0.0.7
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 +294 -39
- package/assets/audio/silent60sec.mp3 +0 -0
- package/assets/html/caption.html +45 -0
- package/assets/html/chart.html +1 -1
- package/assets/html/mermaid.html +6 -2
- package/assets/html/tailwind.html +13 -0
- package/assets/templates/business.json +2 -128
- package/assets/templates/children_book.json +1 -128
- package/assets/templates/coding.json +2 -136
- package/assets/templates/comic_strips.json +6 -0
- package/assets/templates/ghibli_strips.json +6 -0
- package/assets/templates/sensei_and_taro.json +1 -118
- package/lib/actions/audio.js +62 -39
- package/lib/actions/captions.d.ts +2 -0
- package/lib/actions/captions.js +75 -0
- package/lib/actions/images.js +34 -13
- package/lib/actions/index.d.ts +1 -0
- package/lib/actions/index.js +1 -0
- package/lib/actions/movie.js +102 -101
- package/lib/actions/pdf.js +26 -6
- package/lib/actions/translate.js +60 -39
- package/lib/agents/add_bgm_agent.js +15 -39
- package/lib/agents/combine_audio_files_agent.js +53 -35
- package/lib/agents/index.d.ts +2 -3
- package/lib/agents/index.js +2 -3
- package/lib/agents/tts_google_agent.d.ts +4 -0
- package/lib/agents/tts_google_agent.js +51 -0
- package/lib/agents/validate_schema_agent.d.ts +19 -0
- package/lib/agents/validate_schema_agent.js +36 -0
- package/lib/cli/args.d.ts +2 -0
- package/lib/cli/args.js +9 -2
- package/lib/cli/bin.d.ts +3 -0
- package/lib/cli/bin.js +38 -0
- package/lib/cli/cli.js +34 -7
- package/lib/cli/commands/audio/builder.d.ts +14 -0
- package/lib/cli/commands/audio/builder.js +6 -0
- package/lib/cli/commands/audio/handler.d.ts +4 -0
- package/lib/cli/commands/audio/handler.js +7 -0
- package/lib/cli/commands/audio/index.d.ts +4 -0
- package/lib/cli/commands/audio/index.js +4 -0
- package/lib/cli/commands/image/builder.d.ts +14 -0
- package/lib/cli/commands/image/builder.js +6 -0
- package/lib/cli/commands/image/handler.d.ts +4 -0
- package/lib/cli/commands/image/handler.js +7 -0
- package/lib/cli/commands/image/index.d.ts +4 -0
- package/lib/cli/commands/image/index.js +4 -0
- package/lib/cli/commands/movie/builder.d.ts +18 -0
- package/lib/cli/commands/movie/builder.js +19 -0
- package/lib/cli/commands/movie/handler.d.ts +6 -0
- package/lib/cli/commands/movie/handler.js +12 -0
- package/lib/cli/commands/movie/index.d.ts +4 -0
- package/lib/cli/commands/movie/index.js +4 -0
- package/lib/cli/commands/pdf/builder.d.ts +18 -0
- package/lib/cli/commands/pdf/builder.js +19 -0
- package/lib/cli/commands/pdf/handler.d.ts +6 -0
- package/lib/cli/commands/pdf/handler.js +8 -0
- package/lib/cli/commands/pdf/index.d.ts +4 -0
- package/lib/cli/commands/pdf/index.js +4 -0
- package/lib/cli/commands/tool/index.d.ts +6 -0
- package/lib/cli/commands/tool/index.js +8 -0
- package/lib/cli/commands/tool/prompt/builder.d.ts +4 -0
- package/lib/cli/commands/tool/prompt/builder.js +11 -0
- package/lib/cli/commands/tool/prompt/handler.d.ts +4 -0
- package/lib/cli/commands/tool/prompt/handler.js +14 -0
- package/lib/cli/commands/tool/prompt/index.d.ts +4 -0
- package/lib/cli/commands/tool/prompt/index.js +4 -0
- package/lib/cli/commands/tool/schema/builder.d.ts +2 -0
- package/lib/cli/commands/tool/schema/builder.js +3 -0
- package/lib/cli/commands/tool/schema/handler.d.ts +2 -0
- package/lib/cli/commands/tool/schema/handler.js +12 -0
- package/lib/cli/commands/tool/schema/index.d.ts +4 -0
- package/lib/cli/commands/tool/schema/index.js +4 -0
- package/lib/cli/commands/tool/scripting/builder.d.ts +20 -0
- package/lib/cli/commands/tool/scripting/builder.js +63 -0
- package/lib/cli/commands/tool/scripting/handler.d.ts +13 -0
- package/lib/cli/commands/tool/scripting/handler.js +36 -0
- package/lib/cli/commands/tool/scripting/index.d.ts +4 -0
- package/lib/cli/commands/tool/scripting/index.js +4 -0
- package/lib/cli/commands/tool/story_to_script/builder.d.ts +20 -0
- package/lib/cli/commands/tool/story_to_script/builder.js +61 -0
- package/lib/cli/commands/tool/story_to_script/handler.d.ts +13 -0
- package/lib/cli/commands/tool/story_to_script/handler.js +36 -0
- package/lib/cli/commands/tool/story_to_script/index.d.ts +4 -0
- package/lib/cli/commands/tool/story_to_script/index.js +4 -0
- package/lib/cli/commands/translate/builder.d.ts +14 -0
- package/lib/cli/commands/translate/builder.js +5 -0
- package/lib/cli/commands/translate/handler.d.ts +4 -0
- package/lib/cli/commands/translate/handler.js +6 -0
- package/lib/cli/commands/translate/index.d.ts +4 -0
- package/lib/cli/commands/translate/index.js +4 -0
- package/lib/cli/common.d.ts +6 -2
- package/lib/cli/common.js +18 -7
- package/lib/cli/helpers.d.ts +38 -0
- package/lib/cli/helpers.js +115 -0
- package/lib/cli/tool-args.d.ts +1 -0
- package/lib/cli/tool-args.js +1 -1
- package/lib/cli/tool-cli.js +8 -0
- package/lib/methods/mulmo_script.d.ts +0 -1
- package/lib/methods/mulmo_script.js +4 -7
- package/lib/methods/mulmo_script_template.d.ts +2 -2
- package/lib/methods/mulmo_script_template.js +3 -13
- package/lib/methods/mulmo_studio.d.ts +8 -0
- package/lib/methods/mulmo_studio.js +24 -0
- package/lib/tools/create_mulmo_script_from_url.d.ts +1 -1
- package/lib/tools/create_mulmo_script_from_url.js +43 -14
- package/lib/tools/create_mulmo_script_interactively.d.ts +1 -1
- package/lib/tools/create_mulmo_script_interactively.js +21 -20
- package/lib/tools/dump_prompt.js +2 -0
- package/lib/tools/story_to_script.d.ts +12 -0
- package/lib/tools/story_to_script.js +275 -0
- package/lib/types/cli_types.d.ts +14 -0
- package/lib/types/cli_types.js +1 -0
- package/lib/types/schema.d.ts +637 -1766
- package/lib/types/schema.js +77 -8
- package/lib/types/type.d.ts +10 -3
- package/lib/utils/const.d.ts +5 -0
- package/lib/utils/const.js +5 -0
- package/lib/utils/ffmpeg_utils.d.ts +12 -0
- package/lib/utils/ffmpeg_utils.js +63 -0
- package/lib/utils/file.d.ts +8 -3
- package/lib/utils/file.js +40 -9
- package/lib/utils/filters.js +16 -11
- package/lib/utils/image_plugins/chart.js +6 -1
- package/lib/utils/image_plugins/html_tailwind.d.ts +3 -0
- package/lib/utils/image_plugins/html_tailwind.js +18 -0
- package/lib/utils/image_plugins/index.d.ts +2 -1
- package/lib/utils/image_plugins/index.js +2 -1
- package/lib/utils/image_plugins/mermaid.js +1 -1
- package/lib/utils/image_plugins/tailwind.d.ts +3 -0
- package/lib/utils/image_plugins/tailwind.js +18 -0
- package/lib/utils/image_plugins/text_slide.js +9 -2
- package/lib/utils/markdown.d.ts +1 -1
- package/lib/utils/markdown.js +8 -4
- package/lib/utils/preprocess.d.ts +40 -10
- package/lib/utils/preprocess.js +7 -2
- package/lib/utils/prompt.d.ts +16 -0
- package/lib/utils/prompt.js +74 -0
- package/lib/utils/utils.d.ts +10 -5
- package/lib/utils/utils.js +37 -17
- package/package.json +27 -23
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { getAvailableTemplates } from "../../../../utils/file.js";
|
|
2
|
+
import { llm } from "../../../../utils/utils.js";
|
|
3
|
+
import { storyToScriptGenerateMode } from "../../../../utils/const.js";
|
|
4
|
+
const availableTemplateNames = getAvailableTemplates().map((template) => template.filename);
|
|
5
|
+
export const builder = (yargs) => {
|
|
6
|
+
return yargs
|
|
7
|
+
.option("o", {
|
|
8
|
+
alias: "outdir",
|
|
9
|
+
description: "output dir",
|
|
10
|
+
demandOption: false,
|
|
11
|
+
type: "string",
|
|
12
|
+
})
|
|
13
|
+
.option("b", {
|
|
14
|
+
alias: "basedir",
|
|
15
|
+
description: "base dir",
|
|
16
|
+
demandOption: false,
|
|
17
|
+
type: "string",
|
|
18
|
+
})
|
|
19
|
+
.option("t", {
|
|
20
|
+
alias: "template",
|
|
21
|
+
description: "Template name to use",
|
|
22
|
+
demandOption: false,
|
|
23
|
+
choices: availableTemplateNames,
|
|
24
|
+
type: "string",
|
|
25
|
+
})
|
|
26
|
+
.option("s", {
|
|
27
|
+
alias: "script",
|
|
28
|
+
description: "script filename",
|
|
29
|
+
demandOption: false,
|
|
30
|
+
default: "script",
|
|
31
|
+
type: "string",
|
|
32
|
+
})
|
|
33
|
+
.option("beats_per_scene", {
|
|
34
|
+
description: "beats per scene",
|
|
35
|
+
demandOption: false,
|
|
36
|
+
default: 3,
|
|
37
|
+
type: "number",
|
|
38
|
+
})
|
|
39
|
+
.option("llm", {
|
|
40
|
+
description: "llm",
|
|
41
|
+
demandOption: false,
|
|
42
|
+
choices: llm,
|
|
43
|
+
type: "string",
|
|
44
|
+
})
|
|
45
|
+
.option("llm_model", {
|
|
46
|
+
description: "llm model",
|
|
47
|
+
demandOption: false,
|
|
48
|
+
type: "string",
|
|
49
|
+
})
|
|
50
|
+
.option("mode", {
|
|
51
|
+
description: "story to script generation mode",
|
|
52
|
+
demandOption: false,
|
|
53
|
+
choices: Object.values(storyToScriptGenerateMode),
|
|
54
|
+
default: storyToScriptGenerateMode.stepWise,
|
|
55
|
+
type: "string",
|
|
56
|
+
})
|
|
57
|
+
.positional("file", {
|
|
58
|
+
description: "story file path",
|
|
59
|
+
type: "string",
|
|
60
|
+
});
|
|
61
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ToolCliArgs } from "../../../../types/cli_types.js";
|
|
2
|
+
import { LLM } from "../../../../utils/utils.js";
|
|
3
|
+
export declare const handler: (argv: ToolCliArgs<{
|
|
4
|
+
o?: string;
|
|
5
|
+
b?: string;
|
|
6
|
+
t?: string;
|
|
7
|
+
s?: string;
|
|
8
|
+
beats_per_scene?: number;
|
|
9
|
+
file?: string;
|
|
10
|
+
llm?: LLM;
|
|
11
|
+
llm_model?: string;
|
|
12
|
+
mode?: string;
|
|
13
|
+
}>) => Promise<void>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { selectTemplate } from "../../../../utils/inquirer.js";
|
|
2
|
+
import { setGraphAILogger } from "../../../../cli/helpers.js";
|
|
3
|
+
import { storyToScript } from "../../../../tools/story_to_script.js";
|
|
4
|
+
import { mulmoStoryboardSchema } from "../../../../types/schema.js";
|
|
5
|
+
import { getBaseDirPath, getFullPath, readAndParseJson } from "../../../../utils/file.js";
|
|
6
|
+
import { outDirName } from "../../../../utils/const.js";
|
|
7
|
+
export const handler = async (argv) => {
|
|
8
|
+
const { v: verbose, s: filename, file, o: outdir, b: basedir, beats_per_scene, llm, llm_model, mode } = argv;
|
|
9
|
+
let { t: template } = argv;
|
|
10
|
+
const baseDirPath = getBaseDirPath(basedir);
|
|
11
|
+
const outDirPath = getFullPath(baseDirPath, outdir ?? outDirName);
|
|
12
|
+
if (!template) {
|
|
13
|
+
template = await selectTemplate();
|
|
14
|
+
}
|
|
15
|
+
setGraphAILogger(verbose, {
|
|
16
|
+
outdir: outDirPath,
|
|
17
|
+
basedir: baseDirPath,
|
|
18
|
+
template,
|
|
19
|
+
fileName: filename,
|
|
20
|
+
beatsPerScene: beats_per_scene,
|
|
21
|
+
storyFilePath: file,
|
|
22
|
+
llmAgent: llm,
|
|
23
|
+
llmModel: llm_model,
|
|
24
|
+
});
|
|
25
|
+
const parsedStory = readAndParseJson(file, mulmoStoryboardSchema);
|
|
26
|
+
await storyToScript({
|
|
27
|
+
story: parsedStory,
|
|
28
|
+
beatsPerScene: beats_per_scene,
|
|
29
|
+
templateName: template,
|
|
30
|
+
outdir: outDirPath,
|
|
31
|
+
fileName: filename,
|
|
32
|
+
llm,
|
|
33
|
+
llmModel: llm_model,
|
|
34
|
+
generateMode: mode,
|
|
35
|
+
});
|
|
36
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Argv } from "yargs";
|
|
2
|
+
export declare const builder: (yargs: Argv) => Argv<import("yargs").Omit<{
|
|
3
|
+
o: string | undefined;
|
|
4
|
+
} & {
|
|
5
|
+
b: string | undefined;
|
|
6
|
+
} & {
|
|
7
|
+
l: string | undefined;
|
|
8
|
+
} & {
|
|
9
|
+
f: boolean;
|
|
10
|
+
} & {
|
|
11
|
+
file: string | undefined;
|
|
12
|
+
}, "file"> & {
|
|
13
|
+
file: string | undefined;
|
|
14
|
+
}>;
|
package/lib/cli/common.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type { Argv } from "yargs";
|
|
2
2
|
export declare const commonOptions: (yargs: Argv) => Argv<{
|
|
3
|
-
v: boolean;
|
|
4
|
-
} & {
|
|
5
3
|
o: string | undefined;
|
|
6
4
|
} & {
|
|
7
5
|
b: string | undefined;
|
|
6
|
+
} & {
|
|
7
|
+
l: string | undefined;
|
|
8
|
+
} & {
|
|
9
|
+
f: boolean;
|
|
10
|
+
} & {
|
|
11
|
+
file: string | undefined;
|
|
8
12
|
}>;
|
package/lib/cli/common.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
+
import { languages } from "../utils/const.js";
|
|
1
2
|
export const commonOptions = (yargs) => {
|
|
2
3
|
return yargs
|
|
3
|
-
.option("v", {
|
|
4
|
-
alias: "verbose",
|
|
5
|
-
describe: "verbose log",
|
|
6
|
-
demandOption: true,
|
|
7
|
-
default: false,
|
|
8
|
-
type: "boolean",
|
|
9
|
-
})
|
|
10
4
|
.option("o", {
|
|
11
5
|
alias: "outdir",
|
|
12
6
|
description: "output dir",
|
|
@@ -18,5 +12,22 @@ export const commonOptions = (yargs) => {
|
|
|
18
12
|
description: "base dir",
|
|
19
13
|
demandOption: false,
|
|
20
14
|
type: "string",
|
|
15
|
+
})
|
|
16
|
+
.option("l", {
|
|
17
|
+
alias: "lang",
|
|
18
|
+
description: "target language",
|
|
19
|
+
choices: languages,
|
|
20
|
+
demandOption: false,
|
|
21
|
+
type: "string",
|
|
22
|
+
})
|
|
23
|
+
.option("f", {
|
|
24
|
+
alias: "force",
|
|
25
|
+
describe: "Force regenerate",
|
|
26
|
+
type: "boolean",
|
|
27
|
+
default: false,
|
|
28
|
+
})
|
|
29
|
+
.positional("file", {
|
|
30
|
+
describe: "Mulmo Script File",
|
|
31
|
+
type: "string",
|
|
21
32
|
});
|
|
22
33
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { MulmoStudioContext } from "../types/type.js";
|
|
2
|
+
import type { CliArgs } from "../types/cli_types.js";
|
|
3
|
+
export declare const setGraphAILogger: (verbose: boolean | undefined, logValues?: Record<string, unknown>) => void;
|
|
4
|
+
export interface FileObject {
|
|
5
|
+
baseDirPath: string;
|
|
6
|
+
mulmoFilePath: string;
|
|
7
|
+
mulmoFileDirPath: string;
|
|
8
|
+
outDirPath: string;
|
|
9
|
+
imageDirPath: string;
|
|
10
|
+
audioDirPath: string;
|
|
11
|
+
isHttpPath: boolean;
|
|
12
|
+
fileOrUrl: string;
|
|
13
|
+
outputStudioFilePath: string;
|
|
14
|
+
fileName: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const getFileObject: (args: {
|
|
17
|
+
basedir?: string;
|
|
18
|
+
outdir?: string;
|
|
19
|
+
imagedir?: string;
|
|
20
|
+
audiodir?: string;
|
|
21
|
+
file: string;
|
|
22
|
+
}) => FileObject;
|
|
23
|
+
export declare const fetchScript: (isHttpPath: boolean, mulmoFilePath: string, fileOrUrl: string) => Promise<any>;
|
|
24
|
+
type InitOptions = {
|
|
25
|
+
b?: string;
|
|
26
|
+
o?: string;
|
|
27
|
+
i?: string;
|
|
28
|
+
a?: string;
|
|
29
|
+
file?: string;
|
|
30
|
+
l?: string;
|
|
31
|
+
c?: string;
|
|
32
|
+
};
|
|
33
|
+
export declare const initializeContext: (argv: CliArgs<InitOptions>) => Promise<MulmoStudioContext>;
|
|
34
|
+
export declare const runTranslateIfNeeded: (context: MulmoStudioContext, argv: {
|
|
35
|
+
l?: string;
|
|
36
|
+
c?: string;
|
|
37
|
+
}) => Promise<void>;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { GraphAILogger } from "graphai";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import clipboardy from "clipboardy";
|
|
5
|
+
import { getBaseDirPath, getFullPath, readMulmoScriptFile, fetchMulmoScriptFile, getOutputStudioFilePath, resolveDirPath } from "../utils/file.js";
|
|
6
|
+
import { isHttp } from "../utils/utils.js";
|
|
7
|
+
import { createOrUpdateStudioData } from "../utils/preprocess.js";
|
|
8
|
+
import { outDirName, imageDirName, audioDirName } from "../utils/const.js";
|
|
9
|
+
import { translate } from "../actions/translate.js";
|
|
10
|
+
export const setGraphAILogger = (verbose, logValues) => {
|
|
11
|
+
if (verbose) {
|
|
12
|
+
if (logValues) {
|
|
13
|
+
Object.entries(logValues).forEach(([key, value]) => {
|
|
14
|
+
GraphAILogger.info(`${key}:`, value);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
GraphAILogger.setLevelEnabled("error", false);
|
|
20
|
+
GraphAILogger.setLevelEnabled("log", false);
|
|
21
|
+
GraphAILogger.setLevelEnabled("warn", false);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
export const getFileObject = (args) => {
|
|
25
|
+
const { basedir, outdir, imagedir, audiodir, file } = args;
|
|
26
|
+
const baseDirPath = getBaseDirPath(basedir);
|
|
27
|
+
const outDirPath = getFullPath(baseDirPath, outdir ?? outDirName);
|
|
28
|
+
const { fileOrUrl, fileName } = (() => {
|
|
29
|
+
if (file === "__clipboard") {
|
|
30
|
+
// We generate a new unique script file from clipboard text in the output directory
|
|
31
|
+
const now = new Date();
|
|
32
|
+
const pad = (n) => n.toString().padStart(2, "0");
|
|
33
|
+
const fileName = `script_${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}_${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
|
|
34
|
+
const clipboardText = clipboardy.readSync();
|
|
35
|
+
const fileOrUrl = resolveDirPath(outDirPath, `${fileName}.json`);
|
|
36
|
+
fs.writeFileSync(fileOrUrl, clipboardText, "utf8");
|
|
37
|
+
return { fileOrUrl, fileName };
|
|
38
|
+
}
|
|
39
|
+
const fileOrUrl = file ?? "";
|
|
40
|
+
const fileName = path.parse(fileOrUrl).name;
|
|
41
|
+
return { fileOrUrl, fileName };
|
|
42
|
+
})();
|
|
43
|
+
const isHttpPath = isHttp(fileOrUrl);
|
|
44
|
+
const mulmoFilePath = isHttpPath ? "" : getFullPath(baseDirPath, fileOrUrl);
|
|
45
|
+
const mulmoFileDirPath = path.dirname(isHttpPath ? baseDirPath : mulmoFilePath);
|
|
46
|
+
const imageDirPath = getFullPath(outDirPath, imagedir ?? imageDirName);
|
|
47
|
+
const audioDirPath = getFullPath(outDirPath, audiodir ?? audioDirName);
|
|
48
|
+
const outputStudioFilePath = getOutputStudioFilePath(outDirPath, fileName);
|
|
49
|
+
return {
|
|
50
|
+
baseDirPath,
|
|
51
|
+
mulmoFilePath,
|
|
52
|
+
mulmoFileDirPath,
|
|
53
|
+
outDirPath,
|
|
54
|
+
imageDirPath,
|
|
55
|
+
audioDirPath,
|
|
56
|
+
isHttpPath,
|
|
57
|
+
fileOrUrl,
|
|
58
|
+
outputStudioFilePath,
|
|
59
|
+
fileName,
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export const fetchScript = async (isHttpPath, mulmoFilePath, fileOrUrl) => {
|
|
63
|
+
if (isHttpPath) {
|
|
64
|
+
const res = await fetchMulmoScriptFile(fileOrUrl);
|
|
65
|
+
if (!res.result || !res.script) {
|
|
66
|
+
GraphAILogger.info(`ERROR: HTTP error! ${res.status} ${fileOrUrl}`);
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
return res.script;
|
|
70
|
+
}
|
|
71
|
+
if (!fs.existsSync(mulmoFilePath)) {
|
|
72
|
+
GraphAILogger.info(`ERROR: File not exists ${mulmoFilePath}`);
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
return readMulmoScriptFile(mulmoFilePath, "ERROR: File does not exist " + mulmoFilePath).mulmoData;
|
|
76
|
+
};
|
|
77
|
+
export const initializeContext = async (argv) => {
|
|
78
|
+
const files = getFileObject({
|
|
79
|
+
basedir: argv.b,
|
|
80
|
+
outdir: argv.o,
|
|
81
|
+
imagedir: argv.i,
|
|
82
|
+
audiodir: argv.a,
|
|
83
|
+
file: argv.file ?? "",
|
|
84
|
+
});
|
|
85
|
+
const { fileName, isHttpPath, fileOrUrl, mulmoFilePath, outputStudioFilePath } = files;
|
|
86
|
+
setGraphAILogger(argv.v, {
|
|
87
|
+
files,
|
|
88
|
+
});
|
|
89
|
+
const mulmoScript = await fetchScript(isHttpPath, mulmoFilePath, fileOrUrl);
|
|
90
|
+
// Create or update MulmoStudio file with MulmoScript
|
|
91
|
+
const currentStudio = readMulmoScriptFile(outputStudioFilePath);
|
|
92
|
+
const studio = (() => {
|
|
93
|
+
try {
|
|
94
|
+
// validate mulmoStudioSchema. skip if __test_invalid__ is true
|
|
95
|
+
return createOrUpdateStudioData(mulmoScript, currentStudio?.mulmoData, fileName);
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
GraphAILogger.info(`Error: invalid MulmoScript Schema: ${isHttpPath ? fileOrUrl : mulmoFilePath} \n ${error}`);
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
})();
|
|
102
|
+
return {
|
|
103
|
+
studio,
|
|
104
|
+
fileDirs: files,
|
|
105
|
+
force: Boolean(argv.f),
|
|
106
|
+
lang: argv.l,
|
|
107
|
+
caption: argv.c,
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
export const runTranslateIfNeeded = async (context, argv) => {
|
|
111
|
+
if (argv.l || argv.c) {
|
|
112
|
+
GraphAILogger.log("run translate");
|
|
113
|
+
await translate(context);
|
|
114
|
+
}
|
|
115
|
+
};
|
package/lib/cli/tool-args.d.ts
CHANGED
package/lib/cli/tool-args.js
CHANGED
|
@@ -54,7 +54,7 @@ export const args = commonOptions(yargs(hideBin(process.argv)))
|
|
|
54
54
|
.command("$0 <action>", "Run mulmocast tool", (yargs) => {
|
|
55
55
|
return yargs.positional("action", {
|
|
56
56
|
describe: "action to perform",
|
|
57
|
-
choices: ["scripting", "prompt"],
|
|
57
|
+
choices: ["scripting", "prompt", "schema"],
|
|
58
58
|
type: "string",
|
|
59
59
|
});
|
|
60
60
|
})
|
package/lib/cli/tool-cli.js
CHANGED
|
@@ -8,6 +8,8 @@ import { getBaseDirPath, getFullPath } from "../utils/file.js";
|
|
|
8
8
|
import { createMulmoScriptInteractively } from "../tools/create_mulmo_script_interactively.js";
|
|
9
9
|
import { dumpPromptFromTemplate } from "../tools/dump_prompt.js";
|
|
10
10
|
import { getUrlsIfNeeded, selectTemplate } from "../utils/inquirer.js";
|
|
11
|
+
import { mulmoScriptSchema } from "../types/schema.js";
|
|
12
|
+
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
11
13
|
const main = async () => {
|
|
12
14
|
const { o: outdir, b: basedir, action, v: verbose, i: interactive, s: filename, cache } = args;
|
|
13
15
|
let { t: template } = args;
|
|
@@ -51,6 +53,12 @@ const main = async () => {
|
|
|
51
53
|
else if (action === "prompt") {
|
|
52
54
|
await dumpPromptFromTemplate({ templateName: template });
|
|
53
55
|
}
|
|
56
|
+
else if (action === "schema") {
|
|
57
|
+
const defaultSchema = zodToJsonSchema(mulmoScriptSchema, {
|
|
58
|
+
strictUnions: true,
|
|
59
|
+
});
|
|
60
|
+
GraphAILogger.info(JSON.stringify(defaultSchema, null, 2));
|
|
61
|
+
}
|
|
54
62
|
else {
|
|
55
63
|
throw new Error(`Unknown or unsupported action: ${action}`);
|
|
56
64
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "dotenv/config";
|
|
2
2
|
import { MulmoCanvasDimension, MulmoScript, MulmoBeat, SpeechOptions, Text2SpeechProvider, Text2ImageAgentInfo, BeatMediaType } from "../types/index.js";
|
|
3
3
|
export declare const MulmoScriptMethods: {
|
|
4
|
-
getPadding(script: MulmoScript): number;
|
|
5
4
|
getCanvasSize(script: MulmoScript): MulmoCanvasDimension;
|
|
6
5
|
getAspectRatio(script: MulmoScript): string;
|
|
7
6
|
getSpeechProvider(script: MulmoScript): Text2SpeechProvider;
|
|
@@ -3,8 +3,8 @@ import { text2ImageProviderSchema, text2SpeechProviderSchema, mulmoCanvasDimensi
|
|
|
3
3
|
const defaultTextSlideStyles = [
|
|
4
4
|
'*,*::before,*::after{box-sizing:border-box}body,h1,h2,h3,h4,p,figure,blockquote,dl,dd{margin:0}ul[role="list"],ol[role="list"]{list-style:none}html:focus-within{scroll-behavior:smooth}body{min-height:100vh;text-rendering:optimizeSpeed;line-height:1.5}a:not([class]){text-decoration-skip-ink:auto}img,picture{max-width:100%;display:block}input,button,textarea,select{font:inherit}@media(prefers-reduced-motion:reduce){html:focus-within{scroll-behavior:auto}*,*::before,*::after{animation-duration:.01ms !important;animation-iteration-count:1 !important;transition-duration:.01ms !important;scroll-behavior:auto !important}}',
|
|
5
5
|
"body { margin: 60px; margin-top: 40px; color:#333; font-size: 30px; font-family: Arial, sans-serif; box-sizing: border-box; height: 100vh }",
|
|
6
|
-
"h1 { font-size: 56px; margin-bottom: 20px; text-align: center
|
|
7
|
-
"h2 { font-size: 48px }",
|
|
6
|
+
"h1 { font-size: 56px; margin-bottom: 20px; text-align: center }",
|
|
7
|
+
"h2 { font-size: 48px; text-align: center }",
|
|
8
8
|
"h3 { font-size: 36px }",
|
|
9
9
|
"ul { margin-left: 40px } ",
|
|
10
10
|
"pre { background: #eeeecc; font-size: 16px; padding:4px }",
|
|
@@ -15,9 +15,6 @@ const defaultTextSlideStyles = [
|
|
|
15
15
|
"tr:nth-child(even) { background-color: #eee }",
|
|
16
16
|
];
|
|
17
17
|
export const MulmoScriptMethods = {
|
|
18
|
-
getPadding(script) {
|
|
19
|
-
return script.videoParams?.padding ?? 1000; // msec
|
|
20
|
-
},
|
|
21
18
|
getCanvasSize(script) {
|
|
22
19
|
return mulmoCanvasDimensionSchema.parse(script.canvasSize);
|
|
23
20
|
},
|
|
@@ -30,11 +27,11 @@ export const MulmoScriptMethods = {
|
|
|
30
27
|
return text2SpeechProviderSchema.parse(script.speechParams?.provider);
|
|
31
28
|
},
|
|
32
29
|
getTextSlideStyle(script, beat) {
|
|
33
|
-
const styles = script.textSlideParams?.cssStyles ??
|
|
30
|
+
const styles = script.textSlideParams?.cssStyles ?? [];
|
|
34
31
|
// NOTES: Taking advantage of CSS override rule (you can redefine it to override)
|
|
35
32
|
const extraStyles = beat.textSlideParams?.cssStyles ?? [];
|
|
36
33
|
// This code allows us to support both string and array of strings for cssStyles
|
|
37
|
-
return [...[styles], ...[extraStyles]].flat().join("\n");
|
|
34
|
+
return [...defaultTextSlideStyles, ...[styles], ...[extraStyles]].flat().join("\n");
|
|
38
35
|
},
|
|
39
36
|
getSpeechOptions(script, beat) {
|
|
40
37
|
return { ...script.speechParams.speakers[beat.speaker].speechOptions, ...beat.speechOptions };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MulmoScriptTemplate } from "../types/index.js";
|
|
1
|
+
import { MulmoScript, MulmoScriptTemplate } from "../types/index.js";
|
|
2
2
|
export declare const MulmoScriptTemplateMethods: {
|
|
3
|
-
getSystemPrompt(template: MulmoScriptTemplate): string;
|
|
3
|
+
getSystemPrompt(template: MulmoScriptTemplate, script?: MulmoScript): string;
|
|
4
4
|
};
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { mulmoScriptSchema } from "../types/schema.js";
|
|
1
|
+
import { getMulmoScriptTemplateSystemPrompt } from "../utils/prompt.js";
|
|
3
2
|
export const MulmoScriptTemplateMethods = {
|
|
4
|
-
getSystemPrompt(template) {
|
|
5
|
-
|
|
6
|
-
if (template.script) {
|
|
7
|
-
return `${template.systemPrompt}\n\`\`\`JSON\n${JSON.stringify(template.script)}\n\`\`\``;
|
|
8
|
-
}
|
|
9
|
-
// script is not provided, use the default schema
|
|
10
|
-
const defaultSchema = zodToJsonSchema(mulmoScriptSchema, {
|
|
11
|
-
strictUnions: true,
|
|
12
|
-
});
|
|
13
|
-
const specificOutputPrompt = `The output should follow the JSON schema specified below. Please provide your response as valid JSON within \`\`\`json code blocks for clarity.`;
|
|
14
|
-
return `${template.systemPrompt}\n\n${specificOutputPrompt}\n\n\`\`\`JSON\n${JSON.stringify(defaultSchema)}\n\`\`\``;
|
|
3
|
+
getSystemPrompt(template, script) {
|
|
4
|
+
return getMulmoScriptTemplateSystemPrompt(template, script);
|
|
15
5
|
},
|
|
16
6
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MulmoStudio } from "../types/index.js";
|
|
2
|
+
type SessionType = "audio" | "image" | "video" | "multiLingual" | "caption" | "pdf";
|
|
3
|
+
type BeatSessionType = "audio" | "image" | "multiLingual" | "caption";
|
|
4
|
+
export declare const MulmoStudioMethods: {
|
|
5
|
+
setSessionState(studio: MulmoStudio, sessionType: SessionType, value: boolean): void;
|
|
6
|
+
setBeatSessionState(studio: MulmoStudio, sessionType: BeatSessionType, index: number, value: boolean): void;
|
|
7
|
+
};
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { GraphAILogger } from "graphai";
|
|
2
|
+
const notifyStateChange = (studio, sessionType) => {
|
|
3
|
+
const prefix = studio.state.inSession[sessionType] ? "<" : " >";
|
|
4
|
+
GraphAILogger.info(`${prefix} ${sessionType}`);
|
|
5
|
+
};
|
|
6
|
+
const notifyBeatStateChange = (studio, sessionType, index) => {
|
|
7
|
+
const prefix = studio.state.inBeatSession[sessionType].has(index) ? "{" : " }";
|
|
8
|
+
GraphAILogger.info(`${prefix} ${sessionType} ${index}`);
|
|
9
|
+
};
|
|
10
|
+
export const MulmoStudioMethods = {
|
|
11
|
+
setSessionState(studio, sessionType, value) {
|
|
12
|
+
studio.state.inSession[sessionType] = value;
|
|
13
|
+
notifyStateChange(studio, sessionType);
|
|
14
|
+
},
|
|
15
|
+
setBeatSessionState(studio, sessionType, index, value) {
|
|
16
|
+
if (value) {
|
|
17
|
+
studio.state.inBeatSession[sessionType].add(index);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
studio.state.inBeatSession[sessionType].delete(index);
|
|
21
|
+
}
|
|
22
|
+
notifyBeatStateChange(studio, sessionType, index);
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import "dotenv/config";
|
|
2
2
|
import { ScriptingParams } from "../types/index.js";
|
|
3
|
-
export declare const createMulmoScriptFromUrl: ({ urls, templateName, outDirPath, filename, cacheDirPath }: ScriptingParams) => Promise<void>;
|
|
3
|
+
export declare const createMulmoScriptFromUrl: ({ urls, templateName, outDirPath, filename, cacheDirPath, llm, llm_model }: ScriptingParams) => Promise<void>;
|