mulmocast 2.1.13 → 2.1.15
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.
|
Binary file
|
package/lib/actions/bundle.js
CHANGED
|
@@ -15,19 +15,19 @@ const downloadFile = async (url, destPath) => {
|
|
|
15
15
|
const buffer = await response.arrayBuffer();
|
|
16
16
|
fs.writeFileSync(destPath, Buffer.from(buffer));
|
|
17
17
|
};
|
|
18
|
-
const processBgm = async (bgm,
|
|
18
|
+
const processBgm = async (bgm, outDir, baseDir, zipper) => {
|
|
19
19
|
if (!bgm) {
|
|
20
20
|
return undefined;
|
|
21
21
|
}
|
|
22
22
|
if (bgm.kind === "path") {
|
|
23
23
|
// Local file path
|
|
24
|
-
const sourcePath = path.resolve(bgm.path);
|
|
24
|
+
const sourcePath = path.resolve(baseDir, bgm.path);
|
|
25
25
|
if (!fs.existsSync(sourcePath)) {
|
|
26
26
|
GraphAILogger.log(`BGM file not found: ${sourcePath}`);
|
|
27
27
|
return undefined;
|
|
28
28
|
}
|
|
29
29
|
const fileName = path.basename(bgm.path);
|
|
30
|
-
const destPath = path.resolve(
|
|
30
|
+
const destPath = path.resolve(outDir, fileName);
|
|
31
31
|
fs.copyFileSync(sourcePath, destPath);
|
|
32
32
|
zipper.addFile(sourcePath, fileName);
|
|
33
33
|
return fileName;
|
|
@@ -35,7 +35,7 @@ const processBgm = async (bgm, dir, zipper) => {
|
|
|
35
35
|
else if (bgm.kind === "url") {
|
|
36
36
|
// URL download
|
|
37
37
|
const fileName = path.basename(new URL(bgm.url).pathname) || "bgm.mp3";
|
|
38
|
-
const destPath = path.resolve(
|
|
38
|
+
const destPath = path.resolve(outDir, fileName);
|
|
39
39
|
await downloadFile(bgm.url, destPath);
|
|
40
40
|
zipper.addFile(destPath);
|
|
41
41
|
return fileName;
|
|
@@ -54,9 +54,10 @@ const imageSourceMappings = [
|
|
|
54
54
|
];
|
|
55
55
|
export const mulmoViewerBundle = async (context) => {
|
|
56
56
|
const isZip = true;
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
const outDir = context.fileDirs.outDirPath;
|
|
58
|
+
const baseDir = context.fileDirs.baseDirPath;
|
|
59
|
+
mkdir(outDir);
|
|
60
|
+
const zipper = new ZipBuilder(path.resolve(outDir, zipFileName));
|
|
60
61
|
// text
|
|
61
62
|
const resultJson = [];
|
|
62
63
|
context.studio.script.beats.forEach((beat, index) => {
|
|
@@ -76,12 +77,12 @@ export const mulmoViewerBundle = async (context) => {
|
|
|
76
77
|
}
|
|
77
78
|
if (fileName === "silent300.mp3") {
|
|
78
79
|
// Download from GitHub URL
|
|
79
|
-
const destPath = path.resolve(
|
|
80
|
+
const destPath = path.resolve(outDir, fileName);
|
|
80
81
|
await downloadFile(silentMp3, destPath);
|
|
81
82
|
zipper.addFile(destPath, fileName);
|
|
82
83
|
}
|
|
83
84
|
else if (fs.existsSync(audio)) {
|
|
84
|
-
fs.copyFileSync(audio, path.resolve(
|
|
85
|
+
fs.copyFileSync(audio, path.resolve(outDir, fileName));
|
|
85
86
|
zipper.addFile(audio, fileName);
|
|
86
87
|
}
|
|
87
88
|
}
|
|
@@ -95,7 +96,7 @@ export const mulmoViewerBundle = async (context) => {
|
|
|
95
96
|
if (typeof value === "string") {
|
|
96
97
|
data[source] = path.basename(value);
|
|
97
98
|
if (fs.existsSync(value)) {
|
|
98
|
-
fs.copyFileSync(value, path.resolve(
|
|
99
|
+
fs.copyFileSync(value, path.resolve(outDir, path.basename(value)));
|
|
99
100
|
zipper.addFile(value);
|
|
100
101
|
}
|
|
101
102
|
}
|
|
@@ -110,7 +111,7 @@ export const mulmoViewerBundle = async (context) => {
|
|
|
110
111
|
data.videoWithAudioSource === undefined &&
|
|
111
112
|
data.duration) {
|
|
112
113
|
const file = `silent_${index}.mp3`;
|
|
113
|
-
const audioFile = path.resolve(
|
|
114
|
+
const audioFile = path.resolve(outDir, file);
|
|
114
115
|
await createSilentAudio(audioFile, data.duration);
|
|
115
116
|
zipper.addFile(audioFile);
|
|
116
117
|
data.audioSources.ja = file;
|
|
@@ -126,10 +127,10 @@ export const mulmoViewerBundle = async (context) => {
|
|
|
126
127
|
});
|
|
127
128
|
});
|
|
128
129
|
// BGM
|
|
129
|
-
const bgmFileName = await processBgm(context.studio?.script.audioParams?.bgm,
|
|
130
|
+
const bgmFileName = await processBgm(context.studio?.script.audioParams?.bgm, outDir, baseDir, zipper);
|
|
130
131
|
const bundleData = { beats: resultJson, bgmSource: bgmFileName, title: context.studio.script.title };
|
|
131
|
-
fs.writeFileSync(path.resolve(
|
|
132
|
-
zipper.addFile(path.resolve(
|
|
132
|
+
fs.writeFileSync(path.resolve(outDir, viewJsonFileName), JSON.stringify(bundleData, null, 2));
|
|
133
|
+
zipper.addFile(path.resolve(outDir, viewJsonFileName));
|
|
133
134
|
if (isZip) {
|
|
134
135
|
await zipper.finalize();
|
|
135
136
|
}
|
package/lib/utils/context.js
CHANGED
|
@@ -4,7 +4,7 @@ import { beatId, multiLingualObjectToArray } from "./utils.js";
|
|
|
4
4
|
import { mulmoStudioSchema, mulmoCaptionParamsSchema, mulmoPresentationStyleSchema } from "../types/schema.js";
|
|
5
5
|
import { MulmoPresentationStyleMethods, MulmoScriptMethods, MulmoStudioMultiLingualMethod } from "../methods/index.js";
|
|
6
6
|
export const silentMp3 = "https://github.com/receptron/mulmocast-cli/raw/refs/heads/main/assets/audio/silent300.mp3";
|
|
7
|
-
const mulmoCredit = (speaker) => {
|
|
7
|
+
const mulmoCredit = (speaker, isPortrait) => {
|
|
8
8
|
return {
|
|
9
9
|
id: "mulmo_credit",
|
|
10
10
|
speaker,
|
|
@@ -13,7 +13,8 @@ const mulmoCredit = (speaker) => {
|
|
|
13
13
|
type: "image",
|
|
14
14
|
source: {
|
|
15
15
|
kind: "url",
|
|
16
|
-
url: "https://github.com/receptron/mulmocast-cli/raw/refs/heads/main/assets/images/
|
|
16
|
+
url: "https://github.com/receptron/mulmocast-cli/raw/refs/heads/main/assets/images/" +
|
|
17
|
+
(isPortrait ? "mulmocast_credit-portrait.png" : "mulmocast_credit.png"),
|
|
17
18
|
},
|
|
18
19
|
},
|
|
19
20
|
audio: {
|
|
@@ -61,11 +62,12 @@ export const createStudioData = (_mulmoScript, fileName, videoCaptionLang, prese
|
|
|
61
62
|
filename: fileName,
|
|
62
63
|
beats: [...Array(mulmoScript.beats.length)].map(() => ({})),
|
|
63
64
|
});
|
|
65
|
+
const isPortrait = mulmoScript.canvasSize.height > mulmoScript.canvasSize.width;
|
|
64
66
|
// TODO: Move this code out of this function later
|
|
65
67
|
// Addition cloing credit
|
|
66
68
|
if (mulmoScript.$mulmocast.credit === "closing") {
|
|
67
69
|
const defaultSpeaker = MulmoPresentationStyleMethods.getDefaultSpeaker(presentationStyle ?? studio.script);
|
|
68
|
-
mulmoScript.beats.push(mulmoCredit(mulmoScript.beats[0].speaker ?? defaultSpeaker)); // First speaker
|
|
70
|
+
mulmoScript.beats.push(mulmoCredit(mulmoScript.beats[0].speaker ?? defaultSpeaker, isPortrait)); // First speaker
|
|
69
71
|
}
|
|
70
72
|
studio.script = MulmoScriptMethods.validate(mulmoScript); // update the script
|
|
71
73
|
studio.beats = studio.script.beats.map((_, index) => studio.beats[index] ?? {});
|
package/package.json
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$mulmocast": {
|
|
3
|
+
"version": "1.1",
|
|
4
|
+
"credit": "closing"
|
|
5
|
+
},
|
|
6
|
+
"canvasSize": { "width": 1024, "height": 1536 },
|
|
7
|
+
"title": "THE ROAD TO SUPERINTELLIGENCE: EXPLORING AI-2027",
|
|
8
|
+
"speechParams": {
|
|
9
|
+
"speakers": {
|
|
10
|
+
"Host": {
|
|
11
|
+
"voiceId": "shimmer",
|
|
12
|
+
"displayName": {
|
|
13
|
+
"en": "Host"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"lang": "en",
|
|
19
|
+
"beats": [
|
|
20
|
+
{
|
|
21
|
+
"id": "beat1",
|
|
22
|
+
"speaker": "Host",
|
|
23
|
+
"text": "Welcome to Mulmocast Tech Insights."
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"id": "beat2",
|
|
27
|
+
"speaker": "Host",
|
|
28
|
+
"text": "AI-2028 is a project from the AI Futures Project."
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$mulmocast": {
|
|
3
|
+
"version": "1.1",
|
|
4
|
+
"credit": "closing"
|
|
5
|
+
},
|
|
6
|
+
"canvasSize": { "width": 1024 "height": 1536, },
|
|
7
|
+
"title": "THE ROAD TO SUPERINTELLIGENCE: EXPLORING AI-2027",
|
|
8
|
+
"speechParams": {
|
|
9
|
+
"speakers": {
|
|
10
|
+
"Host": {
|
|
11
|
+
"voiceId": "shimmer",
|
|
12
|
+
"displayName": {
|
|
13
|
+
"en": "Host"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"lang": "en",
|
|
19
|
+
"beats": [
|
|
20
|
+
{
|
|
21
|
+
"id": "beat1",
|
|
22
|
+
"speaker": "Host",
|
|
23
|
+
"text": "Welcome to Mulmocast Tech Insights."
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"id": "beat2",
|
|
27
|
+
"speaker": "Host",
|
|
28
|
+
"text": "AI-2028 is a project from the AI Futures Project."
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|