mulmocast 1.2.8 → 1.2.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.
- package/lib/actions/pdf.js +3 -2
- package/lib/actions/translate.js +23 -8
- package/lib/index.common.d.ts +1 -0
- package/lib/index.common.js +1 -0
- package/lib/methods/mulmo_script.d.ts +2 -2
- package/lib/methods/mulmo_script.js +10 -7
- package/lib/methods/mulmo_studio_context.js +2 -1
- package/lib/types/schema.d.ts +60 -7
- package/lib/types/schema.js +3 -1
- package/lib/types/type.d.ts +3 -2
- package/lib/utils/common.d.ts +1 -0
- package/lib/utils/common.js +4 -0
- package/lib/utils/context.d.ts +4 -2
- package/lib/utils/context.js +11 -5
- package/lib/utils/utils.d.ts +12 -1
- package/lib/utils/utils.js +10 -0
- package/package.json +8 -8
- package/scripts/test/test_en.json +2 -0
package/lib/actions/pdf.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import puppeteer from "puppeteer";
|
|
4
|
-
import { GraphAILogger } from "graphai";
|
|
4
|
+
import { GraphAILogger, sleep } from "graphai";
|
|
5
5
|
import { MulmoPresentationStyleMethods } from "../methods/index.js";
|
|
6
6
|
import { localizedText, isHttp } from "../utils/utils.js";
|
|
7
7
|
import { getOutputPdfFilePath, writingMessage, getHTMLFile } from "../utils/file.js";
|
|
@@ -142,7 +142,8 @@ const generatePDF = async (context, pdfMode, pdfSize) => {
|
|
|
142
142
|
});
|
|
143
143
|
try {
|
|
144
144
|
const page = await browser.newPage();
|
|
145
|
-
await page.setContent(html, { waitUntil: "
|
|
145
|
+
await page.setContent(html, { waitUntil: "domcontentloaded" });
|
|
146
|
+
await sleep(1000);
|
|
146
147
|
await page.pdf({
|
|
147
148
|
path: outputPdfPath,
|
|
148
149
|
printBackground: true,
|
package/lib/actions/translate.js
CHANGED
|
@@ -5,7 +5,8 @@ import * as agents from "@graphai/vanilla";
|
|
|
5
5
|
import { openAIAgent } from "@graphai/openai_agent";
|
|
6
6
|
import { fileWriteAgent } from "@graphai/vanilla_node_agents";
|
|
7
7
|
import { splitText } from "../utils/string.js";
|
|
8
|
-
import { settings2GraphAIConfig } from "../utils/utils.js";
|
|
8
|
+
import { settings2GraphAIConfig, multiLingualObjectToArray } from "../utils/utils.js";
|
|
9
|
+
import { beatId } from "../utils/common.js";
|
|
9
10
|
import { getMultiLingual } from "../utils/context.js";
|
|
10
11
|
import { currentMulmoScriptVersion } from "../utils/const.js";
|
|
11
12
|
import { getOutputMultilingualFilePath, mkdir, writingMessage, hashSHA256 } from "../utils/file.js";
|
|
@@ -68,9 +69,10 @@ const beatGraph = {
|
|
|
68
69
|
// for cache
|
|
69
70
|
multiLingual: {
|
|
70
71
|
agent: (namedInputs) => {
|
|
71
|
-
const { multiLinguals, beatIndex, text } = namedInputs;
|
|
72
|
+
const { multiLinguals, beatIndex, text, beat } = namedInputs;
|
|
73
|
+
const key = beatId(beat?.id, beatIndex);
|
|
72
74
|
const cacheKey = hashSHA256(text ?? "");
|
|
73
|
-
const multiLingual = multiLinguals?.[
|
|
75
|
+
const multiLingual = multiLinguals?.[key];
|
|
74
76
|
if (!multiLingual) {
|
|
75
77
|
return { cacheKey, multiLingualTexts: {} };
|
|
76
78
|
}
|
|
@@ -86,6 +88,7 @@ const beatGraph = {
|
|
|
86
88
|
},
|
|
87
89
|
inputs: {
|
|
88
90
|
text: ":beat.text",
|
|
91
|
+
beat: ":beat",
|
|
89
92
|
beatIndex: ":__mapIndex",
|
|
90
93
|
multiLinguals: ":context.multiLingual",
|
|
91
94
|
},
|
|
@@ -141,10 +144,21 @@ const translateGraph = {
|
|
|
141
144
|
targetLangs: {},
|
|
142
145
|
mergeStudioResult: {
|
|
143
146
|
isResult: true,
|
|
144
|
-
agent:
|
|
147
|
+
agent: (namedInputs) => {
|
|
148
|
+
const { multiLingual, beats } = namedInputs;
|
|
149
|
+
const multiLingualObject = beats.reduce((tmp, beat, beatIndex) => {
|
|
150
|
+
const key = beatId(beat?.id, beatIndex);
|
|
151
|
+
tmp[key] = multiLingual[beatIndex];
|
|
152
|
+
return tmp;
|
|
153
|
+
}, {});
|
|
154
|
+
return {
|
|
155
|
+
version: currentMulmoScriptVersion,
|
|
156
|
+
multiLingual: multiLingualObject,
|
|
157
|
+
};
|
|
158
|
+
},
|
|
145
159
|
inputs: {
|
|
146
|
-
version: "1.1",
|
|
147
160
|
multiLingual: ":beatsMap.mergeMultiLingualData",
|
|
161
|
+
beats: ":context.studio.script.beats",
|
|
148
162
|
},
|
|
149
163
|
},
|
|
150
164
|
beatsMap: {
|
|
@@ -229,8 +243,9 @@ export const translateBeat = async (index, context, targetLangs, args) => {
|
|
|
229
243
|
});
|
|
230
244
|
}
|
|
231
245
|
const results = await graph.run();
|
|
232
|
-
const multiLingual = getMultiLingual(outputMultilingualFilePath, context.studio.beats
|
|
233
|
-
|
|
246
|
+
const multiLingual = getMultiLingual(outputMultilingualFilePath, context.studio.beats);
|
|
247
|
+
const key = beatId(context.studio.script.beats[index]?.id, index);
|
|
248
|
+
multiLingual[key] = results.mergeMultiLingualData;
|
|
234
249
|
const data = {
|
|
235
250
|
version: currentMulmoScriptVersion,
|
|
236
251
|
multiLingual,
|
|
@@ -263,7 +278,7 @@ export const translate = async (context, args) => {
|
|
|
263
278
|
const results = await graph.run();
|
|
264
279
|
writingMessage(outputMultilingualFilePath);
|
|
265
280
|
if (results.mergeStudioResult) {
|
|
266
|
-
context.multiLingual = results
|
|
281
|
+
context.multiLingual = multiLingualObjectToArray(results?.mergeStudioResult?.multiLingual, context.studio.script.beats);
|
|
267
282
|
}
|
|
268
283
|
}
|
|
269
284
|
finally {
|
package/lib/index.common.d.ts
CHANGED
package/lib/index.common.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type MulmoScript, type MulmoStudioMultiLingual } from "../types/index.js";
|
|
1
|
+
import { type MulmoStudioBeat, type MulmoScript, type MulmoStudioMultiLingual } from "../types/index.js";
|
|
2
2
|
export declare const MulmoScriptMethods: {
|
|
3
3
|
validate(script: any): MulmoScript;
|
|
4
4
|
};
|
|
5
5
|
export declare const MulmoStudioMultiLingualMethod: {
|
|
6
|
-
validate(jsonData: any,
|
|
6
|
+
validate(jsonData: any, beats: MulmoStudioBeat[]): MulmoStudioMultiLingual;
|
|
7
7
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GraphAILogger } from "graphai";
|
|
2
2
|
import { mulmoScriptSchema, mulmoStudioMultiLingualFileSchema } from "../types/index.js";
|
|
3
|
+
import { beatId } from "../utils/common.js";
|
|
3
4
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
5
|
const validate_1_0 = (script) => {
|
|
5
6
|
if (script.speechParams?.provider) {
|
|
@@ -35,17 +36,19 @@ export const MulmoScriptMethods = {
|
|
|
35
36
|
};
|
|
36
37
|
export const MulmoStudioMultiLingualMethod = {
|
|
37
38
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
-
validate(jsonData,
|
|
39
|
+
validate(jsonData, beats) {
|
|
39
40
|
// TODO version check
|
|
40
41
|
const result = mulmoStudioMultiLingualFileSchema.safeParse(jsonData);
|
|
41
42
|
if (!result.success) {
|
|
42
43
|
GraphAILogger.warn("multiLingual file validation failed.");
|
|
43
44
|
}
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
const multiLingual = result.success ? result.data.multiLingual : {};
|
|
46
|
+
beats.forEach((beat, index) => {
|
|
47
|
+
const key = beatId(beat?.id, index);
|
|
48
|
+
if (!multiLingual[key]) {
|
|
49
|
+
multiLingual[key] = { multiLingualTexts: {} };
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return multiLingual;
|
|
50
53
|
},
|
|
51
54
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
+
import { beatId } from "../utils/common.js";
|
|
2
3
|
import { GraphAILogger } from "graphai";
|
|
3
4
|
const sessionProgressCallbacks = new Set();
|
|
4
5
|
export const addSessionProgressCallback = (cb) => {
|
|
@@ -51,7 +52,7 @@ export const MulmoStudioContextMethods = {
|
|
|
51
52
|
notifyStateChange(context, sessionType);
|
|
52
53
|
},
|
|
53
54
|
setBeatSessionState(context, sessionType, index, id, value) {
|
|
54
|
-
const key = id
|
|
55
|
+
const key = beatId(id, index);
|
|
55
56
|
if (value) {
|
|
56
57
|
if (!context.sessionState.inBeatSession[sessionType]) {
|
|
57
58
|
context.sessionState.inBeatSession[sessionType] = {};
|
package/lib/types/schema.d.ts
CHANGED
|
@@ -5689,6 +5689,7 @@ export declare const mulmoScriptSchema: z.ZodObject<{
|
|
|
5689
5689
|
__test_invalid__?: boolean | undefined;
|
|
5690
5690
|
}>;
|
|
5691
5691
|
export declare const mulmoStudioBeatSchema: z.ZodObject<{
|
|
5692
|
+
id: z.ZodOptional<z.ZodString>;
|
|
5692
5693
|
hash: z.ZodOptional<z.ZodString>;
|
|
5693
5694
|
duration: z.ZodOptional<z.ZodNumber>;
|
|
5694
5695
|
startAt: z.ZodOptional<z.ZodNumber>;
|
|
@@ -5705,6 +5706,7 @@ export declare const mulmoStudioBeatSchema: z.ZodObject<{
|
|
|
5705
5706
|
htmlImageFile: z.ZodOptional<z.ZodString>;
|
|
5706
5707
|
}, "strict", z.ZodTypeAny, {
|
|
5707
5708
|
duration?: number | undefined;
|
|
5709
|
+
id?: string | undefined;
|
|
5708
5710
|
startAt?: number | undefined;
|
|
5709
5711
|
hash?: string | undefined;
|
|
5710
5712
|
audioDuration?: number | undefined;
|
|
@@ -5720,6 +5722,7 @@ export declare const mulmoStudioBeatSchema: z.ZodObject<{
|
|
|
5720
5722
|
htmlImageFile?: string | undefined;
|
|
5721
5723
|
}, {
|
|
5722
5724
|
duration?: number | undefined;
|
|
5725
|
+
id?: string | undefined;
|
|
5723
5726
|
startAt?: number | undefined;
|
|
5724
5727
|
hash?: string | undefined;
|
|
5725
5728
|
audioDuration?: number | undefined;
|
|
@@ -5779,7 +5782,7 @@ export declare const mulmoStudioMultiLingualDataSchema: z.ZodObject<{
|
|
|
5779
5782
|
}>;
|
|
5780
5783
|
cacheKey?: string | undefined;
|
|
5781
5784
|
}>;
|
|
5782
|
-
export declare const
|
|
5785
|
+
export declare const mulmoStudioMultiLingualArraySchema: z.ZodArray<z.ZodObject<{
|
|
5783
5786
|
multiLingualTexts: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
5784
5787
|
text: z.ZodString;
|
|
5785
5788
|
lang: z.ZodString;
|
|
@@ -5824,9 +5827,54 @@ export declare const mulmoStudioMultiLingualSchema: z.ZodArray<z.ZodObject<{
|
|
|
5824
5827
|
}>;
|
|
5825
5828
|
cacheKey?: string | undefined;
|
|
5826
5829
|
}>, "many">;
|
|
5830
|
+
export declare const mulmoStudioMultiLingualSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
5831
|
+
multiLingualTexts: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
5832
|
+
text: z.ZodString;
|
|
5833
|
+
lang: z.ZodString;
|
|
5834
|
+
texts: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
5835
|
+
ttsTexts: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
5836
|
+
cacheKey: z.ZodString;
|
|
5837
|
+
duration: z.ZodOptional<z.ZodNumber>;
|
|
5838
|
+
}, "strict", z.ZodTypeAny, {
|
|
5839
|
+
text: string;
|
|
5840
|
+
lang: string;
|
|
5841
|
+
cacheKey: string;
|
|
5842
|
+
texts?: string[] | undefined;
|
|
5843
|
+
ttsTexts?: string[] | undefined;
|
|
5844
|
+
duration?: number | undefined;
|
|
5845
|
+
}, {
|
|
5846
|
+
text: string;
|
|
5847
|
+
lang: string;
|
|
5848
|
+
cacheKey: string;
|
|
5849
|
+
texts?: string[] | undefined;
|
|
5850
|
+
ttsTexts?: string[] | undefined;
|
|
5851
|
+
duration?: number | undefined;
|
|
5852
|
+
}>>;
|
|
5853
|
+
cacheKey: z.ZodOptional<z.ZodString>;
|
|
5854
|
+
}, "strip", z.ZodTypeAny, {
|
|
5855
|
+
multiLingualTexts: Record<string, {
|
|
5856
|
+
text: string;
|
|
5857
|
+
lang: string;
|
|
5858
|
+
cacheKey: string;
|
|
5859
|
+
texts?: string[] | undefined;
|
|
5860
|
+
ttsTexts?: string[] | undefined;
|
|
5861
|
+
duration?: number | undefined;
|
|
5862
|
+
}>;
|
|
5863
|
+
cacheKey?: string | undefined;
|
|
5864
|
+
}, {
|
|
5865
|
+
multiLingualTexts: Record<string, {
|
|
5866
|
+
text: string;
|
|
5867
|
+
lang: string;
|
|
5868
|
+
cacheKey: string;
|
|
5869
|
+
texts?: string[] | undefined;
|
|
5870
|
+
ttsTexts?: string[] | undefined;
|
|
5871
|
+
duration?: number | undefined;
|
|
5872
|
+
}>;
|
|
5873
|
+
cacheKey?: string | undefined;
|
|
5874
|
+
}>>;
|
|
5827
5875
|
export declare const mulmoStudioMultiLingualFileSchema: z.ZodObject<{
|
|
5828
5876
|
version: z.ZodLiteral<"1.1">;
|
|
5829
|
-
multiLingual: z.
|
|
5877
|
+
multiLingual: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
5830
5878
|
multiLingualTexts: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
5831
5879
|
text: z.ZodString;
|
|
5832
5880
|
lang: z.ZodString;
|
|
@@ -5870,10 +5918,10 @@ export declare const mulmoStudioMultiLingualFileSchema: z.ZodObject<{
|
|
|
5870
5918
|
duration?: number | undefined;
|
|
5871
5919
|
}>;
|
|
5872
5920
|
cacheKey?: string | undefined;
|
|
5873
|
-
}
|
|
5921
|
+
}>>;
|
|
5874
5922
|
}, "strip", z.ZodTypeAny, {
|
|
5875
5923
|
version: "1.1";
|
|
5876
|
-
multiLingual: {
|
|
5924
|
+
multiLingual: Record<string, {
|
|
5877
5925
|
multiLingualTexts: Record<string, {
|
|
5878
5926
|
text: string;
|
|
5879
5927
|
lang: string;
|
|
@@ -5883,10 +5931,10 @@ export declare const mulmoStudioMultiLingualFileSchema: z.ZodObject<{
|
|
|
5883
5931
|
duration?: number | undefined;
|
|
5884
5932
|
}>;
|
|
5885
5933
|
cacheKey?: string | undefined;
|
|
5886
|
-
}
|
|
5934
|
+
}>;
|
|
5887
5935
|
}, {
|
|
5888
5936
|
version: "1.1";
|
|
5889
|
-
multiLingual: {
|
|
5937
|
+
multiLingual: Record<string, {
|
|
5890
5938
|
multiLingualTexts: Record<string, {
|
|
5891
5939
|
text: string;
|
|
5892
5940
|
lang: string;
|
|
@@ -5896,7 +5944,7 @@ export declare const mulmoStudioMultiLingualFileSchema: z.ZodObject<{
|
|
|
5896
5944
|
duration?: number | undefined;
|
|
5897
5945
|
}>;
|
|
5898
5946
|
cacheKey?: string | undefined;
|
|
5899
|
-
}
|
|
5947
|
+
}>;
|
|
5900
5948
|
}>;
|
|
5901
5949
|
export declare const mulmoSessionStateSchema: z.ZodObject<{
|
|
5902
5950
|
inSession: z.ZodObject<{
|
|
@@ -8315,6 +8363,7 @@ export declare const mulmoStudioSchema: z.ZodObject<{
|
|
|
8315
8363
|
}>;
|
|
8316
8364
|
filename: z.ZodString;
|
|
8317
8365
|
beats: z.ZodArray<z.ZodObject<{
|
|
8366
|
+
id: z.ZodOptional<z.ZodString>;
|
|
8318
8367
|
hash: z.ZodOptional<z.ZodString>;
|
|
8319
8368
|
duration: z.ZodOptional<z.ZodNumber>;
|
|
8320
8369
|
startAt: z.ZodOptional<z.ZodNumber>;
|
|
@@ -8331,6 +8380,7 @@ export declare const mulmoStudioSchema: z.ZodObject<{
|
|
|
8331
8380
|
htmlImageFile: z.ZodOptional<z.ZodString>;
|
|
8332
8381
|
}, "strict", z.ZodTypeAny, {
|
|
8333
8382
|
duration?: number | undefined;
|
|
8383
|
+
id?: string | undefined;
|
|
8334
8384
|
startAt?: number | undefined;
|
|
8335
8385
|
hash?: string | undefined;
|
|
8336
8386
|
audioDuration?: number | undefined;
|
|
@@ -8346,6 +8396,7 @@ export declare const mulmoStudioSchema: z.ZodObject<{
|
|
|
8346
8396
|
htmlImageFile?: string | undefined;
|
|
8347
8397
|
}, {
|
|
8348
8398
|
duration?: number | undefined;
|
|
8399
|
+
id?: string | undefined;
|
|
8349
8400
|
startAt?: number | undefined;
|
|
8350
8401
|
hash?: string | undefined;
|
|
8351
8402
|
audioDuration?: number | undefined;
|
|
@@ -8363,6 +8414,7 @@ export declare const mulmoStudioSchema: z.ZodObject<{
|
|
|
8363
8414
|
}, "strict", z.ZodTypeAny, {
|
|
8364
8415
|
beats: {
|
|
8365
8416
|
duration?: number | undefined;
|
|
8417
|
+
id?: string | undefined;
|
|
8366
8418
|
startAt?: number | undefined;
|
|
8367
8419
|
hash?: string | undefined;
|
|
8368
8420
|
audioDuration?: number | undefined;
|
|
@@ -8705,6 +8757,7 @@ export declare const mulmoStudioSchema: z.ZodObject<{
|
|
|
8705
8757
|
}, {
|
|
8706
8758
|
beats: {
|
|
8707
8759
|
duration?: number | undefined;
|
|
8760
|
+
id?: string | undefined;
|
|
8708
8761
|
startAt?: number | undefined;
|
|
8709
8762
|
hash?: string | undefined;
|
|
8710
8763
|
audioDuration?: number | undefined;
|
package/lib/types/schema.js
CHANGED
|
@@ -383,6 +383,7 @@ export const mulmoScriptSchema = mulmoPresentationStyleSchema
|
|
|
383
383
|
.strict();
|
|
384
384
|
export const mulmoStudioBeatSchema = z
|
|
385
385
|
.object({
|
|
386
|
+
id: z.string().optional().describe("Unique identifier for the beat."),
|
|
386
387
|
hash: z.string().optional(),
|
|
387
388
|
duration: z.number().optional(),
|
|
388
389
|
startAt: z.number().optional(),
|
|
@@ -403,7 +404,8 @@ export const mulmoStudioMultiLingualDataSchema = z.object({
|
|
|
403
404
|
multiLingualTexts: multiLingualTextsSchema,
|
|
404
405
|
cacheKey: z.string().optional(),
|
|
405
406
|
});
|
|
406
|
-
export const
|
|
407
|
+
export const mulmoStudioMultiLingualArraySchema = z.array(mulmoStudioMultiLingualDataSchema).min(1);
|
|
408
|
+
export const mulmoStudioMultiLingualSchema = z.record(z.string(), mulmoStudioMultiLingualDataSchema);
|
|
407
409
|
export const mulmoStudioMultiLingualFileSchema = z.object({
|
|
408
410
|
version: z.literal(currentMulmoScriptVersion),
|
|
409
411
|
multiLingual: mulmoStudioMultiLingualSchema,
|
package/lib/types/type.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CallbackFunction } from "graphai";
|
|
2
|
-
import { langSchema, localizedTextSchema, mulmoBeatSchema, mulmoScriptSchema, mulmoStudioSchema, mulmoStudioBeatSchema, mulmoStoryboardSchema, mulmoStoryboardSceneSchema, mulmoStudioMultiLingualSchema, mulmoStudioMultiLingualDataSchema, mulmoStudioMultiLingualFileSchema, speakerDictionarySchema, mulmoImageParamsSchema, mulmoImageParamsImagesSchema, mulmoFillOptionSchema, mulmoMovieParamsSchema, textSlideParamsSchema, speechOptionsSchema, speakerDataSchema, mulmoCanvasDimensionSchema, mulmoPromptTemplateSchema, mulmoPromptTemplateFileSchema, text2ImageProviderSchema, text2HtmlImageProviderSchema, text2MovieProviderSchema, text2SpeechProviderSchema, mulmoPresentationStyleSchema, multiLingualTextsSchema, mulmoImageAssetSchema, mulmoMermaidMediaSchema, mulmoTextSlideMediaSchema, mulmoMarkdownMediaSchema, mulmoImageMediaSchema, mulmoChartMediaSchema, mediaSourceSchema, mulmoSessionStateSchema, mulmoOpenAIImageModelSchema, mulmoGoogleImageModelSchema, mulmoGoogleMovieModelSchema, mulmoReplicateMovieModelSchema, mulmoImagePromptMediaSchema } from "./schema.js";
|
|
2
|
+
import { langSchema, localizedTextSchema, mulmoBeatSchema, mulmoScriptSchema, mulmoStudioSchema, mulmoStudioBeatSchema, mulmoStoryboardSchema, mulmoStoryboardSceneSchema, mulmoStudioMultiLingualSchema, mulmoStudioMultiLingualArraySchema, mulmoStudioMultiLingualDataSchema, mulmoStudioMultiLingualFileSchema, speakerDictionarySchema, mulmoImageParamsSchema, mulmoImageParamsImagesSchema, mulmoFillOptionSchema, mulmoMovieParamsSchema, textSlideParamsSchema, speechOptionsSchema, speakerDataSchema, mulmoCanvasDimensionSchema, mulmoPromptTemplateSchema, mulmoPromptTemplateFileSchema, text2ImageProviderSchema, text2HtmlImageProviderSchema, text2MovieProviderSchema, text2SpeechProviderSchema, mulmoPresentationStyleSchema, multiLingualTextsSchema, mulmoImageAssetSchema, mulmoMermaidMediaSchema, mulmoTextSlideMediaSchema, mulmoMarkdownMediaSchema, mulmoImageMediaSchema, mulmoChartMediaSchema, mediaSourceSchema, mulmoSessionStateSchema, mulmoOpenAIImageModelSchema, mulmoGoogleImageModelSchema, mulmoGoogleMovieModelSchema, mulmoReplicateMovieModelSchema, mulmoImagePromptMediaSchema } from "./schema.js";
|
|
3
3
|
import { pdf_modes, pdf_sizes, storyToScriptGenerateMode } from "../utils/const.js";
|
|
4
4
|
import type { LLM } from "../utils/provider2agent.js";
|
|
5
5
|
import { z } from "zod";
|
|
@@ -28,6 +28,7 @@ export type MulmoStudio = z.infer<typeof mulmoStudioSchema>;
|
|
|
28
28
|
export type MulmoPromptTemplate = z.infer<typeof mulmoPromptTemplateSchema>;
|
|
29
29
|
export type MulmoPromptTemplateFile = z.infer<typeof mulmoPromptTemplateFileSchema>;
|
|
30
30
|
export type MulmoStudioMultiLingual = z.infer<typeof mulmoStudioMultiLingualSchema>;
|
|
31
|
+
export type MulmoStudioMultiLingualArray = z.infer<typeof mulmoStudioMultiLingualArraySchema>;
|
|
31
32
|
export type MulmoStudioMultiLingualData = z.infer<typeof mulmoStudioMultiLingualDataSchema>;
|
|
32
33
|
export type MulmoStudioMultiLingualFile = z.infer<typeof mulmoStudioMultiLingualFileSchema>;
|
|
33
34
|
export type MultiLingualTexts = z.infer<typeof multiLingualTextsSchema>;
|
|
@@ -59,7 +60,7 @@ export type MulmoStudioContext = {
|
|
|
59
60
|
force: boolean;
|
|
60
61
|
sessionState: MulmoSessionState;
|
|
61
62
|
presentationStyle: MulmoPresentationStyle;
|
|
62
|
-
multiLingual:
|
|
63
|
+
multiLingual: MulmoStudioMultiLingualArray;
|
|
63
64
|
};
|
|
64
65
|
export type ScriptingParams = {
|
|
65
66
|
urls: string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const beatId: (id: string | undefined, index: number) => string;
|
package/lib/utils/context.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { MulmoScript, MulmoPresentationStyle, MulmoStudioMultiLingual, FileObject } from "../types/type.js";
|
|
1
|
+
import type { MulmoStudioBeat, MulmoScript, MulmoPresentationStyle, MulmoStudioMultiLingual, FileObject } from "../types/type.js";
|
|
2
2
|
export declare const createStudioData: (_mulmoScript: MulmoScript, fileName: string, videoCaptionLang?: string, presentationStyle?: MulmoPresentationStyle | null) => {
|
|
3
3
|
beats: {
|
|
4
4
|
duration?: number | undefined;
|
|
5
|
+
id?: string | undefined;
|
|
5
6
|
startAt?: number | undefined;
|
|
6
7
|
hash?: string | undefined;
|
|
7
8
|
audioDuration?: number | undefined;
|
|
@@ -343,12 +344,13 @@ export declare const createStudioData: (_mulmoScript: MulmoScript, fileName: str
|
|
|
343
344
|
filename: string;
|
|
344
345
|
};
|
|
345
346
|
export declare const fetchScript: (isHttpPath: boolean, mulmoFilePath: string, fileOrUrl: string) => Promise<MulmoScript | null>;
|
|
346
|
-
export declare const getMultiLingual: (multilingualFilePath: string,
|
|
347
|
+
export declare const getMultiLingual: (multilingualFilePath: string, beats: MulmoStudioBeat[]) => MulmoStudioMultiLingual;
|
|
347
348
|
export declare const getPresentationStyle: (presentationStylePath: string | undefined) => MulmoPresentationStyle | null;
|
|
348
349
|
export declare const initializeContextFromFiles: (files: FileObject, raiseError: boolean, force?: boolean, captionLang?: string, targetLang?: string) => Promise<{
|
|
349
350
|
studio: {
|
|
350
351
|
beats: {
|
|
351
352
|
duration?: number | undefined;
|
|
353
|
+
id?: string | undefined;
|
|
352
354
|
startAt?: number | undefined;
|
|
353
355
|
hash?: string | undefined;
|
|
354
356
|
audioDuration?: number | undefined;
|
package/lib/utils/context.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { GraphAILogger } from "graphai";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import { readMulmoScriptFile, fetchMulmoScriptFile } from "./file.js";
|
|
4
|
+
import { multiLingualObjectToArray } from "./utils.js";
|
|
5
|
+
import { beatId } from "./common.js";
|
|
4
6
|
import { mulmoStudioSchema, mulmoCaptionParamsSchema, mulmoPresentationStyleSchema } from "../types/schema.js";
|
|
5
7
|
import { MulmoPresentationStyleMethods, MulmoScriptMethods, MulmoStudioMultiLingualMethod } from "../methods/index.js";
|
|
6
8
|
const mulmoCredit = (speaker) => {
|
|
@@ -87,12 +89,16 @@ export const fetchScript = async (isHttpPath, mulmoFilePath, fileOrUrl) => {
|
|
|
87
89
|
}
|
|
88
90
|
return readMulmoScriptFile(mulmoFilePath, "ERROR: File does not exist " + mulmoFilePath)?.mulmoData ?? null;
|
|
89
91
|
};
|
|
90
|
-
export const getMultiLingual = (multilingualFilePath,
|
|
92
|
+
export const getMultiLingual = (multilingualFilePath, beats) => {
|
|
91
93
|
if (!fs.existsSync(multilingualFilePath)) {
|
|
92
|
-
return
|
|
94
|
+
return beats.reduce((tmp, beat, index) => {
|
|
95
|
+
const key = beatId(beat?.id, index);
|
|
96
|
+
tmp[key] = { multiLingualTexts: {} };
|
|
97
|
+
return tmp;
|
|
98
|
+
}, {});
|
|
93
99
|
}
|
|
94
100
|
const jsonData = readMulmoScriptFile(multilingualFilePath, "ERROR: File does not exist " + multilingualFilePath)?.mulmoData ?? null;
|
|
95
|
-
return MulmoStudioMultiLingualMethod.validate(jsonData,
|
|
101
|
+
return MulmoStudioMultiLingualMethod.validate(jsonData, beats);
|
|
96
102
|
};
|
|
97
103
|
export const getPresentationStyle = (presentationStylePath) => {
|
|
98
104
|
if (!presentationStylePath) {
|
|
@@ -113,10 +119,10 @@ export const initializeContextFromFiles = async (files, raiseError, force, capti
|
|
|
113
119
|
try {
|
|
114
120
|
const presentationStyle = getPresentationStyle(presentationStylePath);
|
|
115
121
|
const studio = createStudioData(mulmoScript, fileName, captionLang, presentationStyle);
|
|
116
|
-
const multiLingual = getMultiLingual(outputMultilingualFilePath, studio.beats
|
|
122
|
+
const multiLingual = getMultiLingual(outputMultilingualFilePath, studio.script.beats);
|
|
117
123
|
return {
|
|
118
124
|
studio,
|
|
119
|
-
multiLingual,
|
|
125
|
+
multiLingual: multiLingualObjectToArray(multiLingual, studio.script.beats),
|
|
120
126
|
fileDirs: files,
|
|
121
127
|
presentationStyle: presentationStyle ?? studio.script,
|
|
122
128
|
sessionState: initSessionState(),
|
package/lib/utils/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConfigDataDictionary, DefaultConfigData } from "graphai";
|
|
2
|
-
import { MulmoBeat, MulmoStudioMultiLingualData } from "../types/index.js";
|
|
2
|
+
import { MulmoBeat, MulmoStudioBeat, MulmoStudioMultiLingual, MulmoStudioMultiLingualData } from "../types/index.js";
|
|
3
3
|
import type { LLM } from "./provider2agent.js";
|
|
4
4
|
export declare const llmPair: (_llm?: LLM, _model?: string) => {
|
|
5
5
|
agent: "mediaMockAgent" | "openAIAgent" | "anthropicAgent" | "geminiAgent" | "groqAgent";
|
|
@@ -19,4 +19,15 @@ type CleanableObject = {
|
|
|
19
19
|
[key: string]: CleanableValue;
|
|
20
20
|
};
|
|
21
21
|
export declare const deepClean: <T extends CleanableValue>(input: T) => T | undefined;
|
|
22
|
+
export declare const multiLingualObjectToArray: (multiLingual: MulmoStudioMultiLingual | undefined, beats: MulmoStudioBeat[]) => {
|
|
23
|
+
multiLingualTexts: Record<string, {
|
|
24
|
+
text: string;
|
|
25
|
+
lang: string;
|
|
26
|
+
cacheKey: string;
|
|
27
|
+
texts?: string[] | undefined;
|
|
28
|
+
ttsTexts?: string[] | undefined;
|
|
29
|
+
duration?: number | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
cacheKey?: string | undefined;
|
|
32
|
+
}[];
|
|
22
33
|
export {};
|
package/lib/utils/utils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as crypto from "crypto";
|
|
2
2
|
import { provider2LLMAgent } from "./provider2agent.js";
|
|
3
|
+
import { beatId } from "./common.js";
|
|
3
4
|
export const llmPair = (_llm, _model) => {
|
|
4
5
|
const llmKey = _llm ?? "openai";
|
|
5
6
|
const agent = provider2LLMAgent[llmKey]?.agentName ?? provider2LLMAgent.openai.agentName;
|
|
@@ -117,3 +118,12 @@ export const deepClean = (input) => {
|
|
|
117
118
|
}
|
|
118
119
|
return input;
|
|
119
120
|
};
|
|
121
|
+
export const multiLingualObjectToArray = (multiLingual, beats) => {
|
|
122
|
+
return beats.map((beat, index) => {
|
|
123
|
+
const key = beatId(beat?.id, index);
|
|
124
|
+
if (multiLingual?.[key]) {
|
|
125
|
+
return multiLingual[key];
|
|
126
|
+
}
|
|
127
|
+
return { multiLingualTexts: {} };
|
|
128
|
+
});
|
|
129
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mulmocast",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.node.js",
|
|
@@ -77,9 +77,9 @@
|
|
|
77
77
|
"@graphai/stream_agent_filter": "^2.0.2",
|
|
78
78
|
"@graphai/vanilla": "^2.0.12",
|
|
79
79
|
"@graphai/vanilla_node_agents": "^2.0.4",
|
|
80
|
-
"@inquirer/input": "^4.2.
|
|
81
|
-
"@inquirer/select": "^4.3.
|
|
82
|
-
"@modelcontextprotocol/sdk": "^1.17.
|
|
80
|
+
"@inquirer/input": "^4.2.2",
|
|
81
|
+
"@inquirer/select": "^4.3.2",
|
|
82
|
+
"@modelcontextprotocol/sdk": "^1.17.4",
|
|
83
83
|
"@tavily/core": "^0.5.11",
|
|
84
84
|
"canvas": "^3.2.0",
|
|
85
85
|
"clipboardy": "^4.0.0",
|
|
@@ -101,15 +101,15 @@
|
|
|
101
101
|
"@receptron/test_utils": "^2.0.3",
|
|
102
102
|
"@types/fluent-ffmpeg": "^2.1.26",
|
|
103
103
|
"@types/yargs": "^17.0.33",
|
|
104
|
-
"eslint": "^9.
|
|
104
|
+
"eslint": "^9.34.0",
|
|
105
105
|
"eslint-config-prettier": "^10.1.8",
|
|
106
106
|
"eslint-plugin-prettier": "^5.5.4",
|
|
107
|
-
"eslint-plugin-sonarjs": "^3.0.
|
|
107
|
+
"eslint-plugin-sonarjs": "^3.0.5",
|
|
108
108
|
"prettier": "^3.6.2",
|
|
109
109
|
"ts-node": "^10.9.2",
|
|
110
|
-
"tsx": "^4.20.
|
|
110
|
+
"tsx": "^4.20.5",
|
|
111
111
|
"typescript": "^5.9.2",
|
|
112
|
-
"typescript-eslint": "^8.
|
|
112
|
+
"typescript-eslint": "^8.41.0"
|
|
113
113
|
},
|
|
114
114
|
"engines": {
|
|
115
115
|
"node": ">=18.0.0"
|