mulmocast 1.2.52 → 1.2.54
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/lib/actions/translate.js
CHANGED
|
@@ -8,7 +8,7 @@ import { splitText } from "../utils/string.js";
|
|
|
8
8
|
import { settings2GraphAIConfig, beatId, multiLingualObjectToArray } from "../utils/utils.js";
|
|
9
9
|
import { getMultiLingual } from "../utils/context.js";
|
|
10
10
|
import { currentMulmoScriptVersion } from "../utils/const.js";
|
|
11
|
-
import { translateApiKeyMissingError } from "../utils/error_cause.js";
|
|
11
|
+
import { translateApiKeyMissingError, hasCause, agentGenerationError, translateAction, multiLingualFileTarget } from "../utils/error_cause.js";
|
|
12
12
|
import { getOutputMultilingualFilePath, mkdir, writingMessage, hashSHA256 } from "../utils/file.js";
|
|
13
13
|
import { translateSystemPrompt, translatePrompts } from "../utils/prompt.js";
|
|
14
14
|
import { MulmoStudioContextMethods } from "../methods/mulmo_studio_context.js";
|
|
@@ -266,7 +266,12 @@ export const translateBeat = async (index, context, targetLangs, args) => {
|
|
|
266
266
|
}
|
|
267
267
|
catch (error) {
|
|
268
268
|
GraphAILogger.log(error);
|
|
269
|
-
|
|
269
|
+
if (hasCause(error) && error.cause) {
|
|
270
|
+
throw error;
|
|
271
|
+
}
|
|
272
|
+
throw new Error("Failed to translate", {
|
|
273
|
+
cause: agentGenerationError("translateBeat", translateAction, multiLingualFileTarget),
|
|
274
|
+
});
|
|
270
275
|
}
|
|
271
276
|
};
|
|
272
277
|
export const translate = async (context, args) => {
|
|
@@ -298,7 +303,12 @@ export const translate = async (context, args) => {
|
|
|
298
303
|
}
|
|
299
304
|
catch (error) {
|
|
300
305
|
MulmoStudioContextMethods.setSessionState(context, "multiLingual", false, false);
|
|
301
|
-
|
|
306
|
+
if (hasCause(error) && error.cause) {
|
|
307
|
+
throw error;
|
|
308
|
+
}
|
|
309
|
+
throw new Error("Failed to translate", {
|
|
310
|
+
cause: agentGenerationError("translateBeat", translateAction, multiLingualFileTarget),
|
|
311
|
+
});
|
|
302
312
|
}
|
|
303
313
|
return context;
|
|
304
314
|
};
|
package/lib/utils/context.d.ts
CHANGED
|
@@ -313,7 +313,7 @@ export declare const createStudioData: (_mulmoScript: MulmoScript, fileName: str
|
|
|
313
313
|
export declare const fetchScript: (isHttpPath: boolean, mulmoFilePath: string, fileOrUrl: string) => Promise<MulmoScript | null>;
|
|
314
314
|
export declare const getMultiLingual: (multilingualFilePath: string, beats: MulmoStudioBeat[]) => MulmoStudioMultiLingual;
|
|
315
315
|
export declare const getPresentationStyle: (presentationStylePath: string | undefined) => MulmoPresentationStyle | null;
|
|
316
|
-
export declare const initializeContextFromFiles: (files: FileObject, raiseError: boolean, force?: boolean, captionLang?: string, targetLang?: string) => Promise<{
|
|
316
|
+
export declare const initializeContextFromFiles: (files: FileObject, raiseError: boolean, force?: boolean, captionLang?: string, targetLang?: string, index?: number) => Promise<{
|
|
317
317
|
studio: {
|
|
318
318
|
beats: {
|
|
319
319
|
duration?: number | undefined;
|
package/lib/utils/context.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GraphAILogger } from "graphai";
|
|
1
|
+
import { GraphAILogger, isNull } from "graphai";
|
|
2
2
|
import { readMulmoScriptFile, fetchMulmoScriptFile, isFile } from "./file.js";
|
|
3
3
|
import { beatId, multiLingualObjectToArray } from "./utils.js";
|
|
4
4
|
import { mulmoStudioSchema, mulmoCaptionParamsSchema, mulmoPresentationStyleSchema } from "../types/schema.js";
|
|
@@ -112,12 +112,16 @@ export const getPresentationStyle = (presentationStylePath) => {
|
|
|
112
112
|
const jsonData = readMulmoScriptFile(presentationStylePath, "ERROR: File does not exist " + presentationStylePath)?.mulmoData ?? null;
|
|
113
113
|
return mulmoPresentationStyleSchema.parse(jsonData);
|
|
114
114
|
};
|
|
115
|
-
export const initializeContextFromFiles = async (files, raiseError, force, captionLang, targetLang) => {
|
|
115
|
+
export const initializeContextFromFiles = async (files, raiseError, force, captionLang, targetLang, index) => {
|
|
116
116
|
const { fileName, isHttpPath, fileOrUrl, mulmoFilePath, presentationStylePath, outputMultilingualFilePath } = files;
|
|
117
117
|
const mulmoScript = await fetchScript(isHttpPath, mulmoFilePath, fileOrUrl);
|
|
118
118
|
if (!mulmoScript) {
|
|
119
119
|
return null;
|
|
120
120
|
}
|
|
121
|
+
// The index param is used when you want to process only a specific beat in an app, etc. This is to avoid parser errors.
|
|
122
|
+
if (!isNull(index) && mulmoScript.beats[index]) {
|
|
123
|
+
mulmoScript.beats = [mulmoScript.beats[index]];
|
|
124
|
+
}
|
|
121
125
|
try {
|
|
122
126
|
const presentationStyle = getPresentationStyle(presentationStylePath);
|
|
123
127
|
const studio = createStudioData(mulmoScript, fileName, captionLang, presentationStyle);
|
|
@@ -62,6 +62,7 @@ export declare const translateAction = "translate";
|
|
|
62
62
|
export declare const audioFileTarget = "audioFile";
|
|
63
63
|
export declare const imageFileTarget = "imageFile";
|
|
64
64
|
export declare const movieFileTarget = "movieFile";
|
|
65
|
+
export declare const multiLingualFileTarget = "multiLingualFile";
|
|
65
66
|
export declare const videoSourceTarget = "videoSource";
|
|
66
67
|
export declare const audioSourceTarget = "audioSource";
|
|
67
68
|
export declare const codeTextTarget = "codeText";
|
package/lib/utils/error_cause.js
CHANGED
|
@@ -65,6 +65,7 @@ export const translateAction = "translate";
|
|
|
65
65
|
export const audioFileTarget = "audioFile";
|
|
66
66
|
export const imageFileTarget = "imageFile";
|
|
67
67
|
export const movieFileTarget = "movieFile";
|
|
68
|
+
export const multiLingualFileTarget = "multiLingualFile";
|
|
68
69
|
export const videoSourceTarget = "videoSource";
|
|
69
70
|
export const audioSourceTarget = "audioSource";
|
|
70
71
|
export const codeTextTarget = "codeText";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mulmocast",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.54",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.node.js",
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"prettier": "^3.6.2",
|
|
113
113
|
"tsx": "^4.20.6",
|
|
114
114
|
"typescript": "^5.9.3",
|
|
115
|
-
"typescript-eslint": "^8.
|
|
115
|
+
"typescript-eslint": "^8.46.0"
|
|
116
116
|
},
|
|
117
117
|
"engines": {
|
|
118
118
|
"node": ">=20.0.0"
|