mulmocast 0.0.1

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.
Files changed (83) hide show
  1. package/README.md +74 -0
  2. package/assets/audio/silent300.mp3 +0 -0
  3. package/assets/audio/silent800.mp3 +0 -0
  4. package/assets/music/StarsBeyondEx.mp3 +0 -0
  5. package/assets/templates/business.json +89 -0
  6. package/assets/templates/children_book.json +135 -0
  7. package/assets/templates/podcast_standard.json +5 -0
  8. package/assets/templates/sensei_and_taro.json +123 -0
  9. package/lib/actions/audio.d.ts +3 -0
  10. package/lib/actions/audio.js +186 -0
  11. package/lib/actions/images.d.ts +2 -0
  12. package/lib/actions/images.js +211 -0
  13. package/lib/actions/movie.d.ts +2 -0
  14. package/lib/actions/movie.js +81 -0
  15. package/lib/actions/translate.d.ts +3 -0
  16. package/lib/actions/translate.js +236 -0
  17. package/lib/agents/add_bgm_agent.d.ts +3 -0
  18. package/lib/agents/add_bgm_agent.js +61 -0
  19. package/lib/agents/combine_audio_files_agent.d.ts +3 -0
  20. package/lib/agents/combine_audio_files_agent.js +57 -0
  21. package/lib/agents/image_google_agent.d.ts +15 -0
  22. package/lib/agents/image_google_agent.js +88 -0
  23. package/lib/agents/image_openai_agent.d.ts +15 -0
  24. package/lib/agents/image_openai_agent.js +59 -0
  25. package/lib/agents/index.d.ts +13 -0
  26. package/lib/agents/index.js +31 -0
  27. package/lib/agents/mulmo_prompts_agent.d.ts +7 -0
  28. package/lib/agents/mulmo_prompts_agent.js +41 -0
  29. package/lib/agents/prompts_data.d.ts +15 -0
  30. package/lib/agents/prompts_data.js +19 -0
  31. package/lib/agents/tts_nijivoice_agent.d.ts +4 -0
  32. package/lib/agents/tts_nijivoice_agent.js +68 -0
  33. package/lib/agents/tts_openai_agent.d.ts +4 -0
  34. package/lib/agents/tts_openai_agent.js +50 -0
  35. package/lib/agents/validate_mulmo_script_agent.d.ts +17 -0
  36. package/lib/agents/validate_mulmo_script_agent.js +38 -0
  37. package/lib/cli/args.d.ts +10 -0
  38. package/lib/cli/args.js +38 -0
  39. package/lib/cli/cli.d.ts +2 -0
  40. package/lib/cli/cli.js +78 -0
  41. package/lib/cli/common.d.ts +8 -0
  42. package/lib/cli/common.js +26 -0
  43. package/lib/cli/tool-args.d.ts +12 -0
  44. package/lib/cli/tool-args.js +53 -0
  45. package/lib/cli/tool-cli.d.ts +2 -0
  46. package/lib/cli/tool-cli.js +78 -0
  47. package/lib/methods/index.d.ts +3 -0
  48. package/lib/methods/index.js +19 -0
  49. package/lib/methods/mulmo_script.d.ts +11 -0
  50. package/lib/methods/mulmo_script.js +45 -0
  51. package/lib/methods/mulmo_script_template.d.ts +4 -0
  52. package/lib/methods/mulmo_script_template.js +22 -0
  53. package/lib/methods/mulmo_studio_context.d.ts +4 -0
  54. package/lib/methods/mulmo_studio_context.js +12 -0
  55. package/lib/tools/dump_prompt.d.ts +3 -0
  56. package/lib/tools/dump_prompt.js +9 -0
  57. package/lib/tools/prompt.d.ts +1 -0
  58. package/lib/tools/prompt.js +20 -0
  59. package/lib/tools/seed.d.ts +3 -0
  60. package/lib/tools/seed.js +201 -0
  61. package/lib/tools/seed_from_url.d.ts +3 -0
  62. package/lib/tools/seed_from_url.js +178 -0
  63. package/lib/types/index.d.ts +1 -0
  64. package/lib/types/index.js +17 -0
  65. package/lib/types/schema.d.ts +5817 -0
  66. package/lib/types/schema.js +207 -0
  67. package/lib/types/type.d.ts +33 -0
  68. package/lib/types/type.js +2 -0
  69. package/lib/utils/const.d.ts +3 -0
  70. package/lib/utils/const.js +6 -0
  71. package/lib/utils/file.d.ts +28 -0
  72. package/lib/utils/file.js +112 -0
  73. package/lib/utils/filters.d.ts +3 -0
  74. package/lib/utils/filters.js +32 -0
  75. package/lib/utils/markdown.d.ts +1 -0
  76. package/lib/utils/markdown.js +27 -0
  77. package/lib/utils/preprocess.d.ts +247 -0
  78. package/lib/utils/preprocess.js +53 -0
  79. package/lib/utils/string.d.ts +9 -0
  80. package/lib/utils/string.js +60 -0
  81. package/lib/utils/text_hash.d.ts +1 -0
  82. package/lib/utils/text_hash.js +41 -0
  83. package/package.json +77 -0
@@ -0,0 +1,247 @@
1
+ export declare const createOrUpdateStudioData: (mulmoFile: string, files: {
2
+ outDirPath: string;
3
+ }) => {
4
+ beats: {
5
+ text: string;
6
+ speaker: string;
7
+ duration?: number | undefined;
8
+ speechOptions?: {
9
+ speed?: number | undefined;
10
+ instruction?: string | undefined;
11
+ } | undefined;
12
+ image?: {
13
+ type: "markdown";
14
+ markdown: string | string[];
15
+ } | {
16
+ type: "web";
17
+ url: string;
18
+ } | {
19
+ type: "pdf";
20
+ source: {
21
+ url: string;
22
+ kind: "url";
23
+ } | {
24
+ kind: "data";
25
+ data: string;
26
+ } | {
27
+ path: string;
28
+ kind: "path";
29
+ };
30
+ } | {
31
+ type: "image";
32
+ source: {
33
+ url: string;
34
+ kind: "url";
35
+ } | {
36
+ kind: "data";
37
+ data: string;
38
+ } | {
39
+ path: string;
40
+ kind: "path";
41
+ };
42
+ } | {
43
+ type: "svg";
44
+ source: {
45
+ url: string;
46
+ kind: "url";
47
+ } | {
48
+ kind: "data";
49
+ data: string;
50
+ } | {
51
+ path: string;
52
+ kind: "path";
53
+ };
54
+ } | {
55
+ type: "movie";
56
+ source: {
57
+ url: string;
58
+ kind: "url";
59
+ } | {
60
+ kind: "data";
61
+ data: string;
62
+ } | {
63
+ path: string;
64
+ kind: "path";
65
+ };
66
+ } | {
67
+ type: "textSlide";
68
+ slide: {
69
+ title: string;
70
+ bullets: string[];
71
+ };
72
+ } | undefined;
73
+ audio?: {
74
+ type: "audio";
75
+ source: {
76
+ url: string;
77
+ kind: "url";
78
+ } | {
79
+ kind: "data";
80
+ data: string;
81
+ } | {
82
+ path: string;
83
+ kind: "path";
84
+ };
85
+ } | {
86
+ type: "midi";
87
+ source: string;
88
+ } | undefined;
89
+ imageParams?: {
90
+ model?: string | undefined;
91
+ size?: string | undefined;
92
+ style?: string | undefined;
93
+ moderation?: string | undefined;
94
+ } | undefined;
95
+ textSlideParams?: {
96
+ cssStyles: string[];
97
+ } | undefined;
98
+ imagePrompt?: string | undefined;
99
+ multiLingualTexts?: Record<string, {
100
+ text: string;
101
+ lang: string;
102
+ texts?: string[] | undefined;
103
+ ttsTexts?: string[] | undefined;
104
+ duration?: number | undefined;
105
+ }> | undefined;
106
+ hash?: string | undefined;
107
+ audioFile?: string | undefined;
108
+ imageFile?: string | undefined;
109
+ }[];
110
+ script: {
111
+ title: string;
112
+ $mulmocast: {
113
+ version: "1.0";
114
+ credit?: "closing" | undefined;
115
+ };
116
+ beats: {
117
+ text: string;
118
+ speaker: string;
119
+ speechOptions?: {
120
+ speed?: number | undefined;
121
+ instruction?: string | undefined;
122
+ } | undefined;
123
+ image?: {
124
+ type: "markdown";
125
+ markdown: string | string[];
126
+ } | {
127
+ type: "web";
128
+ url: string;
129
+ } | {
130
+ type: "pdf";
131
+ source: {
132
+ url: string;
133
+ kind: "url";
134
+ } | {
135
+ kind: "data";
136
+ data: string;
137
+ } | {
138
+ path: string;
139
+ kind: "path";
140
+ };
141
+ } | {
142
+ type: "image";
143
+ source: {
144
+ url: string;
145
+ kind: "url";
146
+ } | {
147
+ kind: "data";
148
+ data: string;
149
+ } | {
150
+ path: string;
151
+ kind: "path";
152
+ };
153
+ } | {
154
+ type: "svg";
155
+ source: {
156
+ url: string;
157
+ kind: "url";
158
+ } | {
159
+ kind: "data";
160
+ data: string;
161
+ } | {
162
+ path: string;
163
+ kind: "path";
164
+ };
165
+ } | {
166
+ type: "movie";
167
+ source: {
168
+ url: string;
169
+ kind: "url";
170
+ } | {
171
+ kind: "data";
172
+ data: string;
173
+ } | {
174
+ path: string;
175
+ kind: "path";
176
+ };
177
+ } | {
178
+ type: "textSlide";
179
+ slide: {
180
+ title: string;
181
+ bullets: string[];
182
+ };
183
+ } | undefined;
184
+ audio?: {
185
+ type: "audio";
186
+ source: {
187
+ url: string;
188
+ kind: "url";
189
+ } | {
190
+ kind: "data";
191
+ data: string;
192
+ } | {
193
+ path: string;
194
+ kind: "path";
195
+ };
196
+ } | {
197
+ type: "midi";
198
+ source: string;
199
+ } | undefined;
200
+ imageParams?: {
201
+ model?: string | undefined;
202
+ size?: string | undefined;
203
+ style?: string | undefined;
204
+ moderation?: string | undefined;
205
+ } | undefined;
206
+ textSlideParams?: {
207
+ cssStyles: string[];
208
+ } | undefined;
209
+ imagePrompt?: string | undefined;
210
+ }[];
211
+ speechParams: {
212
+ speakers: Record<string, {
213
+ displayName: Record<string, string>;
214
+ voiceId: string;
215
+ speechOptions?: {
216
+ speed?: number | undefined;
217
+ instruction?: string | undefined;
218
+ } | undefined;
219
+ }>;
220
+ provider?: string | undefined;
221
+ };
222
+ lang?: string | undefined;
223
+ imageParams?: {
224
+ model?: string | undefined;
225
+ size?: string | undefined;
226
+ style?: string | undefined;
227
+ moderation?: string | undefined;
228
+ provider?: string | undefined;
229
+ } | undefined;
230
+ textSlideParams?: {
231
+ cssStyles: string[];
232
+ } | undefined;
233
+ description?: string | undefined;
234
+ reference?: string | undefined;
235
+ canvasSize?: {
236
+ width: number;
237
+ height: number;
238
+ } | undefined;
239
+ videoParams?: {
240
+ padding?: number | undefined;
241
+ } | undefined;
242
+ imagePath?: string | undefined;
243
+ omitCaptions?: boolean | undefined;
244
+ __test_invalid__?: boolean | undefined;
245
+ };
246
+ filename: string;
247
+ };
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createOrUpdateStudioData = void 0;
4
+ const file_1 = require("./file");
5
+ const text_hash_1 = require("./text_hash");
6
+ const methods_1 = require("../methods");
7
+ const createOrUpdateStudioData = (mulmoFile, files) => {
8
+ const { outDirPath } = files;
9
+ const readData = (0, file_1.readMulmoScriptFile)(mulmoFile, "ERROR: File does not exist " + mulmoFile);
10
+ const { mulmoData: mulmoScript, fileName } = readData;
11
+ // Create or update MulmoStudio file with MulmoScript
12
+ const outputStudioFilePath = (0, file_1.getOutputStudioFilePath)(outDirPath, fileName);
13
+ const currentStudio = (0, file_1.readMulmoScriptFile)(outputStudioFilePath);
14
+ const studio = currentStudio?.mulmoData ?? {
15
+ script: mulmoScript,
16
+ filename: fileName,
17
+ beats: Array(mulmoScript.beats.length).fill({}),
18
+ };
19
+ if (!studio.beats) {
20
+ studio.beats = [];
21
+ }
22
+ // Addition cloing credit
23
+ if (mulmoScript.$mulmocast.credit === "closing") {
24
+ mulmoScript.beats.push({
25
+ speaker: mulmoScript.beats[0].speaker, // First speaker
26
+ text: "",
27
+ image: {
28
+ type: "image",
29
+ source: {
30
+ kind: "url",
31
+ url: "https://github.com/receptron/mulmocast-cli/raw/refs/heads/main/assets/images/mulmocast_credit.png",
32
+ },
33
+ },
34
+ audio: {
35
+ type: "audio",
36
+ source: {
37
+ kind: "url",
38
+ url: "https://github.com/receptron/mulmocast-cli/raw/refs/heads/main/assets/audio/silent300.mp3",
39
+ },
40
+ },
41
+ });
42
+ }
43
+ studio.script = mulmoScript; // update the script
44
+ studio.beats.length = mulmoScript.beats.length; // In case it became shorter
45
+ mulmoScript.beats.forEach((beat, index) => {
46
+ const voiceId = studio.script.speechParams.speakers[beat.speaker].voiceId;
47
+ const speechOptions = methods_1.MulmoScriptMethods.getSpeechOptions(studio.script, beat);
48
+ const hash_string = `${beat.text}${voiceId}${speechOptions?.instruction ?? ""}${speechOptions?.speed ?? 1.0}`;
49
+ studio.beats[index] = { ...studio.beats[index], ...beat, audioFile: `${fileName}_${index}_${(0, text_hash_1.text2hash)(hash_string)}` };
50
+ });
51
+ return studio;
52
+ };
53
+ exports.createOrUpdateStudioData = createOrUpdateStudioData;
@@ -0,0 +1,9 @@
1
+ export declare function splitIntoSentencesJa(paragraph: string, divider: string, minimum: number): string[];
2
+ export declare const recursiveSplitJa: (text: string) => string[];
3
+ interface Replacement {
4
+ from: string;
5
+ to: string;
6
+ }
7
+ export declare function replacePairsJa(str: string, replacements: Replacement[]): string;
8
+ export declare const replacementsJa: Replacement[];
9
+ export {};
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.replacementsJa = exports.recursiveSplitJa = void 0;
4
+ exports.splitIntoSentencesJa = splitIntoSentencesJa;
5
+ exports.replacePairsJa = replacePairsJa;
6
+ // split ja
7
+ function splitIntoSentencesJa(paragraph, divider, minimum) {
8
+ const sentences = paragraph
9
+ .split(divider) // Split by the Japanese full stop
10
+ .map((sentence) => sentence.trim()) // Trim whitespace
11
+ .filter((sentence) => sentence.length > 0); // Remove empty sentences
12
+ return sentences
13
+ .reduce((acc, sentence) => {
14
+ if (acc.length > 0 && acc[acc.length - 1].length < minimum) {
15
+ acc[acc.length - 1] += divider + sentence;
16
+ }
17
+ else {
18
+ acc.push(sentence);
19
+ }
20
+ return acc;
21
+ }, [])
22
+ .map((sentence, index, array) => (index < array.length - 1 || paragraph.endsWith(divider) ? sentence + divider : sentence));
23
+ }
24
+ const recursiveSplitJa = (text) => {
25
+ const delimiters = ["。", "?", "!", "、"];
26
+ return delimiters
27
+ .reduce((textData, delimiter) => {
28
+ return textData.map((text) => splitIntoSentencesJa(text, delimiter, 7)).flat(1);
29
+ }, [text])
30
+ .flat(1);
31
+ };
32
+ exports.recursiveSplitJa = recursiveSplitJa;
33
+ function replacePairsJa(str, replacements) {
34
+ replacements.forEach(({ from, to }) => {
35
+ // Escape any special regex characters in the 'from' string.
36
+ const escapedFrom = from.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
37
+ const regex = new RegExp(escapedFrom, "g");
38
+ str = str.replace(regex, to);
39
+ });
40
+ return str;
41
+ }
42
+ exports.replacementsJa = [
43
+ { from: "Anthropic", to: "アンスロピック" },
44
+ { from: "OpenAI", to: "オープンエーアイ" },
45
+ { from: "AGI", to: "エージーアイ" },
46
+ { from: "GPU", to: "ジーピーユー" },
47
+ { from: "TPU", to: "ティーピーユー" },
48
+ { from: "CPU", to: "シーピーユー" },
49
+ { from: "LPU", to: "エルピーユー" },
50
+ { from: "Groq", to: "グロック" },
51
+ { from: "TSMC", to: "ティーエスエムシー" },
52
+ { from: "NVIDIA", to: "エヌビディア" },
53
+ { from: "1つ", to: "ひとつ" },
54
+ { from: "2つ", to: "ふたつ" },
55
+ { from: "3つ", to: "みっつ" },
56
+ { from: "4つ", to: "よっつ" },
57
+ { from: "5つ", to: "いつつ" },
58
+ { from: "危険な面", to: "危険なめん" },
59
+ { from: "その通り!", to: "その通り。" },
60
+ ];
@@ -0,0 +1 @@
1
+ export declare const text2hash: (input: string) => string;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.text2hash = void 0;
37
+ const crypto = __importStar(require("crypto"));
38
+ const text2hash = (input) => {
39
+ return crypto.createHash("sha256").update(input).digest("hex");
40
+ };
41
+ exports.text2hash = text2hash;
package/package.json ADDED
@@ -0,0 +1,77 @@
1
+ {
2
+ "name": "mulmocast",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "main": "lib/cli/cli.js",
6
+ "bin": {
7
+ "mulmo": "lib/cli/cli.js",
8
+ "mulmo-tool": "lib/cli/tool-cli.js"
9
+ },
10
+ "files": [
11
+ "./lib",
12
+ "./assets/music/StarsBeyondEx.mp3",
13
+ "./assets/audio/silent300.mp3",
14
+ "./assets/audio/silent800.mp3",
15
+ "./assets/templates/"
16
+ ],
17
+ "types": "./lib/types/index.d.ts",
18
+ "directories": {
19
+ "lib": "lib",
20
+ "test": "tests"
21
+ },
22
+ "scripts": {
23
+ "audio": "npx tsx ./src/cli/cli.ts audio",
24
+ "translate": "npx tsx ./src/cli/cli.ts translate",
25
+ "movie": "npx tsx ./src/cli/cli.ts movie",
26
+ "images": "npx tsx ./src/cli/cli.ts images",
27
+ "preprocess": "npx tsx ./src/cli/cli.ts preprocess",
28
+ "test": "rm -f scratchpad/test*.* && npx tsx ./src/audio.ts scripts/test/test.json && npx tsx ./src/images.ts scripts/test/test.json && npx tsx ./src/movie.ts scripts/test/test.json",
29
+ "ci_test": "node --test --require ts-node/register ./test/*/test_*.ts",
30
+ "lint": "eslint src test",
31
+ "build": "tsc",
32
+ "build_test": "tsc && git checkout -- lib/*",
33
+ "prompt": "npx ts-node ./src/tools/prompt.ts",
34
+ "cli": "npx ts-node ./src/cli/cli.ts",
35
+ "scripting": "npx ts-node ./src/cli/tool-cli.ts scripting",
36
+ "dump_prompt": "npx tsx ./src/cli/tool-cli.ts prompt",
37
+ "latest": "yarn upgrade-interactive --latest",
38
+ "format": "prettier --write '{src,scripts,assets/templates,draft,ideason,scripts_mag2,proto,test,graphai,output}/**/*.{ts,json}'"
39
+ },
40
+ "repository": "git+ssh://git@github.com/receptron/mulmocast-cli.git",
41
+ "author": "snakajima",
42
+ "license": "AGPLV3",
43
+ "bugs": {
44
+ "url": "https://github.com/receptron/mulmocast-cli/issues"
45
+ },
46
+ "homepage": "https://github.com/receptron/mulmocast-cli#readme",
47
+ "dependencies": {
48
+ "@graphai/browserless_agent": "^2.0.0",
49
+ "@graphai/input_agents": "^1.0.1",
50
+ "@graphai/openai_agent": "^1.0.5",
51
+ "@graphai/vanilla": "^2.0.1",
52
+ "@graphai/vanilla_node_agents": "^2.0.0",
53
+ "@types/fluent-ffmpeg": "^2.1.26",
54
+ "canvas": "^3.1.0",
55
+ "dotenv": "^16.4.7",
56
+ "fluent-ffmpeg": "^2.1.3",
57
+ "google-auth-library": "^9.15.1",
58
+ "graphai": "^1.0.12",
59
+ "inquirer": "^12.6.0",
60
+ "marked": "^15.0.11",
61
+ "puppeteer": "^24.8.1",
62
+ "yargs": "^17.7.2",
63
+ "zod": "^3.24.4",
64
+ "zod-to-json-schema": "^3.24.5"
65
+ },
66
+ "devDependencies": {
67
+ "@receptron/test_utils": "^2.0.0",
68
+ "@types/yargs": "^17.0.33",
69
+ "eslint": "^9.26.0",
70
+ "eslint-config-prettier": "^10.0.1",
71
+ "eslint-plugin-prettier": "^5.4.0",
72
+ "prettier": "^3.3.3",
73
+ "ts-node": "^10.9.2",
74
+ "typescript": "^5.7.3",
75
+ "typescript-eslint": "^8.32.0"
76
+ }
77
+ }