mulmocast 0.0.20 → 0.0.21
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/images.js +1 -1
- package/lib/agents/combine_audio_files_agent.js +2 -2
- package/lib/agents/image_openai_agent.js +17 -10
- package/lib/agents/movie_google_agent.js +1 -1
- package/lib/index.browser.d.ts +1 -0
- package/lib/index.browser.js +1 -0
- package/lib/methods/mulmo_studio_context.d.ts +1 -15
- package/lib/types/type.d.ts +13 -0
- package/lib/utils/image_plugins/image.d.ts +2 -2
- package/lib/utils/image_plugins/movie.d.ts +2 -2
- package/package.json +1 -1
package/lib/actions/images.js
CHANGED
|
@@ -35,7 +35,7 @@ const getMediaDurations = (context) => {
|
|
|
35
35
|
return {
|
|
36
36
|
movieDuration,
|
|
37
37
|
audioDuration,
|
|
38
|
-
|
|
38
|
+
hasMedia: movieDuration + audioDuration > 0,
|
|
39
39
|
silenceDuration: 0,
|
|
40
40
|
};
|
|
41
41
|
}));
|
|
@@ -70,7 +70,7 @@ const combineAudioFilesAgent = async ({ namedInputs, }) => {
|
|
|
70
70
|
if (audioDuration > 0) {
|
|
71
71
|
// Check if the current beat has spilled over audio.
|
|
72
72
|
const group = [index];
|
|
73
|
-
for (let i = index + 1; i < context.studio.beats.length && !mediaDurations[i].
|
|
73
|
+
for (let i = index + 1; i < context.studio.beats.length && !mediaDurations[i].hasMedia; i++) {
|
|
74
74
|
group.push(i);
|
|
75
75
|
}
|
|
76
76
|
if (group.length > 1) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
+
import { GraphAILogger } from "graphai";
|
|
3
4
|
import OpenAI, { toFile } from "openai";
|
|
4
5
|
import { defaultOpenAIImageModel } from "../utils/const.js";
|
|
5
6
|
// https://platform.openai.com/docs/guides/image-generation
|
|
@@ -42,17 +43,23 @@ export const imageOpenaiAgent = async ({ namedInputs, params }) => {
|
|
|
42
43
|
imageOptions.moderation = moderation || "auto";
|
|
43
44
|
}
|
|
44
45
|
const response = await (async () => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
try {
|
|
47
|
+
const targetSize = imageOptions.size;
|
|
48
|
+
if ((images ?? []).length > 0 && (targetSize === "1536x1024" || targetSize === "1024x1536" || targetSize === "1024x1024")) {
|
|
49
|
+
const imagelist = await Promise.all((images ?? []).map(async (file) => {
|
|
50
|
+
const ext = path.extname(file).toLowerCase();
|
|
51
|
+
const type = ext === ".jpg" || ext === ".jpeg" ? "image/jpeg" : "image/png";
|
|
52
|
+
return await toFile(fs.createReadStream(file), null, { type });
|
|
53
|
+
}));
|
|
54
|
+
return await openai.images.edit({ ...imageOptions, size: targetSize, image: imagelist });
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
return await openai.images.generate(imageOptions);
|
|
58
|
+
}
|
|
53
59
|
}
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
catch (error) {
|
|
61
|
+
GraphAILogger.info("Failed to generate image:", error.message);
|
|
62
|
+
throw error;
|
|
56
63
|
}
|
|
57
64
|
})();
|
|
58
65
|
if (!response.data) {
|
|
@@ -102,7 +102,7 @@ export const movieGoogleAgent = async ({ namedInputs, params, config }) => {
|
|
|
102
102
|
throw new Error("ERROR: geneateImage returned undefined");
|
|
103
103
|
}
|
|
104
104
|
catch (error) {
|
|
105
|
-
GraphAILogger.info("Failed to generate movie:", error);
|
|
105
|
+
GraphAILogger.info("Failed to generate movie:", error.message);
|
|
106
106
|
throw error;
|
|
107
107
|
}
|
|
108
108
|
};
|
package/lib/index.browser.d.ts
CHANGED
package/lib/index.browser.js
CHANGED
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
import { MulmoStudioContext } from "../types/index.js";
|
|
2
|
-
type SessionType = "audio" | "image" | "video" | "multiLingual" | "caption" | "pdf";
|
|
3
|
-
type BeatSessionType = "audio" | "image" | "multiLingual" | "caption" | "movie";
|
|
4
|
-
type SessionProgressEvent = {
|
|
5
|
-
kind: "session";
|
|
6
|
-
sessionType: SessionType;
|
|
7
|
-
inSession: boolean;
|
|
8
|
-
} | {
|
|
9
|
-
kind: "beat";
|
|
10
|
-
sessionType: BeatSessionType;
|
|
11
|
-
index: number;
|
|
12
|
-
inSession: boolean;
|
|
13
|
-
};
|
|
14
|
-
type SessionProgressCallback = (change: SessionProgressEvent) => void;
|
|
1
|
+
import { BeatSessionType, MulmoStudioContext, SessionProgressCallback, SessionType } from "../types/index.js";
|
|
15
2
|
export declare const addSessionProgressCallback: (cb: SessionProgressCallback) => void;
|
|
16
3
|
export declare const removeSessionProgressCallback: (cb: SessionProgressCallback) => void;
|
|
17
4
|
export declare const MulmoStudioContextMethods: {
|
|
@@ -25,4 +12,3 @@ export declare const MulmoStudioContextMethods: {
|
|
|
25
12
|
setSessionState(context: MulmoStudioContext, sessionType: SessionType, value: boolean): void;
|
|
26
13
|
setBeatSessionState(context: MulmoStudioContext, sessionType: BeatSessionType, index: number, value: boolean): void;
|
|
27
14
|
};
|
|
28
|
-
export {};
|
package/lib/types/type.d.ts
CHANGED
|
@@ -79,3 +79,16 @@ export type Text2ImageAgentInfo = {
|
|
|
79
79
|
};
|
|
80
80
|
export type BeatMediaType = "movie" | "image";
|
|
81
81
|
export type StoryToScriptGenerateMode = (typeof storyToScriptGenerateMode)[keyof typeof storyToScriptGenerateMode];
|
|
82
|
+
export type SessionType = "audio" | "image" | "video" | "multiLingual" | "caption" | "pdf";
|
|
83
|
+
export type BeatSessionType = "audio" | "image" | "multiLingual" | "caption" | "movie";
|
|
84
|
+
export type SessionProgressEvent = {
|
|
85
|
+
kind: "session";
|
|
86
|
+
sessionType: SessionType;
|
|
87
|
+
inSession: boolean;
|
|
88
|
+
} | {
|
|
89
|
+
kind: "beat";
|
|
90
|
+
sessionType: BeatSessionType;
|
|
91
|
+
index: number;
|
|
92
|
+
inSession: boolean;
|
|
93
|
+
};
|
|
94
|
+
export type SessionProgressCallback = (change: SessionProgressEvent) => void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const imageType = "image";
|
|
2
|
-
export declare const process: (params: import("../../index.js").ImageProcessorParams) => string | undefined;
|
|
3
|
-
export declare const path: (params: import("../../index.js").ImageProcessorParams) => string | undefined;
|
|
2
|
+
export declare const process: (params: import("../../index.browser.js").ImageProcessorParams) => string | undefined;
|
|
3
|
+
export declare const path: (params: import("../../index.browser.js").ImageProcessorParams) => string | undefined;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const imageType = "movie";
|
|
2
|
-
export declare const process: (params: import("../../index.js").ImageProcessorParams) => string | undefined;
|
|
3
|
-
export declare const path: (params: import("../../index.js").ImageProcessorParams) => string | undefined;
|
|
2
|
+
export declare const process: (params: import("../../index.browser.js").ImageProcessorParams) => string | undefined;
|
|
3
|
+
export declare const path: (params: import("../../index.browser.js").ImageProcessorParams) => string | undefined;
|