mulmocast 0.0.12 → 0.0.14

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.
@@ -1,4 +1,5 @@
1
1
  import "dotenv/config";
2
2
  import type { CallbackFunction } from "graphai";
3
3
  import { MulmoStudioContext } from "../types/index.js";
4
+ export declare const audioFilePath: (context: MulmoStudioContext) => string;
4
5
  export declare const audio: (context: MulmoStudioContext, callbacks?: CallbackFunction[]) => Promise<void>;
@@ -166,12 +166,17 @@ const agentFilters = [
166
166
  nodeIds: ["tts"],
167
167
  },
168
168
  ];
169
+ export const audioFilePath = (context) => {
170
+ const { studio, fileDirs } = context;
171
+ const { outDirPath } = fileDirs;
172
+ return getAudioArtifactFilePath(outDirPath, studio.filename);
173
+ };
169
174
  export const audio = async (context, callbacks) => {
170
175
  try {
171
176
  MulmoStudioContextMethods.setSessionState(context, "audio", true);
172
177
  const { studio, fileDirs, lang } = context;
173
178
  const { outDirPath, audioDirPath } = fileDirs;
174
- const audioArtifactFilePath = getAudioArtifactFilePath(outDirPath, studio.filename);
179
+ const audioArtifactFilePath = audioFilePath(context);
175
180
  const audioSegmentDirPath = getAudioSegmentDirPath(audioDirPath, studio.filename);
176
181
  const audioCombinedFilePath = getAudioCombinedFilePath(audioDirPath, studio.filename, lang);
177
182
  const outputStudioFilePath = getOutputStudioFilePath(outDirPath, studio.filename);
@@ -199,7 +204,7 @@ export const audio = async (context, callbacks) => {
199
204
  graph.injectValue("outputStudioFilePath", outputStudioFilePath);
200
205
  graph.injectValue("audioSegmentDirPath", audioSegmentDirPath);
201
206
  graph.injectValue("audioDirPath", audioDirPath);
202
- graph.injectValue("musicFile", MulmoMediaSourceMethods.resolve(studio.script.audioParams.bgm, context) ?? process.env.PATH_BGM ?? defaultBGMPath);
207
+ graph.injectValue("musicFile", MulmoMediaSourceMethods.resolve(studio.script.audioParams.bgm, context) ?? process.env.PATH_BGM ?? defaultBGMPath());
203
208
  if (callbacks) {
204
209
  callbacks.forEach((callback) => {
205
210
  graph.registerCallback(callback);
@@ -1,2 +1,3 @@
1
1
  import { MulmoStudioContext } from "../types/index.js";
2
- export declare const captions: (context: MulmoStudioContext) => Promise<void>;
2
+ import type { CallbackFunction } from "graphai";
3
+ export declare const captions: (context: MulmoStudioContext, callbacks?: CallbackFunction[]) => Promise<void>;
@@ -62,11 +62,16 @@ const graph_data = {
62
62
  },
63
63
  },
64
64
  };
65
- export const captions = async (context) => {
65
+ export const captions = async (context, callbacks) => {
66
66
  try {
67
67
  MulmoStudioContextMethods.setSessionState(context, "caption", true);
68
68
  const graph = new GraphAI(graph_data, { ...vanillaAgents });
69
69
  graph.injectValue("context", context);
70
+ if (callbacks) {
71
+ callbacks.forEach((callback) => {
72
+ graph.registerCallback(callback);
73
+ });
74
+ }
70
75
  await graph.run();
71
76
  }
72
77
  finally {
@@ -7,4 +7,5 @@ export declare const getAudioPart: (inputIndex: number, duration: number, delay:
7
7
  audioId: string;
8
8
  audioPart: string;
9
9
  };
10
+ export declare const movieFilePath: (context: MulmoStudioContext) => string;
10
11
  export declare const movie: (context: MulmoStudioContext) => Promise<void>;
@@ -163,13 +163,17 @@ const createVideo = async (audioArtifactFilePath, outputVideoPath, studio, capti
163
163
  GraphAILogger.info((studio.script.references ?? []).map((reference) => `${reference.title} (${reference.url})`).join("\n"));
164
164
  return true;
165
165
  };
166
+ export const movieFilePath = (context) => {
167
+ const { studio, fileDirs, caption } = context;
168
+ return getOutputVideoFilePath(fileDirs.outDirPath, studio.filename, context.lang, caption);
169
+ };
166
170
  export const movie = async (context) => {
167
171
  MulmoStudioContextMethods.setSessionState(context, "video", true);
168
172
  try {
169
173
  const { studio, fileDirs, caption } = context;
170
174
  const { outDirPath } = fileDirs;
171
175
  const audioArtifactFilePath = getAudioArtifactFilePath(outDirPath, studio.filename);
172
- const outputVideoPath = getOutputVideoFilePath(outDirPath, studio.filename, context.lang, caption);
176
+ const outputVideoPath = movieFilePath(context);
173
177
  if (await createVideo(audioArtifactFilePath, outputVideoPath, studio, caption)) {
174
178
  writingMessage(outputVideoPath);
175
179
  }
@@ -4,7 +4,7 @@ import { FfmpegContextInit, FfmpegContextGenerateOutput, FfmpegContextInputForma
4
4
  const combineAudioFilesAgent = async ({ namedInputs, }) => {
5
5
  const { context, combinedFileName } = namedInputs;
6
6
  const ffmpegContext = FfmpegContextInit();
7
- const longSilentId = FfmpegContextInputFormattedAudio(ffmpegContext, silent60secPath);
7
+ const longSilentId = FfmpegContextInputFormattedAudio(ffmpegContext, silent60secPath());
8
8
  // We cannot reuse longSilentId. We need to explicitly split it for each beat.
9
9
  const silentIds = context.studio.beats.map((_, index) => `[ls_${index}]`);
10
10
  ffmpegContext.filterComplex.push(`${longSilentId}asplit=${silentIds.length}${silentIds.join("")}`);
@@ -27,10 +27,8 @@ export declare const getOutputVideoFilePath: (outDirPath: string, fileName: stri
27
27
  export declare const getOutputPdfFilePath: (outDirPath: string, fileName: string, pdfMode: PDFMode, lang?: string) => string;
28
28
  export declare const getTemplateFilePath: (templateName: string) => string;
29
29
  export declare const mkdir: (dirPath: string) => void;
30
- export declare const silentPath: string;
31
- export declare const silentLastPath: string;
32
- export declare const silent60secPath: string;
33
- export declare const defaultBGMPath: string;
30
+ export declare const silent60secPath: () => string;
31
+ export declare const defaultBGMPath: () => string;
34
32
  export declare const getHTMLFile: (filename: string) => string;
35
33
  export declare const getBaseDirPath: (basedir?: string) => string;
36
34
  export declare const getFullPath: (baseDirPath: string | undefined, file: string) => string;
package/lib/utils/file.js CHANGED
@@ -95,10 +95,10 @@ export const mkdir = (dirPath) => {
95
95
  fs.mkdirSync(dirPath, { recursive: true });
96
96
  }
97
97
  };
98
- export const silentPath = path.resolve(npmRoot, "./assets/audio/silent300.mp3");
99
- export const silentLastPath = path.resolve(npmRoot, "./assets/audio/silent800.mp3");
100
- export const silent60secPath = path.resolve(npmRoot, "./assets/audio/silent60sec.mp3");
101
- export const defaultBGMPath = path.resolve(npmRoot, "./assets/music/StarsBeyondEx.mp3");
98
+ // export const silentPath = path.resolve(npmRoot, "./assets/audio/silent300.mp3");
99
+ // export const silentLastPath = path.resolve(npmRoot, "./assets/audio/silent800.mp3");
100
+ export const silent60secPath = () => path.resolve(npmRoot, "./assets/audio/silent60sec.mp3");
101
+ export const defaultBGMPath = () => path.resolve(npmRoot, "./assets/music/StarsBeyondEx.mp3");
102
102
  export const getHTMLFile = (filename) => {
103
103
  const htmlPath = path.resolve(npmRoot, `./assets/html/${filename}.html`);
104
104
  return fs.readFileSync(htmlPath, "utf-8");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mulmocast",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -11,8 +11,6 @@
11
11
  "./lib",
12
12
  "./scripts/templates",
13
13
  "./assets/music/StarsBeyondEx.mp3",
14
- "./assets/audio/silent300.mp3",
15
- "./assets/audio/silent800.mp3",
16
14
  "./assets/audio/silent60sec.mp3",
17
15
  "./assets/html/",
18
16
  "./assets/font/",
Binary file
Binary file