mulmocast 1.2.15 → 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
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"),
|
|
@@ -43,7 +43,7 @@ export const imagePreprocessAgent = async (namedInputs) => {
|
|
|
43
43
|
returnValue.lipSyncFile = moviePaths.lipSyncFile;
|
|
44
44
|
if (context.studio.script.audioParams?.suppressSpeech) {
|
|
45
45
|
// studio beat may ot have startAt and duration yet, in case of API call from the app.
|
|
46
|
-
returnValue.startAt = context.studio.beats.filter((_, i) => i < index).reduce((acc, curr) => acc + (curr.duration ?? 0), 0);
|
|
46
|
+
returnValue.startAt = context.studio.script.beats.filter((_, i) => i < index).reduce((acc, curr) => acc + (curr.duration ?? 0), 0);
|
|
47
47
|
returnValue.duration = beat.duration ?? 0;
|
|
48
48
|
returnValue.lipSyncTrimAudio = true;
|
|
49
49
|
returnValue.bgmFile = MulmoMediaSourceMethods.resolve(context.studio.script.audioParams.bgm, context);
|
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": {
|