magic-hour 0.36.0 → 0.37.0
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/README.md +202 -10
- package/dist/helpers/download.d.ts +5 -0
- package/dist/helpers/download.js +88 -0
- package/dist/helpers/generate-type.d.ts +51 -0
- package/dist/helpers/generate-type.js +2 -0
- package/dist/helpers/sleep.d.ts +4 -0
- package/dist/helpers/sleep.js +9 -0
- package/dist/logger.d.ts +48 -0
- package/dist/logger.js +97 -0
- package/dist/resources/v1/ai-clothes-changer/resource-client.d.ts +50 -0
- package/dist/resources/v1/ai-clothes-changer/resource-client.js +75 -0
- package/dist/resources/v1/ai-face-editor/resource-client.d.ts +55 -0
- package/dist/resources/v1/ai-face-editor/resource-client.js +85 -0
- package/dist/resources/v1/ai-gif-generator/resource-client.d.ts +29 -0
- package/dist/resources/v1/ai-gif-generator/resource-client.js +60 -0
- package/dist/resources/v1/ai-headshot-generator/resource-client.d.ts +38 -0
- package/dist/resources/v1/ai-headshot-generator/resource-client.js +68 -0
- package/dist/resources/v1/ai-image-editor/resource-client.d.ts +39 -0
- package/dist/resources/v1/ai-image-editor/resource-client.js +69 -0
- package/dist/resources/v1/ai-image-generator/resource-client.d.ts +31 -0
- package/dist/resources/v1/ai-image-generator/resource-client.js +62 -0
- package/dist/resources/v1/ai-image-upscaler/resource-client.d.ts +40 -0
- package/dist/resources/v1/ai-image-upscaler/resource-client.js +70 -0
- package/dist/resources/v1/ai-meme-generator/resource-client.d.ts +33 -0
- package/dist/resources/v1/ai-meme-generator/resource-client.js +64 -0
- package/dist/resources/v1/ai-photo-editor/resource-client.d.ts +49 -0
- package/dist/resources/v1/ai-photo-editor/resource-client.js +79 -0
- package/dist/resources/v1/ai-qr-code-generator/resource-client.d.ts +30 -0
- package/dist/resources/v1/ai-qr-code-generator/resource-client.js +61 -0
- package/dist/resources/v1/ai-talking-photo/resource-client.d.ts +51 -0
- package/dist/resources/v1/ai-talking-photo/resource-client.js +76 -0
- package/dist/resources/v1/animation/resource-client.d.ts +61 -0
- package/dist/resources/v1/animation/resource-client.js +98 -0
- package/dist/resources/v1/auto-subtitle-generator/resource-client.d.ts +41 -0
- package/dist/resources/v1/auto-subtitle-generator/resource-client.js +71 -0
- package/dist/resources/v1/face-detection/resource-client.d.ts +30 -0
- package/dist/resources/v1/face-detection/resource-client.js +75 -0
- package/dist/resources/v1/face-swap/resource-client.d.ts +77 -0
- package/dist/resources/v1/face-swap/resource-client.js +125 -0
- package/dist/resources/v1/face-swap-photo/resource-client.d.ts +73 -0
- package/dist/resources/v1/face-swap-photo/resource-client.js +117 -0
- package/dist/resources/v1/files/resource-client.d.ts +40 -0
- package/dist/resources/v1/files/resource-client.js +236 -0
- package/dist/resources/v1/files/resource-client.test.d.ts +1 -0
- package/dist/resources/v1/files/resource-client.test.js +422 -0
- package/dist/resources/v1/image-background-remover/resource-client.d.ts +49 -0
- package/dist/resources/v1/image-background-remover/resource-client.js +82 -0
- package/dist/resources/v1/image-projects/resource-client.d.ts +22 -0
- package/dist/resources/v1/image-projects/resource-client.js +68 -0
- package/dist/resources/v1/image-projects/resource-client.test.d.ts +1 -0
- package/dist/resources/v1/image-projects/resource-client.test.js +538 -0
- package/dist/resources/v1/image-to-video/resource-client.d.ts +40 -0
- package/dist/resources/v1/image-to-video/resource-client.js +70 -0
- package/dist/resources/v1/lip-sync/resource-client.d.ts +53 -0
- package/dist/resources/v1/lip-sync/resource-client.js +84 -0
- package/dist/resources/v1/photo-colorizer/resource-client.d.ts +38 -0
- package/dist/resources/v1/photo-colorizer/resource-client.js +68 -0
- package/dist/resources/v1/text-to-video/resource-client.d.ts +32 -0
- package/dist/resources/v1/text-to-video/resource-client.js +63 -0
- package/dist/resources/v1/video-projects/resource-client.d.ts +22 -0
- package/dist/resources/v1/video-projects/resource-client.js +68 -0
- package/dist/resources/v1/video-projects/resource-client.test.d.ts +1 -0
- package/dist/resources/v1/video-projects/resource-client.test.js +713 -0
- package/dist/resources/v1/video-to-video/resource-client.d.ts +48 -0
- package/dist/resources/v1/video-to-video/resource-client.js +84 -0
- package/package.json +15 -11
|
@@ -1,13 +1,74 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
2
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
23
|
exports.AiQrCodeGeneratorClient = void 0;
|
|
4
24
|
const core_1 = require("../../../core");
|
|
5
25
|
const v1_ai_qr_code_generator_create_body_1 = require("../../../types/v1-ai-qr-code-generator-create-body");
|
|
6
26
|
const v1_ai_qr_code_generator_create_response_1 = require("../../../types/v1-ai-qr-code-generator-create-response");
|
|
27
|
+
const logger_1 = require("../../../logger");
|
|
28
|
+
const image_projects_1 = require("../../../resources/v1/image-projects");
|
|
7
29
|
class AiQrCodeGeneratorClient extends core_1.CoreResourceClient {
|
|
8
30
|
constructor(coreClient, opts) {
|
|
9
31
|
super(coreClient, opts);
|
|
10
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* AI QR Code
|
|
35
|
+
*
|
|
36
|
+
* Create an AI QR code
|
|
37
|
+
*
|
|
38
|
+
* This method provides a convenient way to create a request and automatically wait for completion and download outputs.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* import Client from "../../../index.js";
|
|
43
|
+
*
|
|
44
|
+
* const client = new Client({ token: process.env["API_TOKEN"]!! });
|
|
45
|
+
* const res = await client.v1.aiQrCodeGenerator.generate(
|
|
46
|
+
* {
|
|
47
|
+
* content: "https://magichour.ai",
|
|
48
|
+
* name: "Qr Code image",
|
|
49
|
+
* style: { artStyle: "Watercolor" },
|
|
50
|
+
* },
|
|
51
|
+
* {
|
|
52
|
+
* waitForCompletion: true,
|
|
53
|
+
* downloadOutputs: true,
|
|
54
|
+
* downloadDirectory: "outputs",
|
|
55
|
+
* },
|
|
56
|
+
* );
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
generate(request_1) {
|
|
60
|
+
return __awaiter(this, arguments, void 0, function* (request, opts = {}) {
|
|
61
|
+
const { waitForCompletion = true, downloadOutputs = true, downloadDirectory = undefined } = opts, createOpts = __rest(opts, ["waitForCompletion", "downloadOutputs", "downloadDirectory"]);
|
|
62
|
+
const createResponse = yield this.create(request, createOpts);
|
|
63
|
+
(0, logger_1.getLogger)().info(`Created AiQrCodeGeneratorClient project ${createResponse.id}`);
|
|
64
|
+
const projectsClient = new image_projects_1.ImageProjectsClient(this._client, this._opts);
|
|
65
|
+
(0, logger_1.getLogger)().debug(`Checking result for AiQrCodeGeneratorClient project ${createResponse.id}`);
|
|
66
|
+
const result = yield projectsClient.checkResult({ id: createResponse.id }, Object.assign({ waitForCompletion,
|
|
67
|
+
downloadOutputs,
|
|
68
|
+
downloadDirectory }, createOpts));
|
|
69
|
+
return result;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
11
72
|
/**
|
|
12
73
|
* AI QR Code
|
|
13
74
|
*
|
|
@@ -1,8 +1,58 @@
|
|
|
1
1
|
import { types } from "../../../index.js";
|
|
2
2
|
import { ApiPromise, CoreClient, CoreResourceClient, RequestOptions, ResourceClientOptions } from "../../../core";
|
|
3
|
+
import { GenerateOptions, GenerateRequestType } from "../../../helpers/generate-type";
|
|
3
4
|
import * as requests from "../../../resources/v1/ai-talking-photo/request-types";
|
|
5
|
+
type GenerateRequest = GenerateRequestType<requests.CreateRequest, {
|
|
6
|
+
/**
|
|
7
|
+
* The audio file to sync with the image. This value is either
|
|
8
|
+
* - a direct URL to the image file
|
|
9
|
+
* - a path to a local file
|
|
10
|
+
*
|
|
11
|
+
* Note: if the path begins with `api-assets`, it will be assumed to already be uploaded to Magic Hour's storage, and will not be uploaded again.
|
|
12
|
+
*/
|
|
13
|
+
audioFilePath: string;
|
|
14
|
+
/**
|
|
15
|
+
* The source image to animate. This value is either
|
|
16
|
+
* - a direct URL to the image file
|
|
17
|
+
* - a path to a local file
|
|
18
|
+
*
|
|
19
|
+
* Note: if the path begins with `api-assets`, it will be assumed to already be uploaded to Magic Hour's storage, and will not be uploaded again.
|
|
20
|
+
*/
|
|
21
|
+
imageFilePath: string;
|
|
22
|
+
}>;
|
|
4
23
|
export declare class AiTalkingPhotoClient extends CoreResourceClient {
|
|
5
24
|
constructor(coreClient: CoreClient, opts: ResourceClientOptions);
|
|
25
|
+
/**
|
|
26
|
+
* AI Talking Photo
|
|
27
|
+
*
|
|
28
|
+
* Create a talking photo from an image and audio or text input
|
|
29
|
+
*
|
|
30
|
+
* This method provides a convenient way to create a request and automatically wait for completion and download outputs.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* import Client from "../../../index.js";
|
|
35
|
+
*
|
|
36
|
+
* const client = new Client({ token: process.env["API_TOKEN"]!! });
|
|
37
|
+
* const res = await client.v1.aiTalkingPhoto.generate(
|
|
38
|
+
* {
|
|
39
|
+
* assets: {
|
|
40
|
+
* audioFilePath: "/path/to/1234.mp3",
|
|
41
|
+
* imageFilePath: "/path/to/1234.png",
|
|
42
|
+
* },
|
|
43
|
+
* endSeconds: 15.0,
|
|
44
|
+
* name: "Talking Photo image",
|
|
45
|
+
* startSeconds: 0.0,
|
|
46
|
+
* },
|
|
47
|
+
* {
|
|
48
|
+
* waitForCompletion: true,
|
|
49
|
+
* downloadOutputs: true,
|
|
50
|
+
* downloadDirectory: "outputs",
|
|
51
|
+
* },
|
|
52
|
+
* );
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
generate(request: GenerateRequest, opts?: GenerateOptions): Promise<import("../video-projects/resource-client").V1VideoProjectsGetResponseWithDownloads>;
|
|
6
56
|
/**
|
|
7
57
|
* AI Talking Photo
|
|
8
58
|
*
|
|
@@ -12,3 +62,4 @@ export declare class AiTalkingPhotoClient extends CoreResourceClient {
|
|
|
12
62
|
*/
|
|
13
63
|
create(request: requests.CreateRequest, opts?: RequestOptions): ApiPromise<types.V1AiTalkingPhotoCreateResponse>;
|
|
14
64
|
}
|
|
65
|
+
export {};
|
|
@@ -1,13 +1,89 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
2
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
23
|
exports.AiTalkingPhotoClient = void 0;
|
|
4
24
|
const core_1 = require("../../../core");
|
|
25
|
+
const files_1 = require("../../../resources/v1/files");
|
|
5
26
|
const v1_ai_talking_photo_create_body_1 = require("../../../types/v1-ai-talking-photo-create-body");
|
|
6
27
|
const v1_ai_talking_photo_create_response_1 = require("../../../types/v1-ai-talking-photo-create-response");
|
|
28
|
+
const logger_1 = require("../../../logger");
|
|
29
|
+
const video_projects_1 = require("../../../resources/v1/video-projects");
|
|
7
30
|
class AiTalkingPhotoClient extends core_1.CoreResourceClient {
|
|
8
31
|
constructor(coreClient, opts) {
|
|
9
32
|
super(coreClient, opts);
|
|
10
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* AI Talking Photo
|
|
36
|
+
*
|
|
37
|
+
* Create a talking photo from an image and audio or text input
|
|
38
|
+
*
|
|
39
|
+
* This method provides a convenient way to create a request and automatically wait for completion and download outputs.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* import Client from "../../../index.js";
|
|
44
|
+
*
|
|
45
|
+
* const client = new Client({ token: process.env["API_TOKEN"]!! });
|
|
46
|
+
* const res = await client.v1.aiTalkingPhoto.generate(
|
|
47
|
+
* {
|
|
48
|
+
* assets: {
|
|
49
|
+
* audioFilePath: "/path/to/1234.mp3",
|
|
50
|
+
* imageFilePath: "/path/to/1234.png",
|
|
51
|
+
* },
|
|
52
|
+
* endSeconds: 15.0,
|
|
53
|
+
* name: "Talking Photo image",
|
|
54
|
+
* startSeconds: 0.0,
|
|
55
|
+
* },
|
|
56
|
+
* {
|
|
57
|
+
* waitForCompletion: true,
|
|
58
|
+
* downloadOutputs: true,
|
|
59
|
+
* downloadDirectory: "outputs",
|
|
60
|
+
* },
|
|
61
|
+
* );
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
generate(request_1) {
|
|
65
|
+
return __awaiter(this, arguments, void 0, function* (request, opts = {}) {
|
|
66
|
+
const { waitForCompletion = true, downloadOutputs = true, downloadDirectory = undefined } = opts, createOpts = __rest(opts, ["waitForCompletion", "downloadOutputs", "downloadDirectory"]);
|
|
67
|
+
const fileClient = new files_1.FilesClient(this._client, this._opts);
|
|
68
|
+
const _a = request.assets, { audioFilePath, imageFilePath } = _a, restAssets = __rest(_a, ["audioFilePath", "imageFilePath"]);
|
|
69
|
+
(0, logger_1.getLogger)().debug(`Uploading file ${audioFilePath} to Magic Hour's storage`);
|
|
70
|
+
(0, logger_1.getLogger)().debug(`Uploading file ${imageFilePath} to Magic Hour's storage`);
|
|
71
|
+
const [uploadedAudioFilePath, uploadedImageFilePath] = yield Promise.all([
|
|
72
|
+
fileClient.uploadFile(audioFilePath),
|
|
73
|
+
fileClient.uploadFile(imageFilePath),
|
|
74
|
+
]);
|
|
75
|
+
(0, logger_1.getLogger)().info(`Uploaded file ${audioFilePath} to Magic Hour's storage as ${uploadedAudioFilePath}`);
|
|
76
|
+
(0, logger_1.getLogger)().info(`Uploaded file ${imageFilePath} to Magic Hour's storage as ${uploadedImageFilePath}`);
|
|
77
|
+
const createResponse = yield this.create(Object.assign(Object.assign({}, request), { assets: Object.assign(Object.assign({}, restAssets), { audioFilePath: uploadedAudioFilePath, imageFilePath: uploadedImageFilePath }) }), createOpts);
|
|
78
|
+
(0, logger_1.getLogger)().info(`Created AiTalkingPhotoClient project ${createResponse.id}`);
|
|
79
|
+
const projectsClient = new video_projects_1.VideoProjectsClient(this._client, this._opts);
|
|
80
|
+
(0, logger_1.getLogger)().debug(`Checking result for AiTalkingPhotoClient project ${createResponse.id}`);
|
|
81
|
+
const result = yield projectsClient.checkResult({ id: createResponse.id }, Object.assign({ waitForCompletion,
|
|
82
|
+
downloadOutputs,
|
|
83
|
+
downloadDirectory }, createOpts));
|
|
84
|
+
return result;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
11
87
|
/**
|
|
12
88
|
* AI Talking Photo
|
|
13
89
|
*
|
|
@@ -1,8 +1,68 @@
|
|
|
1
1
|
import { types } from "../../../index.js";
|
|
2
2
|
import { ApiPromise, CoreClient, CoreResourceClient, RequestOptions, ResourceClientOptions } from "../../../core";
|
|
3
|
+
import { GenerateOptions, GenerateRequestType } from "../../../helpers/generate-type";
|
|
3
4
|
import * as requests from "../../../resources/v1/animation/request-types";
|
|
5
|
+
type GenerateRequest = GenerateRequestType<requests.CreateRequest, {
|
|
6
|
+
/**
|
|
7
|
+
* The path of the input audio. This value is either
|
|
8
|
+
* - a direct URL to the image file
|
|
9
|
+
* - a path to a local file
|
|
10
|
+
*
|
|
11
|
+
* Note: if the path begins with `api-assets`, it will be assumed to already be uploaded to Magic Hour's storage, and will not be uploaded again.
|
|
12
|
+
*/
|
|
13
|
+
audioFilePath?: string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* An initial image to use a the first frame of the video. This value is either
|
|
16
|
+
* - a direct URL to the image file
|
|
17
|
+
* - a path to a local file
|
|
18
|
+
*
|
|
19
|
+
* Note: if the path begins with `api-assets`, it will be assumed to already be uploaded to Magic Hour's storage, and will not be uploaded again.
|
|
20
|
+
*/
|
|
21
|
+
imageFilePath?: string | undefined;
|
|
22
|
+
}>;
|
|
4
23
|
export declare class AnimationClient extends CoreResourceClient {
|
|
5
24
|
constructor(coreClient: CoreClient, opts: ResourceClientOptions);
|
|
25
|
+
/**
|
|
26
|
+
* Animation
|
|
27
|
+
*
|
|
28
|
+
* Create a Animation video
|
|
29
|
+
*
|
|
30
|
+
* This method provides a convenient way to create a request and automatically wait for completion and download outputs.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* import Client from "../../../index.js";
|
|
35
|
+
*
|
|
36
|
+
* const client = new Client({ token: process.env["API_TOKEN"]!! });
|
|
37
|
+
* const res = await client.v1.animation.generate(
|
|
38
|
+
* {
|
|
39
|
+
* assets: {
|
|
40
|
+
* audioFilePath: "/path/to/1234.mp3",
|
|
41
|
+
* audioSource: "file",
|
|
42
|
+
* imageFilePath: "/path/to/1234.png",
|
|
43
|
+
* },
|
|
44
|
+
* endSeconds: 15.0,
|
|
45
|
+
* fps: 12.0,
|
|
46
|
+
* height: 960,
|
|
47
|
+
* name: "Animation video",
|
|
48
|
+
* style: {
|
|
49
|
+
* artStyle: "Painterly Illustration",
|
|
50
|
+
* cameraEffect: "Simple Zoom In",
|
|
51
|
+
* prompt: "Cyberpunk city",
|
|
52
|
+
* promptType: "custom",
|
|
53
|
+
* transitionSpeed: 5,
|
|
54
|
+
* },
|
|
55
|
+
* width: 512,
|
|
56
|
+
* },
|
|
57
|
+
* {
|
|
58
|
+
* waitForCompletion: true,
|
|
59
|
+
* downloadOutputs: true,
|
|
60
|
+
* downloadDirectory: "outputs",
|
|
61
|
+
* },
|
|
62
|
+
* );
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
generate(request: GenerateRequest, opts?: GenerateOptions): Promise<import("../video-projects/resource-client").V1VideoProjectsGetResponseWithDownloads>;
|
|
6
66
|
/**
|
|
7
67
|
* Animation
|
|
8
68
|
*
|
|
@@ -12,3 +72,4 @@ export declare class AnimationClient extends CoreResourceClient {
|
|
|
12
72
|
*/
|
|
13
73
|
create(request: requests.CreateRequest, opts?: RequestOptions): ApiPromise<types.V1AnimationCreateResponse>;
|
|
14
74
|
}
|
|
75
|
+
export {};
|
|
@@ -1,13 +1,111 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
2
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
23
|
exports.AnimationClient = void 0;
|
|
4
24
|
const core_1 = require("../../../core");
|
|
25
|
+
const files_1 = require("../../../resources/v1/files");
|
|
5
26
|
const v1_animation_create_body_1 = require("../../../types/v1-animation-create-body");
|
|
6
27
|
const v1_animation_create_response_1 = require("../../../types/v1-animation-create-response");
|
|
28
|
+
const logger_1 = require("../../../logger");
|
|
29
|
+
const video_projects_1 = require("../../../resources/v1/video-projects");
|
|
7
30
|
class AnimationClient extends core_1.CoreResourceClient {
|
|
8
31
|
constructor(coreClient, opts) {
|
|
9
32
|
super(coreClient, opts);
|
|
10
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Animation
|
|
36
|
+
*
|
|
37
|
+
* Create a Animation video
|
|
38
|
+
*
|
|
39
|
+
* This method provides a convenient way to create a request and automatically wait for completion and download outputs.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* import Client from "../../../index.js";
|
|
44
|
+
*
|
|
45
|
+
* const client = new Client({ token: process.env["API_TOKEN"]!! });
|
|
46
|
+
* const res = await client.v1.animation.generate(
|
|
47
|
+
* {
|
|
48
|
+
* assets: {
|
|
49
|
+
* audioFilePath: "/path/to/1234.mp3",
|
|
50
|
+
* audioSource: "file",
|
|
51
|
+
* imageFilePath: "/path/to/1234.png",
|
|
52
|
+
* },
|
|
53
|
+
* endSeconds: 15.0,
|
|
54
|
+
* fps: 12.0,
|
|
55
|
+
* height: 960,
|
|
56
|
+
* name: "Animation video",
|
|
57
|
+
* style: {
|
|
58
|
+
* artStyle: "Painterly Illustration",
|
|
59
|
+
* cameraEffect: "Simple Zoom In",
|
|
60
|
+
* prompt: "Cyberpunk city",
|
|
61
|
+
* promptType: "custom",
|
|
62
|
+
* transitionSpeed: 5,
|
|
63
|
+
* },
|
|
64
|
+
* width: 512,
|
|
65
|
+
* },
|
|
66
|
+
* {
|
|
67
|
+
* waitForCompletion: true,
|
|
68
|
+
* downloadOutputs: true,
|
|
69
|
+
* downloadDirectory: "outputs",
|
|
70
|
+
* },
|
|
71
|
+
* );
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
generate(request_1) {
|
|
75
|
+
return __awaiter(this, arguments, void 0, function* (request, opts = {}) {
|
|
76
|
+
const { waitForCompletion = true, downloadOutputs = true, downloadDirectory = undefined } = opts, createOpts = __rest(opts, ["waitForCompletion", "downloadOutputs", "downloadDirectory"]);
|
|
77
|
+
const fileClient = new files_1.FilesClient(this._client, this._opts);
|
|
78
|
+
const _a = request.assets, { audioFilePath, imageFilePath } = _a, restAssets = __rest(_a, ["audioFilePath", "imageFilePath"]);
|
|
79
|
+
if (audioFilePath) {
|
|
80
|
+
(0, logger_1.getLogger)().debug(`Uploading file ${audioFilePath} to Magic Hour's storage`);
|
|
81
|
+
}
|
|
82
|
+
if (imageFilePath) {
|
|
83
|
+
(0, logger_1.getLogger)().debug(`Uploading file ${imageFilePath} to Magic Hour's storage`);
|
|
84
|
+
}
|
|
85
|
+
const [uploadedAudioFilePath, uploadedImageFilePath] = yield Promise.all([
|
|
86
|
+
audioFilePath
|
|
87
|
+
? fileClient.uploadFile(audioFilePath)
|
|
88
|
+
: Promise.resolve(audioFilePath),
|
|
89
|
+
imageFilePath
|
|
90
|
+
? fileClient.uploadFile(imageFilePath)
|
|
91
|
+
: Promise.resolve(imageFilePath),
|
|
92
|
+
]);
|
|
93
|
+
if (audioFilePath) {
|
|
94
|
+
(0, logger_1.getLogger)().info(`Uploaded file ${audioFilePath} to Magic Hour's storage as ${uploadedAudioFilePath}`);
|
|
95
|
+
}
|
|
96
|
+
if (imageFilePath) {
|
|
97
|
+
(0, logger_1.getLogger)().info(`Uploaded file ${imageFilePath} to Magic Hour's storage as ${uploadedImageFilePath}`);
|
|
98
|
+
}
|
|
99
|
+
const createResponse = yield this.create(Object.assign(Object.assign({}, request), { assets: Object.assign(Object.assign({}, restAssets), { audioFilePath: audioFilePath ? uploadedAudioFilePath : audioFilePath, imageFilePath: imageFilePath ? uploadedImageFilePath : imageFilePath }) }), createOpts);
|
|
100
|
+
(0, logger_1.getLogger)().info(`Created AnimationClient project ${createResponse.id}`);
|
|
101
|
+
const projectsClient = new video_projects_1.VideoProjectsClient(this._client, this._opts);
|
|
102
|
+
(0, logger_1.getLogger)().debug(`Checking result for AnimationClient project ${createResponse.id}`);
|
|
103
|
+
const result = yield projectsClient.checkResult({ id: createResponse.id }, Object.assign({ waitForCompletion,
|
|
104
|
+
downloadOutputs,
|
|
105
|
+
downloadDirectory }, createOpts));
|
|
106
|
+
return result;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
11
109
|
/**
|
|
12
110
|
* Animation
|
|
13
111
|
*
|
|
@@ -1,8 +1,48 @@
|
|
|
1
1
|
import { types } from "../../../index.js";
|
|
2
2
|
import { ApiPromise, CoreClient, CoreResourceClient, RequestOptions, ResourceClientOptions } from "../../../core";
|
|
3
|
+
import { GenerateOptions, GenerateRequestType } from "../../../helpers/generate-type";
|
|
3
4
|
import * as requests from "../../../resources/v1/auto-subtitle-generator/request-types";
|
|
5
|
+
type GenerateRequest = GenerateRequestType<requests.CreateRequest, {
|
|
6
|
+
/**
|
|
7
|
+
* This is the video used to add subtitles. This value is either
|
|
8
|
+
* - a direct URL to the image file
|
|
9
|
+
* - a path to a local file
|
|
10
|
+
*
|
|
11
|
+
* Note: if the path begins with `api-assets`, it will be assumed to already be uploaded to Magic Hour's storage, and will not be uploaded again.
|
|
12
|
+
*/
|
|
13
|
+
videoFilePath: string;
|
|
14
|
+
}>;
|
|
4
15
|
export declare class AutoSubtitleGeneratorClient extends CoreResourceClient {
|
|
5
16
|
constructor(coreClient: CoreClient, opts: ResourceClientOptions);
|
|
17
|
+
/**
|
|
18
|
+
* Auto Subtitle Generator
|
|
19
|
+
*
|
|
20
|
+
* Automatically generate subtitles for your video in multiple languages
|
|
21
|
+
*
|
|
22
|
+
* This method provides a convenient way to create a request and automatically wait for completion and download outputs.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import Client from "../../../index.js";
|
|
27
|
+
*
|
|
28
|
+
* const client = new Client({ token: process.env["API_TOKEN"]!! });
|
|
29
|
+
* const res = await client.v1.autoSubtitleGenerator.generate(
|
|
30
|
+
* {
|
|
31
|
+
* assets: { videoFilePath: "/path/to/1234.mp4" },
|
|
32
|
+
* endSeconds: 15.0,
|
|
33
|
+
* name: "Auto Subtitle video",
|
|
34
|
+
* startSeconds: 0.0,
|
|
35
|
+
* style: {},
|
|
36
|
+
* },
|
|
37
|
+
* {
|
|
38
|
+
* waitForCompletion: true,
|
|
39
|
+
* downloadOutputs: true,
|
|
40
|
+
* downloadDirectory: "outputs",
|
|
41
|
+
* },
|
|
42
|
+
* );
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
generate(request: GenerateRequest, opts?: GenerateOptions): Promise<import("../video-projects/resource-client").V1VideoProjectsGetResponseWithDownloads>;
|
|
6
46
|
/**
|
|
7
47
|
* Auto Subtitle Generator
|
|
8
48
|
*
|
|
@@ -12,3 +52,4 @@ export declare class AutoSubtitleGeneratorClient extends CoreResourceClient {
|
|
|
12
52
|
*/
|
|
13
53
|
create(request: requests.CreateRequest, opts?: RequestOptions): ApiPromise<types.V1AutoSubtitleGeneratorCreateResponse>;
|
|
14
54
|
}
|
|
55
|
+
export {};
|
|
@@ -1,13 +1,84 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
2
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
23
|
exports.AutoSubtitleGeneratorClient = void 0;
|
|
4
24
|
const core_1 = require("../../../core");
|
|
25
|
+
const files_1 = require("../../../resources/v1/files");
|
|
5
26
|
const v1_auto_subtitle_generator_create_body_1 = require("../../../types/v1-auto-subtitle-generator-create-body");
|
|
6
27
|
const v1_auto_subtitle_generator_create_response_1 = require("../../../types/v1-auto-subtitle-generator-create-response");
|
|
28
|
+
const logger_1 = require("../../../logger");
|
|
29
|
+
const video_projects_1 = require("../../../resources/v1/video-projects");
|
|
7
30
|
class AutoSubtitleGeneratorClient extends core_1.CoreResourceClient {
|
|
8
31
|
constructor(coreClient, opts) {
|
|
9
32
|
super(coreClient, opts);
|
|
10
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Auto Subtitle Generator
|
|
36
|
+
*
|
|
37
|
+
* Automatically generate subtitles for your video in multiple languages
|
|
38
|
+
*
|
|
39
|
+
* This method provides a convenient way to create a request and automatically wait for completion and download outputs.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* import Client from "../../../index.js";
|
|
44
|
+
*
|
|
45
|
+
* const client = new Client({ token: process.env["API_TOKEN"]!! });
|
|
46
|
+
* const res = await client.v1.autoSubtitleGenerator.generate(
|
|
47
|
+
* {
|
|
48
|
+
* assets: { videoFilePath: "/path/to/1234.mp4" },
|
|
49
|
+
* endSeconds: 15.0,
|
|
50
|
+
* name: "Auto Subtitle video",
|
|
51
|
+
* startSeconds: 0.0,
|
|
52
|
+
* style: {},
|
|
53
|
+
* },
|
|
54
|
+
* {
|
|
55
|
+
* waitForCompletion: true,
|
|
56
|
+
* downloadOutputs: true,
|
|
57
|
+
* downloadDirectory: "outputs",
|
|
58
|
+
* },
|
|
59
|
+
* );
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
generate(request_1) {
|
|
63
|
+
return __awaiter(this, arguments, void 0, function* (request, opts = {}) {
|
|
64
|
+
const { waitForCompletion = true, downloadOutputs = true, downloadDirectory = undefined } = opts, createOpts = __rest(opts, ["waitForCompletion", "downloadOutputs", "downloadDirectory"]);
|
|
65
|
+
const fileClient = new files_1.FilesClient(this._client, this._opts);
|
|
66
|
+
const _a = request.assets, { videoFilePath } = _a, restAssets = __rest(_a, ["videoFilePath"]);
|
|
67
|
+
(0, logger_1.getLogger)().debug(`Uploading file ${videoFilePath} to Magic Hour's storage`);
|
|
68
|
+
const [uploadedVideoFilePath] = yield Promise.all([
|
|
69
|
+
fileClient.uploadFile(videoFilePath),
|
|
70
|
+
]);
|
|
71
|
+
(0, logger_1.getLogger)().info(`Uploaded file ${videoFilePath} to Magic Hour's storage as ${uploadedVideoFilePath}`);
|
|
72
|
+
const createResponse = yield this.create(Object.assign(Object.assign({}, request), { assets: Object.assign(Object.assign({}, restAssets), { videoFilePath: uploadedVideoFilePath }) }), createOpts);
|
|
73
|
+
(0, logger_1.getLogger)().info(`Created AutoSubtitleGeneratorClient project ${createResponse.id}`);
|
|
74
|
+
const projectsClient = new video_projects_1.VideoProjectsClient(this._client, this._opts);
|
|
75
|
+
(0, logger_1.getLogger)().debug(`Checking result for AutoSubtitleGeneratorClient project ${createResponse.id}`);
|
|
76
|
+
const result = yield projectsClient.checkResult({ id: createResponse.id }, Object.assign({ waitForCompletion,
|
|
77
|
+
downloadOutputs,
|
|
78
|
+
downloadDirectory }, createOpts));
|
|
79
|
+
return result;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
11
82
|
/**
|
|
12
83
|
* Auto Subtitle Generator
|
|
13
84
|
*
|
|
@@ -1,8 +1,37 @@
|
|
|
1
1
|
import { types } from "../../../index.js";
|
|
2
2
|
import { ApiPromise, CoreClient, CoreResourceClient, RequestOptions, ResourceClientOptions } from "../../../core";
|
|
3
|
+
import { GenerateOptions, GenerateRequestType } from "../../../helpers/generate-type";
|
|
3
4
|
import * as requests from "../../../resources/v1/face-detection/request-types";
|
|
5
|
+
type GenerateRequest = GenerateRequestType<requests.CreateRequest, {
|
|
6
|
+
/** This is the image or video where the face will be detected. This value is either
|
|
7
|
+
* - a direct URL to the image file
|
|
8
|
+
* - a path to a local file
|
|
9
|
+
*
|
|
10
|
+
* Note: if the path begins with `api-assets`, it will be assumed to already be uploaded to Magic Hour's storage, and will not be uploaded again. */
|
|
11
|
+
targetFilePath: string;
|
|
12
|
+
}>;
|
|
4
13
|
export declare class FaceDetectionClient extends CoreResourceClient {
|
|
5
14
|
constructor(coreClient: CoreClient, opts: ResourceClientOptions);
|
|
15
|
+
/**
|
|
16
|
+
* Face Detection
|
|
17
|
+
*
|
|
18
|
+
* Detect faces in an image or video
|
|
19
|
+
*
|
|
20
|
+
* This method provides a convenient way to create a request and automatically wait for completion and download outputs.
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
generate(request: GenerateRequest, opts?: GenerateOptions): Promise<{
|
|
24
|
+
creditsCharged: number;
|
|
25
|
+
faces: types.V1FaceDetectionGetResponseFacesItem[];
|
|
26
|
+
id: string;
|
|
27
|
+
status: "complete" | "error" | "queued" | "rendering";
|
|
28
|
+
} | {
|
|
29
|
+
downloadedPaths: string[];
|
|
30
|
+
creditsCharged: number;
|
|
31
|
+
faces: types.V1FaceDetectionGetResponseFacesItem[];
|
|
32
|
+
id: string;
|
|
33
|
+
status: "complete" | "error" | "queued" | "rendering";
|
|
34
|
+
}>;
|
|
6
35
|
/**
|
|
7
36
|
* Get face detection details
|
|
8
37
|
*
|
|
@@ -26,3 +55,4 @@ export declare class FaceDetectionClient extends CoreResourceClient {
|
|
|
26
55
|
*/
|
|
27
56
|
create(request: requests.CreateRequest, opts?: RequestOptions): ApiPromise<types.V1FaceDetectionCreateResponse>;
|
|
28
57
|
}
|
|
58
|
+
export {};
|