mulmocast 0.0.1 → 0.0.2
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 +108 -12
- package/assets/html/chart.html +47 -0
- package/assets/html/mermaid.html +63 -0
- package/assets/templates/business.json +60 -6
- package/assets/templates/children_book.json +1 -3
- package/assets/templates/coding.json +103 -0
- package/lib/actions/audio.d.ts +1 -1
- package/lib/actions/audio.js +52 -81
- package/lib/actions/images.d.ts +1 -1
- package/lib/actions/images.js +48 -80
- package/lib/actions/movie.d.ts +1 -1
- package/lib/actions/movie.js +76 -76
- package/lib/actions/translate.d.ts +1 -1
- package/lib/actions/translate.js +16 -52
- package/lib/agents/add_bgm_agent.d.ts +1 -1
- package/lib/agents/add_bgm_agent.js +10 -14
- package/lib/agents/combine_audio_files_agent.d.ts +1 -1
- package/lib/agents/combine_audio_files_agent.js +40 -30
- package/lib/agents/image_google_agent.d.ts +1 -1
- package/lib/agents/image_google_agent.js +8 -11
- package/lib/agents/image_openai_agent.js +7 -14
- package/lib/agents/index.d.ts +8 -8
- package/lib/agents/index.js +13 -30
- package/lib/agents/mulmo_prompts_agent.d.ts +1 -1
- package/lib/agents/mulmo_prompts_agent.js +7 -11
- package/lib/agents/prompts_data.js +1 -4
- package/lib/agents/tts_nijivoice_agent.d.ts +1 -1
- package/lib/agents/tts_nijivoice_agent.js +8 -12
- package/lib/agents/tts_openai_agent.js +9 -16
- package/lib/agents/validate_mulmo_script_agent.d.ts +1 -1
- package/lib/agents/validate_mulmo_script_agent.js +6 -10
- package/lib/cli/args.d.ts +2 -1
- package/lib/cli/args.js +16 -14
- package/lib/cli/cli.js +64 -49
- package/lib/cli/common.js +1 -5
- package/lib/cli/tool-args.d.ts +2 -1
- package/lib/cli/tool-args.js +19 -18
- package/lib/cli/tool-cli.js +32 -51
- package/lib/methods/index.d.ts +3 -3
- package/lib/methods/index.js +3 -19
- package/lib/methods/mulmo_script.d.ts +10 -5
- package/lib/methods/mulmo_script.js +17 -11
- package/lib/methods/mulmo_script_template.d.ts +1 -1
- package/lib/methods/mulmo_script_template.js +4 -10
- package/lib/methods/mulmo_studio_context.d.ts +1 -1
- package/lib/methods/mulmo_studio_context.js +3 -9
- package/lib/tools/create_mulmo_script_from_url.d.ts +3 -0
- package/lib/tools/create_mulmo_script_from_url.js +152 -0
- package/lib/tools/create_mulmo_script_interactively.d.ts +3 -0
- package/lib/tools/create_mulmo_script_interactively.js +217 -0
- package/lib/tools/dump_prompt.js +5 -8
- package/lib/tools/prompt.js +9 -11
- package/lib/tools/seed_from_url2.d.ts +3 -0
- package/lib/tools/seed_from_url2.js +154 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.js +1 -17
- package/lib/types/schema.d.ts +433 -71
- package/lib/types/schema.js +126 -111
- package/lib/types/type.d.ts +7 -3
- package/lib/types/type.js +1 -2
- package/lib/utils/const.d.ts +2 -1
- package/lib/utils/const.js +4 -6
- package/lib/utils/file.d.ts +19 -4
- package/lib/utils/file.js +78 -71
- package/lib/utils/filters.d.ts +1 -0
- package/lib/utils/filters.js +47 -26
- package/lib/utils/image_preprocess.d.ts +14 -0
- package/lib/utils/image_preprocess.js +52 -0
- package/lib/utils/inquirer.d.ts +2 -0
- package/lib/utils/inquirer.js +33 -0
- package/lib/utils/markdown.d.ts +3 -1
- package/lib/utils/markdown.js +17 -19
- package/lib/utils/plugins.d.ts +5 -0
- package/lib/utils/plugins.js +11 -0
- package/lib/utils/preprocess.d.ts +24 -7
- package/lib/utils/preprocess.js +8 -14
- package/lib/utils/string.js +4 -10
- package/lib/utils/text_hash.js +2 -39
- package/package.json +12 -6
package/lib/utils/filters.js
CHANGED
|
@@ -1,32 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const graphai_1 = require("graphai");
|
|
10
|
-
const file_1 = require("./file");
|
|
11
|
-
const fileCacheAgentFilter = async (context, next) => {
|
|
1
|
+
import "dotenv/config";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import fsPromise from "fs/promises";
|
|
5
|
+
import { GraphAILogger } from "graphai";
|
|
6
|
+
import { writingMessage } from "./file.js";
|
|
7
|
+
import { text2hash } from "./text_hash.js";
|
|
8
|
+
export const fileCacheAgentFilter = async (context, next) => {
|
|
12
9
|
const { namedInputs } = context;
|
|
13
|
-
const { file, text } = namedInputs;
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
const { file, text, force } = namedInputs;
|
|
11
|
+
const shouldUseCache = async () => {
|
|
12
|
+
if (force) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
await fsPromise.access(file);
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
catch (__e) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
if (await shouldUseCache()) {
|
|
16
24
|
const elements = file.split("/");
|
|
17
|
-
|
|
25
|
+
GraphAILogger.info("cache hit: " + elements[elements.length - 1], text.slice(0, 10));
|
|
18
26
|
return true;
|
|
19
27
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
graphai_1.GraphAILogger.log("no cache, no buffer: " + file);
|
|
29
|
-
return false;
|
|
28
|
+
const output = (await next(context));
|
|
29
|
+
const buffer = output ? output["buffer"] : undefined;
|
|
30
|
+
if (buffer) {
|
|
31
|
+
writingMessage(file);
|
|
32
|
+
await fsPromise.writeFile(file, buffer);
|
|
33
|
+
return true;
|
|
30
34
|
}
|
|
35
|
+
GraphAILogger.log("no cache, no buffer: " + file);
|
|
36
|
+
return false;
|
|
37
|
+
};
|
|
38
|
+
export const browserlessCacheGenerator = (cacheDir) => {
|
|
39
|
+
const browserlessCache = async (context, next) => {
|
|
40
|
+
const cacheKey = text2hash(context?.namedInputs?.url);
|
|
41
|
+
const cachePath = path.resolve(cacheDir, cacheKey + ".txt");
|
|
42
|
+
if (fs.existsSync(cachePath)) {
|
|
43
|
+
// console.log("cache hit!!");
|
|
44
|
+
const text = fs.readFileSync(cachePath, "utf-8");
|
|
45
|
+
return { text };
|
|
46
|
+
}
|
|
47
|
+
// console.log("cache not hit!!");
|
|
48
|
+
const result = (await next(context));
|
|
49
|
+
fs.writeFileSync(cachePath, result?.text, "utf8");
|
|
50
|
+
return result;
|
|
51
|
+
};
|
|
52
|
+
return browserlessCache;
|
|
31
53
|
};
|
|
32
|
-
exports.fileCacheAgentFilter = fileCacheAgentFilter;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MulmoStudioBeat, MulmoStudioContext, MulmoCanvasDimension } from "../types/index.js";
|
|
2
|
+
type ImageProcessorParams = {
|
|
3
|
+
beat: MulmoStudioBeat;
|
|
4
|
+
context: MulmoStudioContext;
|
|
5
|
+
imagePath: string;
|
|
6
|
+
textSlideStyle: string;
|
|
7
|
+
canvasSize: MulmoCanvasDimension;
|
|
8
|
+
};
|
|
9
|
+
export declare const processTextSlide: (params: ImageProcessorParams) => Promise<void>;
|
|
10
|
+
export declare const processMarkdown: (params: ImageProcessorParams) => Promise<void>;
|
|
11
|
+
export declare const processImage: (params: ImageProcessorParams) => string | undefined;
|
|
12
|
+
export declare const processChart: (params: ImageProcessorParams) => Promise<void>;
|
|
13
|
+
export declare const processMermaid: (params: ImageProcessorParams) => Promise<void>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { MulmoStudioContextMethods } from "../methods/index.js";
|
|
2
|
+
import { getHTMLFile } from "./file.js";
|
|
3
|
+
import { renderMarkdownToImage, renderHTMLToImage, interpolate } from "./markdown.js";
|
|
4
|
+
export const processTextSlide = async (params) => {
|
|
5
|
+
const { beat, imagePath, textSlideStyle, canvasSize } = params;
|
|
6
|
+
if (!beat.image || beat.image.type !== "textSlide")
|
|
7
|
+
return;
|
|
8
|
+
const slide = beat.image.slide;
|
|
9
|
+
const markdown = `# ${slide.title}\n` + slide.bullets.map((text) => `- ${text}`).join("\n");
|
|
10
|
+
await renderMarkdownToImage(markdown, textSlideStyle, imagePath, canvasSize.width, canvasSize.height);
|
|
11
|
+
};
|
|
12
|
+
export const processMarkdown = async (params) => {
|
|
13
|
+
const { beat, imagePath, textSlideStyle, canvasSize } = params;
|
|
14
|
+
if (!beat.image || beat.image.type !== "markdown")
|
|
15
|
+
return;
|
|
16
|
+
const markdown = Array.isArray(beat.image.markdown) ? beat.image.markdown.join("\n") : beat.image.markdown;
|
|
17
|
+
await renderMarkdownToImage(markdown, textSlideStyle, imagePath, canvasSize.width, canvasSize.height);
|
|
18
|
+
};
|
|
19
|
+
export const processImage = (params) => {
|
|
20
|
+
const { beat, context } = params;
|
|
21
|
+
if (!beat.image || beat.image.type !== "image")
|
|
22
|
+
return;
|
|
23
|
+
if (beat.image.source.kind === "url") {
|
|
24
|
+
return beat.image.source.url;
|
|
25
|
+
}
|
|
26
|
+
else if (beat.image.source.kind === "path") {
|
|
27
|
+
return MulmoStudioContextMethods.resolveAssetPath(context, beat.image.source.path);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export const processChart = async (params) => {
|
|
31
|
+
const { beat, imagePath, canvasSize } = params;
|
|
32
|
+
if (!beat.image || beat.image.type !== "chart")
|
|
33
|
+
return;
|
|
34
|
+
const template = getHTMLFile("chart");
|
|
35
|
+
const htmlData = interpolate(template, {
|
|
36
|
+
title: beat.image.title,
|
|
37
|
+
width: Math.round(canvasSize.width * 0.625).toString(),
|
|
38
|
+
chart_data: JSON.stringify(beat.image.chartData),
|
|
39
|
+
});
|
|
40
|
+
await renderHTMLToImage(htmlData, imagePath, canvasSize.width, canvasSize.height);
|
|
41
|
+
};
|
|
42
|
+
export const processMermaid = async (params) => {
|
|
43
|
+
const { beat, imagePath, canvasSize } = params;
|
|
44
|
+
if (!beat.image || beat.image.type !== "mermaid")
|
|
45
|
+
return;
|
|
46
|
+
const template = getHTMLFile("mermaid");
|
|
47
|
+
const htmlData = interpolate(template, {
|
|
48
|
+
title: beat.image.title,
|
|
49
|
+
diagram_code: beat.image.code,
|
|
50
|
+
});
|
|
51
|
+
await renderHTMLToImage(htmlData, imagePath, canvasSize.width, canvasSize.height);
|
|
52
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import inquirer from "inquirer";
|
|
2
|
+
import { getAvailableTemplates } from "./file.js";
|
|
3
|
+
export const selectTemplate = async () => {
|
|
4
|
+
const availableTemplates = getAvailableTemplates();
|
|
5
|
+
const answers = await inquirer.prompt([
|
|
6
|
+
{
|
|
7
|
+
type: "list",
|
|
8
|
+
name: "templateName",
|
|
9
|
+
message: "Select a template to use",
|
|
10
|
+
choices: availableTemplates.map((t) => ({
|
|
11
|
+
name: `${t.filename} - ${t.description}`,
|
|
12
|
+
value: t.filename,
|
|
13
|
+
})),
|
|
14
|
+
},
|
|
15
|
+
]);
|
|
16
|
+
return answers.templateName;
|
|
17
|
+
};
|
|
18
|
+
export const getUrlsIfNeeded = async (urls) => {
|
|
19
|
+
if (urls && urls.length > 0)
|
|
20
|
+
return urls;
|
|
21
|
+
const answers = await inquirer.prompt([
|
|
22
|
+
{
|
|
23
|
+
type: "input",
|
|
24
|
+
name: "urls",
|
|
25
|
+
message: "Enter URLs for scripting references (comma separated):",
|
|
26
|
+
validate: (input) => input.trim().length > 0 || "At least one URL is required",
|
|
27
|
+
},
|
|
28
|
+
]);
|
|
29
|
+
return answers.urls
|
|
30
|
+
.split(",")
|
|
31
|
+
.map((u) => u.trim())
|
|
32
|
+
.filter((u) => u.length > 0);
|
|
33
|
+
};
|
package/lib/utils/markdown.d.ts
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const renderHTMLToImage: (html: string, outputPath: string, width: number, height: number) => Promise<void>;
|
|
2
|
+
export declare const renderMarkdownToImage: (markdown: string, style: string, outputPath: string, width: number, height: number) => Promise<void>;
|
|
3
|
+
export declare const interpolate: (template: string, data: Record<string, string>) => string;
|
package/lib/utils/markdown.js
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const marked_1 = require("marked");
|
|
8
|
-
const puppeteer_1 = __importDefault(require("puppeteer"));
|
|
9
|
-
const convertMarkdownToImage = async (markdown, style, outputPath) => {
|
|
10
|
-
// Step 0: Prepare the header
|
|
11
|
-
const header = `<head><style>${style}</style></head>`;
|
|
12
|
-
// Step 1: Convert Markdown to HTML
|
|
13
|
-
const body = await (0, marked_1.marked)(markdown);
|
|
14
|
-
const html = `<htlm>${header}<body>${body}</body></html>`;
|
|
15
|
-
// Step 2: Use Puppeteer to render HTML to an image
|
|
16
|
-
const browser = await puppeteer_1.default.launch();
|
|
1
|
+
import { GraphAILogger } from "graphai";
|
|
2
|
+
import { marked } from "marked";
|
|
3
|
+
import puppeteer from "puppeteer";
|
|
4
|
+
export const renderHTMLToImage = async (html, outputPath, width, height) => {
|
|
5
|
+
// Use Puppeteer to render HTML to an image
|
|
6
|
+
const browser = await puppeteer.launch();
|
|
17
7
|
const page = await browser.newPage();
|
|
18
8
|
// Set the page content to the HTML generated from the Markdown
|
|
19
9
|
await page.setContent(html);
|
|
20
10
|
// Adjust page settings if needed (like width, height, etc.)
|
|
21
|
-
await page.setViewport({ width
|
|
11
|
+
await page.setViewport({ width, height });
|
|
22
12
|
// Step 3: Capture screenshot of the page (which contains the Markdown-rendered HTML)
|
|
23
13
|
await page.screenshot({ path: outputPath });
|
|
24
14
|
await browser.close();
|
|
25
|
-
|
|
15
|
+
GraphAILogger.info(`HTML image rendered to ${outputPath}`);
|
|
16
|
+
};
|
|
17
|
+
export const renderMarkdownToImage = async (markdown, style, outputPath, width, height) => {
|
|
18
|
+
const header = `<head><style>${style}</style></head>`;
|
|
19
|
+
const body = await marked(markdown);
|
|
20
|
+
const html = `<htlm>${header}<body>${body}</body></html>`;
|
|
21
|
+
await renderHTMLToImage(html, outputPath, width, height);
|
|
22
|
+
};
|
|
23
|
+
export const interpolate = (template, data) => {
|
|
24
|
+
return template.replace(/\$\{(.*?)\}/g, (_, key) => data[key.trim()] ?? "");
|
|
26
25
|
};
|
|
27
|
-
exports.convertMarkdownToImage = convertMarkdownToImage;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ora from "ora";
|
|
2
|
+
const spinner = ora();
|
|
3
|
+
spinner.prefixText = "\n";
|
|
4
|
+
export const cliLoadingPlugin = ({ nodeId, message }) => (log) => {
|
|
5
|
+
if (log.nodeId === nodeId && log.state === "queued") {
|
|
6
|
+
spinner.start(message);
|
|
7
|
+
}
|
|
8
|
+
if (log.nodeId === nodeId && log.state === "completed") {
|
|
9
|
+
spinner.stop();
|
|
10
|
+
}
|
|
11
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { MulmoScript } from "../types/index.js";
|
|
2
|
+
export declare const createOrUpdateStudioData: (mulmoScript: MulmoScript, fileName: string, files: {
|
|
2
3
|
outDirPath: string;
|
|
3
4
|
}) => {
|
|
4
5
|
beats: {
|
|
@@ -69,6 +70,14 @@ export declare const createOrUpdateStudioData: (mulmoFile: string, files: {
|
|
|
69
70
|
title: string;
|
|
70
71
|
bullets: string[];
|
|
71
72
|
};
|
|
73
|
+
} | {
|
|
74
|
+
type: "chart";
|
|
75
|
+
title: string;
|
|
76
|
+
chartData: Record<string, any>;
|
|
77
|
+
} | {
|
|
78
|
+
code: string;
|
|
79
|
+
type: "mermaid";
|
|
80
|
+
title: string;
|
|
72
81
|
} | undefined;
|
|
73
82
|
audio?: {
|
|
74
83
|
type: "audio";
|
|
@@ -113,6 +122,10 @@ export declare const createOrUpdateStudioData: (mulmoFile: string, files: {
|
|
|
113
122
|
version: "1.0";
|
|
114
123
|
credit?: "closing" | undefined;
|
|
115
124
|
};
|
|
125
|
+
canvasSize: {
|
|
126
|
+
width: number;
|
|
127
|
+
height: number;
|
|
128
|
+
};
|
|
116
129
|
beats: {
|
|
117
130
|
text: string;
|
|
118
131
|
speaker: string;
|
|
@@ -180,6 +193,14 @@ export declare const createOrUpdateStudioData: (mulmoFile: string, files: {
|
|
|
180
193
|
title: string;
|
|
181
194
|
bullets: string[];
|
|
182
195
|
};
|
|
196
|
+
} | {
|
|
197
|
+
type: "chart";
|
|
198
|
+
title: string;
|
|
199
|
+
chartData: Record<string, any>;
|
|
200
|
+
} | {
|
|
201
|
+
code: string;
|
|
202
|
+
type: "mermaid";
|
|
203
|
+
title: string;
|
|
183
204
|
} | undefined;
|
|
184
205
|
audio?: {
|
|
185
206
|
type: "audio";
|
|
@@ -209,6 +230,7 @@ export declare const createOrUpdateStudioData: (mulmoFile: string, files: {
|
|
|
209
230
|
imagePrompt?: string | undefined;
|
|
210
231
|
}[];
|
|
211
232
|
speechParams: {
|
|
233
|
+
provider: "openai" | "nijivoice";
|
|
212
234
|
speakers: Record<string, {
|
|
213
235
|
displayName: Record<string, string>;
|
|
214
236
|
voiceId: string;
|
|
@@ -217,25 +239,20 @@ export declare const createOrUpdateStudioData: (mulmoFile: string, files: {
|
|
|
217
239
|
instruction?: string | undefined;
|
|
218
240
|
} | undefined;
|
|
219
241
|
}>;
|
|
220
|
-
provider?: string | undefined;
|
|
221
242
|
};
|
|
222
243
|
lang?: string | undefined;
|
|
223
244
|
imageParams?: {
|
|
245
|
+
provider: "openai" | "google";
|
|
224
246
|
model?: string | undefined;
|
|
225
247
|
size?: string | undefined;
|
|
226
248
|
style?: string | undefined;
|
|
227
249
|
moderation?: string | undefined;
|
|
228
|
-
provider?: string | undefined;
|
|
229
250
|
} | undefined;
|
|
230
251
|
textSlideParams?: {
|
|
231
252
|
cssStyles: string[];
|
|
232
253
|
} | undefined;
|
|
233
254
|
description?: string | undefined;
|
|
234
255
|
reference?: string | undefined;
|
|
235
|
-
canvasSize?: {
|
|
236
|
-
width: number;
|
|
237
|
-
height: number;
|
|
238
|
-
} | undefined;
|
|
239
256
|
videoParams?: {
|
|
240
257
|
padding?: number | undefined;
|
|
241
258
|
} | undefined;
|
package/lib/utils/preprocess.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const text_hash_1 = require("./text_hash");
|
|
6
|
-
const methods_1 = require("../methods");
|
|
7
|
-
const createOrUpdateStudioData = (mulmoFile, files) => {
|
|
1
|
+
import { readMulmoScriptFile, getOutputStudioFilePath } from "./file.js";
|
|
2
|
+
import { text2hash } from "./text_hash.js";
|
|
3
|
+
import { MulmoScriptMethods } from "../methods/index.js";
|
|
4
|
+
export const createOrUpdateStudioData = (mulmoScript, fileName, files) => {
|
|
8
5
|
const { outDirPath } = files;
|
|
9
|
-
const readData = (0, file_1.readMulmoScriptFile)(mulmoFile, "ERROR: File does not exist " + mulmoFile);
|
|
10
|
-
const { mulmoData: mulmoScript, fileName } = readData;
|
|
11
6
|
// Create or update MulmoStudio file with MulmoScript
|
|
12
|
-
const outputStudioFilePath =
|
|
13
|
-
const currentStudio =
|
|
7
|
+
const outputStudioFilePath = getOutputStudioFilePath(outDirPath, fileName);
|
|
8
|
+
const currentStudio = readMulmoScriptFile(outputStudioFilePath);
|
|
14
9
|
const studio = currentStudio?.mulmoData ?? {
|
|
15
10
|
script: mulmoScript,
|
|
16
11
|
filename: fileName,
|
|
@@ -44,10 +39,9 @@ const createOrUpdateStudioData = (mulmoFile, files) => {
|
|
|
44
39
|
studio.beats.length = mulmoScript.beats.length; // In case it became shorter
|
|
45
40
|
mulmoScript.beats.forEach((beat, index) => {
|
|
46
41
|
const voiceId = studio.script.speechParams.speakers[beat.speaker].voiceId;
|
|
47
|
-
const speechOptions =
|
|
42
|
+
const speechOptions = MulmoScriptMethods.getSpeechOptions(studio.script, beat);
|
|
48
43
|
const hash_string = `${beat.text}${voiceId}${speechOptions?.instruction ?? ""}${speechOptions?.speed ?? 1.0}`;
|
|
49
|
-
studio.beats[index] = { ...studio.beats[index], ...beat, audioFile: `${fileName}_${index}_${
|
|
44
|
+
studio.beats[index] = { ...studio.beats[index], ...beat, audioFile: `${fileName}_${index}_${text2hash(hash_string)}` };
|
|
50
45
|
});
|
|
51
46
|
return studio;
|
|
52
47
|
};
|
|
53
|
-
exports.createOrUpdateStudioData = createOrUpdateStudioData;
|
package/lib/utils/string.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.replacementsJa = exports.recursiveSplitJa = void 0;
|
|
4
|
-
exports.splitIntoSentencesJa = splitIntoSentencesJa;
|
|
5
|
-
exports.replacePairsJa = replacePairsJa;
|
|
6
1
|
// split ja
|
|
7
|
-
function splitIntoSentencesJa(paragraph, divider, minimum) {
|
|
2
|
+
export function splitIntoSentencesJa(paragraph, divider, minimum) {
|
|
8
3
|
const sentences = paragraph
|
|
9
4
|
.split(divider) // Split by the Japanese full stop
|
|
10
5
|
.map((sentence) => sentence.trim()) // Trim whitespace
|
|
@@ -21,7 +16,7 @@ function splitIntoSentencesJa(paragraph, divider, minimum) {
|
|
|
21
16
|
}, [])
|
|
22
17
|
.map((sentence, index, array) => (index < array.length - 1 || paragraph.endsWith(divider) ? sentence + divider : sentence));
|
|
23
18
|
}
|
|
24
|
-
const recursiveSplitJa = (text) => {
|
|
19
|
+
export const recursiveSplitJa = (text) => {
|
|
25
20
|
const delimiters = ["。", "?", "!", "、"];
|
|
26
21
|
return delimiters
|
|
27
22
|
.reduce((textData, delimiter) => {
|
|
@@ -29,8 +24,7 @@ const recursiveSplitJa = (text) => {
|
|
|
29
24
|
}, [text])
|
|
30
25
|
.flat(1);
|
|
31
26
|
};
|
|
32
|
-
|
|
33
|
-
function replacePairsJa(str, replacements) {
|
|
27
|
+
export function replacePairsJa(str, replacements) {
|
|
34
28
|
replacements.forEach(({ from, to }) => {
|
|
35
29
|
// Escape any special regex characters in the 'from' string.
|
|
36
30
|
const escapedFrom = from.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -39,7 +33,7 @@ function replacePairsJa(str, replacements) {
|
|
|
39
33
|
});
|
|
40
34
|
return str;
|
|
41
35
|
}
|
|
42
|
-
|
|
36
|
+
export const replacementsJa = [
|
|
43
37
|
{ from: "Anthropic", to: "アンスロピック" },
|
|
44
38
|
{ from: "OpenAI", to: "オープンエーアイ" },
|
|
45
39
|
{ from: "AGI", to: "エージーアイ" },
|
package/lib/utils/text_hash.js
CHANGED
|
@@ -1,41 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.text2hash = void 0;
|
|
37
|
-
const crypto = __importStar(require("crypto"));
|
|
38
|
-
const text2hash = (input) => {
|
|
1
|
+
import * as crypto from "crypto";
|
|
2
|
+
export const text2hash = (input) => {
|
|
39
3
|
return crypto.createHash("sha256").update(input).digest("hex");
|
|
40
4
|
};
|
|
41
|
-
exports.text2hash = text2hash;
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mulmocast",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "lib/cli/cli.js",
|
|
6
7
|
"bin": {
|
|
7
8
|
"mulmo": "lib/cli/cli.js",
|
|
@@ -12,6 +13,7 @@
|
|
|
12
13
|
"./assets/music/StarsBeyondEx.mp3",
|
|
13
14
|
"./assets/audio/silent300.mp3",
|
|
14
15
|
"./assets/audio/silent800.mp3",
|
|
16
|
+
"./assets/html/",
|
|
15
17
|
"./assets/templates/"
|
|
16
18
|
],
|
|
17
19
|
"types": "./lib/types/index.d.ts",
|
|
@@ -26,20 +28,20 @@
|
|
|
26
28
|
"images": "npx tsx ./src/cli/cli.ts images",
|
|
27
29
|
"preprocess": "npx tsx ./src/cli/cli.ts preprocess",
|
|
28
30
|
"test": "rm -f scratchpad/test*.* && npx tsx ./src/audio.ts scripts/test/test.json && npx tsx ./src/images.ts scripts/test/test.json && npx tsx ./src/movie.ts scripts/test/test.json",
|
|
29
|
-
"ci_test": "node --test
|
|
31
|
+
"ci_test": "node --test --loader=ts-node/esm ./test/*/test_*.ts",
|
|
30
32
|
"lint": "eslint src test",
|
|
31
33
|
"build": "tsc",
|
|
32
34
|
"build_test": "tsc && git checkout -- lib/*",
|
|
33
|
-
"prompt": "npx
|
|
34
|
-
"cli": "npx
|
|
35
|
-
"scripting": "npx
|
|
35
|
+
"prompt": "npx tsx ./src/tools/prompt.ts",
|
|
36
|
+
"cli": "npx tsx ./src/cli/cli.ts",
|
|
37
|
+
"scripting": "npx tsx ./src/cli/tool-cli.ts scripting",
|
|
36
38
|
"dump_prompt": "npx tsx ./src/cli/tool-cli.ts prompt",
|
|
37
39
|
"latest": "yarn upgrade-interactive --latest",
|
|
38
40
|
"format": "prettier --write '{src,scripts,assets/templates,draft,ideason,scripts_mag2,proto,test,graphai,output}/**/*.{ts,json}'"
|
|
39
41
|
},
|
|
40
42
|
"repository": "git+ssh://git@github.com/receptron/mulmocast-cli.git",
|
|
41
43
|
"author": "snakajima",
|
|
42
|
-
"license": "
|
|
44
|
+
"license": "AGPL-3.0-only",
|
|
43
45
|
"bugs": {
|
|
44
46
|
"url": "https://github.com/receptron/mulmocast-cli/issues"
|
|
45
47
|
},
|
|
@@ -58,6 +60,7 @@
|
|
|
58
60
|
"graphai": "^1.0.12",
|
|
59
61
|
"inquirer": "^12.6.0",
|
|
60
62
|
"marked": "^15.0.11",
|
|
63
|
+
"ora": "^8.2.0",
|
|
61
64
|
"puppeteer": "^24.8.1",
|
|
62
65
|
"yargs": "^17.7.2",
|
|
63
66
|
"zod": "^3.24.4",
|
|
@@ -73,5 +76,8 @@
|
|
|
73
76
|
"ts-node": "^10.9.2",
|
|
74
77
|
"typescript": "^5.7.3",
|
|
75
78
|
"typescript-eslint": "^8.32.0"
|
|
79
|
+
},
|
|
80
|
+
"engines": {
|
|
81
|
+
"node": ">=16.0.0"
|
|
76
82
|
}
|
|
77
83
|
}
|