mulmocast 1.2.8 → 1.2.9
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 +22 -8
- 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/context.d.ts +4 -2
- package/lib/utils/context.js +10 -5
- package/lib/utils/utils.d.ts +13 -1
- package/lib/utils/utils.js +13 -0
- package/package.json +8 -8
- package/scripts/test/test_en.json +2 -0
package/lib/actions/translate.js
CHANGED
|
@@ -5,7 +5,7 @@ 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, beatId, multiLingualObjectToArray } from "../utils/utils.js";
|
|
9
9
|
import { getMultiLingual } from "../utils/context.js";
|
|
10
10
|
import { currentMulmoScriptVersion } from "../utils/const.js";
|
|
11
11
|
import { getOutputMultilingualFilePath, mkdir, writingMessage, hashSHA256 } from "../utils/file.js";
|
|
@@ -68,9 +68,10 @@ const beatGraph = {
|
|
|
68
68
|
// for cache
|
|
69
69
|
multiLingual: {
|
|
70
70
|
agent: (namedInputs) => {
|
|
71
|
-
const { multiLinguals, beatIndex, text } = namedInputs;
|
|
71
|
+
const { multiLinguals, beatIndex, text, beat } = namedInputs;
|
|
72
|
+
const key = beatId(beat?.id, beatIndex);
|
|
72
73
|
const cacheKey = hashSHA256(text ?? "");
|
|
73
|
-
const multiLingual = multiLinguals?.[
|
|
74
|
+
const multiLingual = multiLinguals?.[key];
|
|
74
75
|
if (!multiLingual) {
|
|
75
76
|
return { cacheKey, multiLingualTexts: {} };
|
|
76
77
|
}
|
|
@@ -86,6 +87,7 @@ const beatGraph = {
|
|
|
86
87
|
},
|
|
87
88
|
inputs: {
|
|
88
89
|
text: ":beat.text",
|
|
90
|
+
beat: ":beat",
|
|
89
91
|
beatIndex: ":__mapIndex",
|
|
90
92
|
multiLinguals: ":context.multiLingual",
|
|
91
93
|
},
|
|
@@ -141,10 +143,21 @@ const translateGraph = {
|
|
|
141
143
|
targetLangs: {},
|
|
142
144
|
mergeStudioResult: {
|
|
143
145
|
isResult: true,
|
|
144
|
-
agent:
|
|
146
|
+
agent: (namedInputs) => {
|
|
147
|
+
const { multiLingual, beats } = namedInputs;
|
|
148
|
+
const multiLingualObject = beats.reduce((tmp, beat, beatIndex) => {
|
|
149
|
+
const key = beatId(beat?.id, beatIndex);
|
|
150
|
+
tmp[key] = multiLingual[beatIndex];
|
|
151
|
+
return tmp;
|
|
152
|
+
}, {});
|
|
153
|
+
return {
|
|
154
|
+
version: "1.1",
|
|
155
|
+
multiLingual: multiLingualObject,
|
|
156
|
+
};
|
|
157
|
+
},
|
|
145
158
|
inputs: {
|
|
146
|
-
version: "1.1",
|
|
147
159
|
multiLingual: ":beatsMap.mergeMultiLingualData",
|
|
160
|
+
beats: ":context.studio.script.beats",
|
|
148
161
|
},
|
|
149
162
|
},
|
|
150
163
|
beatsMap: {
|
|
@@ -229,8 +242,9 @@ export const translateBeat = async (index, context, targetLangs, args) => {
|
|
|
229
242
|
});
|
|
230
243
|
}
|
|
231
244
|
const results = await graph.run();
|
|
232
|
-
const multiLingual = getMultiLingual(outputMultilingualFilePath, context.studio.beats
|
|
233
|
-
|
|
245
|
+
const multiLingual = getMultiLingual(outputMultilingualFilePath, context.studio.beats);
|
|
246
|
+
const key = beatId(context.studio.script.beats[index]?.id, index);
|
|
247
|
+
multiLingual[key] = results.mergeMultiLingualData;
|
|
234
248
|
const data = {
|
|
235
249
|
version: currentMulmoScriptVersion,
|
|
236
250
|
multiLingual,
|
|
@@ -263,7 +277,7 @@ export const translate = async (context, args) => {
|
|
|
263
277
|
const results = await graph.run();
|
|
264
278
|
writingMessage(outputMultilingualFilePath);
|
|
265
279
|
if (results.mergeStudioResult) {
|
|
266
|
-
context.multiLingual = results
|
|
280
|
+
context.multiLingual = multiLingualObjectToArray(results?.mergeStudioResult?.multiLingual, context.studio.script.beats);
|
|
267
281
|
}
|
|
268
282
|
}
|
|
269
283
|
finally {
|
|
@@ -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/utils.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/utils.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[];
|
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,7 @@
|
|
|
1
1
|
import { GraphAILogger } from "graphai";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import { readMulmoScriptFile, fetchMulmoScriptFile } from "./file.js";
|
|
4
|
+
import { beatId, multiLingualObjectToArray } from "./utils.js";
|
|
4
5
|
import { mulmoStudioSchema, mulmoCaptionParamsSchema, mulmoPresentationStyleSchema } from "../types/schema.js";
|
|
5
6
|
import { MulmoPresentationStyleMethods, MulmoScriptMethods, MulmoStudioMultiLingualMethod } from "../methods/index.js";
|
|
6
7
|
const mulmoCredit = (speaker) => {
|
|
@@ -87,12 +88,16 @@ export const fetchScript = async (isHttpPath, mulmoFilePath, fileOrUrl) => {
|
|
|
87
88
|
}
|
|
88
89
|
return readMulmoScriptFile(mulmoFilePath, "ERROR: File does not exist " + mulmoFilePath)?.mulmoData ?? null;
|
|
89
90
|
};
|
|
90
|
-
export const getMultiLingual = (multilingualFilePath,
|
|
91
|
+
export const getMultiLingual = (multilingualFilePath, beats) => {
|
|
91
92
|
if (!fs.existsSync(multilingualFilePath)) {
|
|
92
|
-
return
|
|
93
|
+
return beats.reduce((tmp, beat, index) => {
|
|
94
|
+
const key = beatId(beat?.id, index);
|
|
95
|
+
tmp[key] = { multiLingualTexts: {} };
|
|
96
|
+
return tmp;
|
|
97
|
+
}, {});
|
|
93
98
|
}
|
|
94
99
|
const jsonData = readMulmoScriptFile(multilingualFilePath, "ERROR: File does not exist " + multilingualFilePath)?.mulmoData ?? null;
|
|
95
|
-
return MulmoStudioMultiLingualMethod.validate(jsonData,
|
|
100
|
+
return MulmoStudioMultiLingualMethod.validate(jsonData, beats);
|
|
96
101
|
};
|
|
97
102
|
export const getPresentationStyle = (presentationStylePath) => {
|
|
98
103
|
if (!presentationStylePath) {
|
|
@@ -113,10 +118,10 @@ export const initializeContextFromFiles = async (files, raiseError, force, capti
|
|
|
113
118
|
try {
|
|
114
119
|
const presentationStyle = getPresentationStyle(presentationStylePath);
|
|
115
120
|
const studio = createStudioData(mulmoScript, fileName, captionLang, presentationStyle);
|
|
116
|
-
const multiLingual = getMultiLingual(outputMultilingualFilePath, studio.beats
|
|
121
|
+
const multiLingual = getMultiLingual(outputMultilingualFilePath, studio.script.beats);
|
|
117
122
|
return {
|
|
118
123
|
studio,
|
|
119
|
-
multiLingual,
|
|
124
|
+
multiLingual: multiLingualObjectToArray(multiLingual, studio.script.beats),
|
|
120
125
|
fileDirs: files,
|
|
121
126
|
presentationStyle: presentationStyle ?? studio.script,
|
|
122
127
|
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,16 @@ 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 beatId: (id: string | undefined, index: number) => string;
|
|
23
|
+
export declare const multiLingualObjectToArray: (multiLingual: MulmoStudioMultiLingual | undefined, beats: MulmoStudioBeat[]) => {
|
|
24
|
+
multiLingualTexts: Record<string, {
|
|
25
|
+
text: string;
|
|
26
|
+
lang: string;
|
|
27
|
+
cacheKey: string;
|
|
28
|
+
texts?: string[] | undefined;
|
|
29
|
+
ttsTexts?: string[] | undefined;
|
|
30
|
+
duration?: number | undefined;
|
|
31
|
+
}>;
|
|
32
|
+
cacheKey?: string | undefined;
|
|
33
|
+
}[];
|
|
22
34
|
export {};
|
package/lib/utils/utils.js
CHANGED
|
@@ -117,3 +117,16 @@ export const deepClean = (input) => {
|
|
|
117
117
|
}
|
|
118
118
|
return input;
|
|
119
119
|
};
|
|
120
|
+
export const beatId = (id, index) => {
|
|
121
|
+
const key = id ?? `__index__${index}`;
|
|
122
|
+
return key;
|
|
123
|
+
};
|
|
124
|
+
export const multiLingualObjectToArray = (multiLingual, beats) => {
|
|
125
|
+
return beats.map((beat, index) => {
|
|
126
|
+
const key = beatId(beat?.id, index);
|
|
127
|
+
if (multiLingual?.[key]) {
|
|
128
|
+
return multiLingual[key];
|
|
129
|
+
}
|
|
130
|
+
return { multiLingualTexts: {} };
|
|
131
|
+
});
|
|
132
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mulmocast",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.9",
|
|
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"
|