mulmocast 1.2.14 → 1.2.16
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/captions.js +2 -2
- package/lib/actions/image_agents.js +3 -2
- package/lib/actions/images.js +2 -1
- package/lib/methods/mulmo_studio_context.d.ts +1 -1
- package/lib/methods/mulmo_studio_context.js +3 -0
- package/lib/utils/utils.d.ts +1 -0
- package/lib/utils/utils.js +3 -0
- package/package.json +1 -1
- package/scripts/test/test_captions.json +2 -2
package/lib/actions/captions.js
CHANGED
|
@@ -2,7 +2,7 @@ import { mulmoCaptionParamsSchema } from "../types/index.js";
|
|
|
2
2
|
import { GraphAI, GraphAILogger } from "graphai";
|
|
3
3
|
import * as agents from "@graphai/vanilla";
|
|
4
4
|
import { getHTMLFile, getCaptionImagePath, getOutputStudioFilePath } from "../utils/file.js";
|
|
5
|
-
import { localizedText } from "../utils/utils.js";
|
|
5
|
+
import { localizedText, processLineBreaks } from "../utils/utils.js";
|
|
6
6
|
import { renderHTMLToImage, interpolate } from "../utils/markdown.js";
|
|
7
7
|
import { MulmoStudioContextMethods, MulmoPresentationStyleMethods } from "../methods/index.js";
|
|
8
8
|
import { fileWriteAgent } from "@graphai/vanilla_node_agents";
|
|
@@ -36,7 +36,7 @@ const graph_data = {
|
|
|
36
36
|
}
|
|
37
37
|
const text = localizedText(beat, context.multiLingual?.[index], captionParams.lang, context.studio.script.lang);
|
|
38
38
|
const htmlData = interpolate(template, {
|
|
39
|
-
caption: text,
|
|
39
|
+
caption: processLineBreaks(text),
|
|
40
40
|
width: `${canvasSize.width}`,
|
|
41
41
|
height: `${canvasSize.height}`,
|
|
42
42
|
styles: captionParams.styles.join(";\n"),
|
|
@@ -42,8 +42,9 @@ export const imagePreprocessAgent = async (namedInputs) => {
|
|
|
42
42
|
returnValue.lipSyncModel = beat.lipSyncParams?.model ?? context.presentationStyle.lipSyncParams?.model ?? lipSyncAgentInfo.defaultModel;
|
|
43
43
|
returnValue.lipSyncFile = moviePaths.lipSyncFile;
|
|
44
44
|
if (context.studio.script.audioParams?.suppressSpeech) {
|
|
45
|
-
|
|
46
|
-
returnValue.
|
|
45
|
+
// studio beat may ot have startAt and duration yet, in case of API call from the app.
|
|
46
|
+
returnValue.startAt = context.studio.script.beats.filter((_, i) => i < index).reduce((acc, curr) => acc + (curr.duration ?? 0), 0);
|
|
47
|
+
returnValue.duration = beat.duration ?? 0;
|
|
47
48
|
returnValue.lipSyncTrimAudio = true;
|
|
48
49
|
returnValue.bgmFile = MulmoMediaSourceMethods.resolve(context.studio.script.audioParams.bgm, context);
|
|
49
50
|
const folderName = MulmoStudioContextMethods.getFileName(context);
|
package/lib/actions/images.js
CHANGED
|
@@ -231,6 +231,7 @@ const beat_graph_data = {
|
|
|
231
231
|
return { buffer };
|
|
232
232
|
},
|
|
233
233
|
inputs: {
|
|
234
|
+
onComplete: [":imageGenerator", ":imagePlugin"],
|
|
234
235
|
audioFile: ":preprocessor.audioFile",
|
|
235
236
|
bgmFile: ":preprocessor.bgmFile",
|
|
236
237
|
startAt: ":preprocessor.startAt",
|
|
@@ -240,8 +241,8 @@ const beat_graph_data = {
|
|
|
240
241
|
file: ":preprocessor.audioFile",
|
|
241
242
|
index: ":__mapIndex",
|
|
242
243
|
id: ":beat.id",
|
|
243
|
-
sessionType: "audioTrimmer",
|
|
244
244
|
mulmoContext: ":context",
|
|
245
|
+
// sessionType: undefined, // no need to notify state change
|
|
245
246
|
},
|
|
246
247
|
},
|
|
247
248
|
defaultValue: {},
|
|
@@ -14,7 +14,7 @@ export declare const MulmoStudioContextMethods: {
|
|
|
14
14
|
getFileName(context: MulmoStudioContext): string;
|
|
15
15
|
getCaption(context: MulmoStudioContext): string | undefined;
|
|
16
16
|
setSessionState(context: MulmoStudioContext, sessionType: SessionType, value: boolean): void;
|
|
17
|
-
setBeatSessionState(context: MulmoStudioContext, sessionType: BeatSessionType, index: number, id: string | undefined, value: boolean): void;
|
|
17
|
+
setBeatSessionState(context: MulmoStudioContext, sessionType: BeatSessionType | undefined, index: number, id: string | undefined, value: boolean): void;
|
|
18
18
|
needTranslate(context: MulmoStudioContext, includeCaption?: boolean): boolean | "" | undefined;
|
|
19
19
|
getIntroPadding(context: MulmoStudioContext): number;
|
|
20
20
|
};
|
|
@@ -53,6 +53,9 @@ export const MulmoStudioContextMethods = {
|
|
|
53
53
|
notifyStateChange(context, sessionType);
|
|
54
54
|
},
|
|
55
55
|
setBeatSessionState(context, sessionType, index, id, value) {
|
|
56
|
+
if (!sessionType) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
56
59
|
const key = beatId(id, index);
|
|
57
60
|
if (value) {
|
|
58
61
|
if (!context.sessionState.inBeatSession[sessionType]) {
|
package/lib/utils/utils.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare const llmPair: (_llm?: LLM, _model?: string) => {
|
|
|
14
14
|
export declare const chunkArray: <T>(array: T[], size?: number) => T[][];
|
|
15
15
|
export declare const isHttp: (fileOrUrl: string) => boolean;
|
|
16
16
|
export declare const localizedText: (beat: MulmoBeat, multiLingualData?: MulmoStudioMultiLingualData, targetLang?: string, defaultLang?: string) => string;
|
|
17
|
+
export declare function processLineBreaks(text: string): string;
|
|
17
18
|
export declare function userAssert(condition: boolean, message: string): asserts condition;
|
|
18
19
|
export declare const settings2GraphAIConfig: (settings?: Record<string, string>, env?: Record<string, string | undefined>) => ConfigDataDictionary<DefaultConfigData>;
|
|
19
20
|
export declare const getExtention: (contentType: string | null, url: string) => string;
|
package/lib/utils/utils.js
CHANGED
|
@@ -30,6 +30,9 @@ export const localizedText = (beat, multiLingualData, targetLang, defaultLang) =
|
|
|
30
30
|
}
|
|
31
31
|
return beat.text;
|
|
32
32
|
};
|
|
33
|
+
export function processLineBreaks(text) {
|
|
34
|
+
return text.replace(/\n/g, "<br>");
|
|
35
|
+
}
|
|
33
36
|
export function userAssert(condition, message) {
|
|
34
37
|
if (!condition) {
|
|
35
38
|
throw new Error(message);
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
},
|
|
5
5
|
"lang": "en",
|
|
6
6
|
"captionParams": {
|
|
7
|
-
"lang": "
|
|
7
|
+
"lang": "en",
|
|
8
8
|
"styles": ["color: yellow"]
|
|
9
9
|
},
|
|
10
10
|
"beats": [
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
|
-
"text": "Hello World. May the force be with you
|
|
22
|
+
"text": "Hello World. May the force be with you.\nThis is a long caption.\nThis is a really long caption.",
|
|
23
23
|
"image": {
|
|
24
24
|
"type": "textSlide",
|
|
25
25
|
"slide": {
|