mulmocast 1.1.9 → 1.1.10

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.
@@ -46,6 +46,10 @@ export declare const translateTextGraph: {
46
46
  };
47
47
  };
48
48
  };
49
+ export declare const getOutputMultilingualFilePathAndMkdir: (context: MulmoStudioContext) => {
50
+ outputMultilingualFilePath: string;
51
+ outDirPath: string;
52
+ };
49
53
  export declare const translateBeat: (index: number, context: MulmoStudioContext, targetLangs: string[], args?: {
50
54
  settings?: Record<string, string>;
51
55
  callbacks?: CallbackFunction[];
@@ -1,5 +1,4 @@
1
1
  import "dotenv/config";
2
- import { createHash } from "crypto";
3
2
  import fs from "fs";
4
3
  import { GraphAI, assert, isNull, GraphAILogger } from "graphai";
5
4
  import * as agents from "@graphai/vanilla";
@@ -9,13 +8,10 @@ import { splitText } from "../utils/string.js";
9
8
  import { settings2GraphAIConfig } from "../utils/utils.js";
10
9
  import { getMultiLingual } from "../utils/context.js";
11
10
  import { currentMulmoScriptVersion } from "../utils/const.js";
12
- import { getOutputMultilingualFilePath, mkdir, writingMessage } from "../utils/file.js";
11
+ import { getOutputMultilingualFilePath, mkdir, writingMessage, hashSHA256 } from "../utils/file.js";
13
12
  import { translateSystemPrompt, translatePrompts } from "../utils/prompt.js";
14
13
  import { MulmoStudioContextMethods } from "../methods/mulmo_studio_context.js";
15
14
  const vanillaAgents = agents.default ?? agents;
16
- const hashSHA256 = (text) => {
17
- return createHash("sha256").update(text, "utf8").digest("hex");
18
- };
19
15
  // 1. translateGraph / map each beats.
20
16
  // 2. beatGraph / map each target lang.
21
17
  // 3. translateTextGraph / translate text.
@@ -202,6 +198,13 @@ const agentFilters = [
202
198
  nodeIds: ["localizedText"],
203
199
  },
204
200
  ];
201
+ export const getOutputMultilingualFilePathAndMkdir = (context) => {
202
+ const fileName = MulmoStudioContextMethods.getFileName(context);
203
+ const outDirPath = MulmoStudioContextMethods.getOutDirPath(context);
204
+ const outputMultilingualFilePath = getOutputMultilingualFilePath(outDirPath, fileName);
205
+ mkdir(outDirPath);
206
+ return { outputMultilingualFilePath, outDirPath };
207
+ };
205
208
  export const translateBeat = async (index, context, targetLangs, args) => {
206
209
  const { settings, callbacks } = args ?? {};
207
210
  // Validate inputs
@@ -212,10 +215,7 @@ export const translateBeat = async (index, context, targetLangs, args) => {
212
215
  throw new Error("targetLangs must be a non-empty array");
213
216
  }
214
217
  try {
215
- const fileName = MulmoStudioContextMethods.getFileName(context);
216
- const outDirPath = MulmoStudioContextMethods.getOutDirPath(context);
217
- const outputMultilingualFilePath = getOutputMultilingualFilePath(outDirPath, fileName);
218
- mkdir(outDirPath);
218
+ const { outputMultilingualFilePath } = getOutputMultilingualFilePathAndMkdir(context);
219
219
  const config = settings2GraphAIConfig(settings, process.env);
220
220
  assert(!!config?.openAIAgent?.apiKey, "The OPENAI_API_KEY environment variable is missing or empty");
221
221
  const graph = new GraphAI(beatGraph, { ...vanillaAgents, fileWriteAgent, openAIAgent }, { agentFilters, config });
@@ -246,10 +246,7 @@ export const translate = async (context, args) => {
246
246
  const { settings, callbacks } = args ?? {};
247
247
  try {
248
248
  MulmoStudioContextMethods.setSessionState(context, "multiLingual", true);
249
- const fileName = MulmoStudioContextMethods.getFileName(context);
250
- const outDirPath = MulmoStudioContextMethods.getOutDirPath(context);
251
- const outputMultilingualFilePath = getOutputMultilingualFilePath(outDirPath, fileName);
252
- mkdir(outDirPath);
249
+ const { outputMultilingualFilePath, outDirPath } = getOutputMultilingualFilePathAndMkdir(context);
253
250
  const targetLangs = [...new Set([context.lang, context.studio.script.captionParams?.lang].filter((x) => !isNull(x)))];
254
251
  const config = settings2GraphAIConfig(settings, process.env);
255
252
  assert(!!config?.openAIAgent?.apiKey, "The OPENAI_API_KEY environment variable is missing or empty");
@@ -1,3 +1,4 @@
1
+ import { GraphAILogger } from "graphai";
1
2
  import { mulmoScriptSchema, mulmoStudioMultiLingualFileSchema } from "../types/index.js";
2
3
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3
4
  const validate_1_0 = (script) => {
@@ -37,6 +38,9 @@ export const MulmoStudioMultiLingualMethod = {
37
38
  validate(jsonData, studioBeatsLength) {
38
39
  // TODO version check
39
40
  const result = mulmoStudioMultiLingualFileSchema.safeParse(jsonData);
41
+ if (!result.success) {
42
+ GraphAILogger.warn("multiLingual file validation failed.");
43
+ }
40
44
  const dataSet = result.success ? result.data.multiLingual : [];
41
45
  while (dataSet.length < studioBeatsLength) {
42
46
  dataSet.push({ multiLingualTexts: {} });
@@ -48,3 +48,4 @@ export declare const getAvailableScriptTemplates: () => MulmoScript[];
48
48
  export declare const writingMessage: (filePath: string) => void;
49
49
  export declare const readAndParseJson: <S extends ZodSchema<any>>(filePath: string, schema: S) => ReturnType<S["parse"]>;
50
50
  export declare const generateTimestampedFileName: (prefix: string) => string;
51
+ export declare const hashSHA256: (text: string) => string;
package/lib/utils/file.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
+ import { createHash } from "crypto";
3
4
  import { parse as yamlParse } from "yaml";
4
5
  import { fileURLToPath } from "url";
5
6
  import { GraphAILogger } from "graphai";
@@ -226,3 +227,6 @@ export const generateTimestampedFileName = (prefix) => {
226
227
  const pad = (n) => n.toString().padStart(2, "0");
227
228
  return `${prefix}_${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}_${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
228
229
  };
230
+ export const hashSHA256 = (text) => {
231
+ return createHash("sha256").update(text, "utf8").digest("hex");
232
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mulmocast",
3
- "version": "1.1.9",
3
+ "version": "1.1.10",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "lib/index.node.js",
@@ -26,6 +26,7 @@
26
26
  "./scripts/test",
27
27
  "./assets/audio/silent60sec.mp3",
28
28
  "./assets/html/",
29
+ "./assets/images/",
29
30
  "./assets/templates/"
30
31
  ],
31
32
  "directories": {
@@ -82,8 +83,8 @@
82
83
  "fluent-ffmpeg": "^2.1.3",
83
84
  "google-auth-library": "^10.1.0",
84
85
  "graphai": "^2.0.13",
85
- "inquirer": "^12.7.0",
86
- "marked": "^16.1.1",
86
+ "inquirer": "^12.9.0",
87
+ "marked": "^16.1.2",
87
88
  "ora": "^8.2.0",
88
89
  "puppeteer": "^24.15.0",
89
90
  "replicate": "^1.0.1",
@@ -106,7 +107,7 @@
106
107
  "ts-node": "^10.9.2",
107
108
  "tsx": "^4.20.3",
108
109
  "typescript": "^5.9.2",
109
- "typescript-eslint": "^8.37.0"
110
+ "typescript-eslint": "^8.39.0"
110
111
  },
111
112
  "engines": {
112
113
  "node": ">=18.0.0"
@@ -2,6 +2,9 @@
2
2
  "$mulmocast": {
3
3
  "version": "1.1"
4
4
  },
5
+ "audioParams": {
6
+ "bgmVolume": 0
7
+ },
5
8
  "lang": "en",
6
9
  "beats": [
7
10
  {