mulmocast 0.0.10 → 0.0.12
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 +18 -3
- package/assets/templates/ghibli_shorts.json +34 -0
- package/assets/templates/shorts.json +18 -0
- package/assets/templates/trailer.json +25 -0
- package/lib/actions/audio.d.ts +2 -1
- package/lib/actions/audio.js +35 -17
- package/lib/actions/captions.js +5 -5
- package/lib/actions/images.d.ts +2 -1
- package/lib/actions/images.js +90 -58
- package/lib/actions/movie.js +53 -16
- package/lib/actions/pdf.js +3 -3
- package/lib/actions/translate.d.ts +2 -1
- package/lib/actions/translate.js +21 -16
- package/lib/agents/combine_audio_files_agent.js +4 -0
- package/lib/agents/image_google_agent.d.ts +4 -1
- package/lib/agents/image_google_agent.js +3 -2
- package/lib/agents/image_openai_agent.d.ts +5 -3
- package/lib/agents/image_openai_agent.js +35 -7
- package/lib/agents/index.d.ts +2 -1
- package/lib/agents/index.js +2 -1
- package/lib/agents/movie_google_agent.d.ts +9 -2
- package/lib/agents/movie_google_agent.js +24 -16
- package/lib/agents/tts_elevenlabs_agent.d.ts +4 -0
- package/lib/agents/tts_elevenlabs_agent.js +60 -0
- package/lib/agents/tts_google_agent.js +1 -1
- package/lib/agents/tts_nijivoice_agent.js +3 -2
- package/lib/agents/tts_openai_agent.js +1 -1
- package/lib/cli/commands/audio/handler.js +4 -1
- package/lib/cli/commands/image/handler.js +4 -1
- package/lib/cli/commands/movie/handler.js +4 -1
- package/lib/cli/commands/pdf/handler.js +4 -1
- package/lib/cli/commands/translate/handler.js +4 -1
- package/lib/cli/helpers.d.ts +3 -3
- package/lib/cli/helpers.js +38 -20
- package/lib/index.d.ts +5 -0
- package/lib/index.js +5 -0
- package/lib/methods/mulmo_media_source.d.ts +1 -0
- package/lib/methods/mulmo_media_source.js +12 -0
- package/lib/methods/mulmo_script.d.ts +1 -1
- package/lib/methods/mulmo_script.js +9 -5
- package/lib/methods/mulmo_studio_context.d.ts +5 -0
- package/lib/methods/mulmo_studio_context.js +23 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/schema.d.ts +1513 -290
- package/lib/types/schema.js +26 -35
- package/lib/types/type.d.ts +4 -1
- package/lib/utils/file.d.ts +5 -15
- package/lib/utils/file.js +14 -21
- package/lib/utils/filters.js +4 -4
- package/lib/utils/image_plugins/beat.d.ts +4 -0
- package/lib/utils/image_plugins/beat.js +7 -0
- package/lib/utils/image_plugins/image.d.ts +1 -1
- package/lib/utils/image_plugins/index.d.ts +2 -1
- package/lib/utils/image_plugins/index.js +2 -1
- package/lib/utils/image_plugins/movie.d.ts +1 -1
- package/lib/utils/image_plugins/source.js +2 -2
- package/lib/utils/preprocess.d.ts +26 -23
- package/lib/utils/preprocess.js +4 -0
- package/package.json +8 -8
- package/scripts/templates/movie_prompts_no_text_template.json +50 -0
- package/scripts/templates/shorts_template.json +52 -0
|
@@ -36,7 +36,7 @@ const ttsOpenaiAgentInfo = {
|
|
|
36
36
|
description: "OpenAI TTS agent",
|
|
37
37
|
category: ["tts"],
|
|
38
38
|
author: "Receptron Team",
|
|
39
|
-
repository: "https://github.com/receptron/
|
|
39
|
+
repository: "https://github.com/receptron/mulmocast-cli/",
|
|
40
40
|
license: "MIT",
|
|
41
41
|
environmentVariables: ["OPENAI_API_KEY"],
|
|
42
42
|
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { audio } from "../../../actions/index.js";
|
|
2
|
-
import { initializeContext, runTranslateIfNeeded } from "
|
|
2
|
+
import { initializeContext, runTranslateIfNeeded } from "../../helpers.js";
|
|
3
3
|
export const handler = async (argv) => {
|
|
4
4
|
const context = await initializeContext(argv);
|
|
5
|
+
if (!context) {
|
|
6
|
+
process.exit(1);
|
|
7
|
+
}
|
|
5
8
|
await runTranslateIfNeeded(context, argv);
|
|
6
9
|
await audio(context);
|
|
7
10
|
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { images } from "../../../actions/index.js";
|
|
2
|
-
import { initializeContext, runTranslateIfNeeded } from "
|
|
2
|
+
import { initializeContext, runTranslateIfNeeded } from "../../helpers.js";
|
|
3
3
|
export const handler = async (argv) => {
|
|
4
4
|
const context = await initializeContext(argv);
|
|
5
|
+
if (!context) {
|
|
6
|
+
process.exit(1);
|
|
7
|
+
}
|
|
5
8
|
await runTranslateIfNeeded(context, argv);
|
|
6
9
|
await images(context);
|
|
7
10
|
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { audio, images, movie, captions } from "../../../actions/index.js";
|
|
2
|
-
import { initializeContext, runTranslateIfNeeded } from "
|
|
2
|
+
import { initializeContext, runTranslateIfNeeded } from "../../helpers.js";
|
|
3
3
|
export const handler = async (argv) => {
|
|
4
4
|
const context = await initializeContext(argv);
|
|
5
|
+
if (!context) {
|
|
6
|
+
process.exit(1);
|
|
7
|
+
}
|
|
5
8
|
await runTranslateIfNeeded(context, argv);
|
|
6
9
|
await audio(context);
|
|
7
10
|
await images(context);
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { images, pdf } from "../../../actions/index.js";
|
|
2
|
-
import { initializeContext, runTranslateIfNeeded } from "
|
|
2
|
+
import { initializeContext, runTranslateIfNeeded } from "../../helpers.js";
|
|
3
3
|
export const handler = async (argv) => {
|
|
4
4
|
const context = await initializeContext(argv);
|
|
5
|
+
if (!context) {
|
|
6
|
+
process.exit(1);
|
|
7
|
+
}
|
|
5
8
|
await runTranslateIfNeeded(context, argv);
|
|
6
9
|
await images(context);
|
|
7
10
|
await pdf(context, argv.pdf_mode, argv.pdf_size);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { translate } from "../../../actions/index.js";
|
|
2
|
-
import { initializeContext } from "
|
|
2
|
+
import { initializeContext } from "../../helpers.js";
|
|
3
3
|
export const handler = async (argv) => {
|
|
4
4
|
const context = await initializeContext(argv);
|
|
5
|
+
if (!context) {
|
|
6
|
+
process.exit(1);
|
|
7
|
+
}
|
|
5
8
|
await translate(context);
|
|
6
9
|
};
|
package/lib/cli/helpers.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MulmoStudioContext } from "../types/type.js";
|
|
1
|
+
import type { MulmoScript, MulmoStudioContext } from "../types/type.js";
|
|
2
2
|
import type { CliArgs } from "../types/cli_types.js";
|
|
3
3
|
export declare const setGraphAILogger: (verbose: boolean | undefined, logValues?: Record<string, unknown>) => void;
|
|
4
4
|
export interface FileObject {
|
|
@@ -20,7 +20,7 @@ export declare const getFileObject: (args: {
|
|
|
20
20
|
audiodir?: string;
|
|
21
21
|
file: string;
|
|
22
22
|
}) => FileObject;
|
|
23
|
-
export declare const fetchScript: (isHttpPath: boolean, mulmoFilePath: string, fileOrUrl: string) => Promise<
|
|
23
|
+
export declare const fetchScript: (isHttpPath: boolean, mulmoFilePath: string, fileOrUrl: string) => Promise<MulmoScript | null>;
|
|
24
24
|
type InitOptions = {
|
|
25
25
|
b?: string;
|
|
26
26
|
o?: string;
|
|
@@ -30,7 +30,7 @@ type InitOptions = {
|
|
|
30
30
|
l?: string;
|
|
31
31
|
c?: string;
|
|
32
32
|
};
|
|
33
|
-
export declare const initializeContext: (argv: CliArgs<InitOptions>) => Promise<MulmoStudioContext>;
|
|
33
|
+
export declare const initializeContext: (argv: CliArgs<InitOptions>) => Promise<MulmoStudioContext | null>;
|
|
34
34
|
export declare const runTranslateIfNeeded: (context: MulmoStudioContext, argv: {
|
|
35
35
|
l?: string;
|
|
36
36
|
c?: string;
|
package/lib/cli/helpers.js
CHANGED
|
@@ -65,15 +65,15 @@ export const fetchScript = async (isHttpPath, mulmoFilePath, fileOrUrl) => {
|
|
|
65
65
|
const res = await fetchMulmoScriptFile(fileOrUrl);
|
|
66
66
|
if (!res.result || !res.script) {
|
|
67
67
|
GraphAILogger.info(`ERROR: HTTP error! ${res.status} ${fileOrUrl}`);
|
|
68
|
-
|
|
68
|
+
return null;
|
|
69
69
|
}
|
|
70
70
|
return res.script;
|
|
71
71
|
}
|
|
72
72
|
if (!fs.existsSync(mulmoFilePath)) {
|
|
73
73
|
GraphAILogger.info(`ERROR: File not exists ${mulmoFilePath}`);
|
|
74
|
-
|
|
74
|
+
return null;
|
|
75
75
|
}
|
|
76
|
-
return readMulmoScriptFile(mulmoFilePath, "ERROR: File does not exist " + mulmoFilePath)
|
|
76
|
+
return readMulmoScriptFile(mulmoFilePath, "ERROR: File does not exist " + mulmoFilePath)?.mulmoData ?? null;
|
|
77
77
|
};
|
|
78
78
|
export const initializeContext = async (argv) => {
|
|
79
79
|
const files = getFileObject({
|
|
@@ -88,25 +88,43 @@ export const initializeContext = async (argv) => {
|
|
|
88
88
|
files,
|
|
89
89
|
});
|
|
90
90
|
const mulmoScript = await fetchScript(isHttpPath, mulmoFilePath, fileOrUrl);
|
|
91
|
+
if (!mulmoScript) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
91
94
|
// Create or update MulmoStudio file with MulmoScript
|
|
92
95
|
const currentStudio = readMulmoScriptFile(outputStudioFilePath);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
96
|
+
try {
|
|
97
|
+
// validate mulmoStudioSchema. skip if __test_invalid__ is true
|
|
98
|
+
const studio = createOrUpdateStudioData(mulmoScript, currentStudio?.mulmoData, fileName);
|
|
99
|
+
return {
|
|
100
|
+
studio,
|
|
101
|
+
fileDirs: files,
|
|
102
|
+
force: Boolean(argv.f),
|
|
103
|
+
lang: argv.l,
|
|
104
|
+
caption: argv.c,
|
|
105
|
+
sessionState: {
|
|
106
|
+
inSession: {
|
|
107
|
+
audio: false,
|
|
108
|
+
image: false,
|
|
109
|
+
video: false,
|
|
110
|
+
multiLingual: false,
|
|
111
|
+
caption: false,
|
|
112
|
+
pdf: false,
|
|
113
|
+
},
|
|
114
|
+
inBeatSession: {
|
|
115
|
+
audio: {},
|
|
116
|
+
image: {},
|
|
117
|
+
movie: {},
|
|
118
|
+
multiLingual: {},
|
|
119
|
+
caption: {},
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
GraphAILogger.info(`Error: invalid MulmoScript Schema: ${isHttpPath ? fileOrUrl : mulmoFilePath} \n ${error}`);
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
110
128
|
};
|
|
111
129
|
export const runTranslateIfNeeded = async (context, argv) => {
|
|
112
130
|
if (argv.l || argv.c) {
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MulmoMediaSource, MulmoStudioContext } from "../types/index.js";
|
|
2
2
|
export declare const MulmoMediaSourceMethods: {
|
|
3
3
|
getText(mediaSource: MulmoMediaSource, context: MulmoStudioContext): Promise<string | null>;
|
|
4
|
+
resolve(mediaSource: MulmoMediaSource | undefined, context: MulmoStudioContext): string | null;
|
|
4
5
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import { getFullPath } from "../utils/file.js";
|
|
3
|
+
import { MulmoStudioContextMethods } from "../methods/index.js";
|
|
3
4
|
export const MulmoMediaSourceMethods = {
|
|
4
5
|
async getText(mediaSource, context) {
|
|
5
6
|
if (mediaSource.kind === "text") {
|
|
@@ -18,4 +19,15 @@ export const MulmoMediaSourceMethods = {
|
|
|
18
19
|
}
|
|
19
20
|
return null;
|
|
20
21
|
},
|
|
22
|
+
resolve(mediaSource, context) {
|
|
23
|
+
if (!mediaSource)
|
|
24
|
+
return null;
|
|
25
|
+
if (mediaSource.kind === "path") {
|
|
26
|
+
return MulmoStudioContextMethods.resolveAssetPath(context, mediaSource.path);
|
|
27
|
+
}
|
|
28
|
+
if (mediaSource.kind === "url") {
|
|
29
|
+
return mediaSource.url;
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
},
|
|
21
33
|
};
|
|
@@ -2,8 +2,8 @@ import "dotenv/config";
|
|
|
2
2
|
import { MulmoCanvasDimension, MulmoScript, MulmoBeat, SpeechOptions, Text2SpeechProvider, Text2ImageAgentInfo, BeatMediaType } from "../types/index.js";
|
|
3
3
|
export declare const MulmoScriptMethods: {
|
|
4
4
|
getCanvasSize(script: MulmoScript): MulmoCanvasDimension;
|
|
5
|
-
getAspectRatio(script: MulmoScript): string;
|
|
6
5
|
getSpeechProvider(script: MulmoScript): Text2SpeechProvider;
|
|
6
|
+
getAllSpeechProviders(script: MulmoScript): Set<Text2SpeechProvider>;
|
|
7
7
|
getTextSlideStyle(script: MulmoScript, beat: MulmoBeat): string;
|
|
8
8
|
getSpeechOptions(script: MulmoScript, beat: MulmoBeat): SpeechOptions | undefined;
|
|
9
9
|
getImageAgentInfo(script: MulmoScript): Text2ImageAgentInfo;
|
|
@@ -18,14 +18,18 @@ export const MulmoScriptMethods = {
|
|
|
18
18
|
getCanvasSize(script) {
|
|
19
19
|
return mulmoCanvasDimensionSchema.parse(script.canvasSize);
|
|
20
20
|
},
|
|
21
|
-
getAspectRatio(script) {
|
|
22
|
-
// Google's text2image specific parameter
|
|
23
|
-
const size = this.getCanvasSize(script);
|
|
24
|
-
return size.width > size.height ? "16:9" : "9:16";
|
|
25
|
-
},
|
|
26
21
|
getSpeechProvider(script) {
|
|
27
22
|
return text2SpeechProviderSchema.parse(script.speechParams?.provider);
|
|
28
23
|
},
|
|
24
|
+
getAllSpeechProviders(script) {
|
|
25
|
+
const providers = new Set();
|
|
26
|
+
const defaultProvider = this.getSpeechProvider(script);
|
|
27
|
+
Object.values(script.speechParams.speakers).forEach((speaker) => {
|
|
28
|
+
const provider = speaker.provider ?? defaultProvider;
|
|
29
|
+
providers.add(provider);
|
|
30
|
+
});
|
|
31
|
+
return providers;
|
|
32
|
+
},
|
|
29
33
|
getTextSlideStyle(script, beat) {
|
|
30
34
|
const styles = script.textSlideParams?.cssStyles ?? [];
|
|
31
35
|
// NOTES: Taking advantage of CSS override rule (you can redefine it to override)
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { MulmoStudioContext } from "../types/index.js";
|
|
2
|
+
type SessionType = "audio" | "image" | "video" | "multiLingual" | "caption" | "pdf";
|
|
3
|
+
type BeatSessionType = "audio" | "image" | "multiLingual" | "caption" | "movie";
|
|
2
4
|
export declare const MulmoStudioContextMethods: {
|
|
3
5
|
resolveAssetPath(context: MulmoStudioContext, relativePath: string): string;
|
|
6
|
+
setSessionState(context: MulmoStudioContext, sessionType: SessionType, value: boolean): void;
|
|
7
|
+
setBeatSessionState(context: MulmoStudioContext, sessionType: BeatSessionType, index: number, value: boolean): void;
|
|
4
8
|
};
|
|
9
|
+
export {};
|
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
+
import { GraphAILogger } from "graphai";
|
|
3
|
+
const notifyStateChange = (context, sessionType) => {
|
|
4
|
+
const prefix = context.sessionState.inSession[sessionType] ? "<" : " >";
|
|
5
|
+
GraphAILogger.info(`${prefix} ${sessionType}`);
|
|
6
|
+
};
|
|
7
|
+
const notifyBeatStateChange = (context, sessionType, index) => {
|
|
8
|
+
const prefix = context.sessionState.inBeatSession[sessionType][index] ? "{" : " }";
|
|
9
|
+
GraphAILogger.info(`${prefix} ${sessionType} ${index}`);
|
|
10
|
+
};
|
|
2
11
|
export const MulmoStudioContextMethods = {
|
|
3
12
|
resolveAssetPath(context, relativePath) {
|
|
4
13
|
return path.resolve(context.fileDirs.mulmoFileDirPath, relativePath);
|
|
5
14
|
},
|
|
15
|
+
setSessionState(context, sessionType, value) {
|
|
16
|
+
context.sessionState.inSession[sessionType] = value;
|
|
17
|
+
notifyStateChange(context, sessionType);
|
|
18
|
+
},
|
|
19
|
+
setBeatSessionState(context, sessionType, index, value) {
|
|
20
|
+
if (value) {
|
|
21
|
+
context.sessionState.inBeatSession[sessionType][index] = true;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
// NOTE: Setting to false causes the parse error in rebuildStudio in preprocess.ts
|
|
25
|
+
delete context.sessionState.inBeatSession[sessionType][index];
|
|
26
|
+
}
|
|
27
|
+
notifyBeatStateChange(context, sessionType, index);
|
|
28
|
+
},
|
|
6
29
|
};
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/index.js
CHANGED