@nsketch/cli 0.1.0 → 0.1.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.
- package/README.md +1 -1
- package/dist/index.js +13 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ nsketch generate video --prompt "the corgi rides a wave" --image ./corgi.png --w
|
|
|
31
31
|
|
|
32
32
|
# Voice, lipsync, motion transfer, upscaling
|
|
33
33
|
nsketch generate voice --script "Hello world"
|
|
34
|
-
nsketch generate lipsync --video ./clip.mp4 --audio ./voice.mp3
|
|
34
|
+
nsketch generate lipsync --video ./clip.mp4 --audio ./voice.mp3 --audio-duration 5
|
|
35
35
|
nsketch generate motion-transfer --image ./character.png --video ./dance.mp4 --wait
|
|
36
36
|
nsketch generate upscale --image ./photo.jpg --mode crystal
|
|
37
37
|
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import fs from "fs";
|
|
|
13
13
|
import os from "os";
|
|
14
14
|
import path from "path";
|
|
15
15
|
var DEFAULT_API_URL = "https://nsketch.ai";
|
|
16
|
+
var DEFAULT_CLIENT_ID = "gD7cfeHjNmpt6CPe";
|
|
16
17
|
var CONFIG_DIR = path.join(os.homedir(), ".config", "nsketch");
|
|
17
18
|
var CREDENTIALS_PATH = path.join(CONFIG_DIR, "credentials.json");
|
|
18
19
|
var CONFIG_PATH = path.join(CONFIG_DIR, "config.json");
|
|
@@ -50,7 +51,7 @@ function resolveApiUrl(flagValue) {
|
|
|
50
51
|
return (flagValue || process.env.NSKETCH_API_URL || loadConfig().apiUrl || DEFAULT_API_URL).replace(/\/$/, "");
|
|
51
52
|
}
|
|
52
53
|
function resolveClientId(flagValue) {
|
|
53
|
-
return flagValue || process.env.NSKETCH_OAUTH_CLIENT_ID || loadConfig().clientId ||
|
|
54
|
+
return flagValue || process.env.NSKETCH_OAUTH_CLIENT_ID || loadConfig().clientId || DEFAULT_CLIENT_ID;
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
// src/auth.ts
|
|
@@ -391,7 +392,7 @@ async function waitForCompletion(apiUrl2, target, opts) {
|
|
|
391
392
|
|
|
392
393
|
// src/index.ts
|
|
393
394
|
var program = new Command();
|
|
394
|
-
program.name("nsketch").description("Nsketch AI \u2014 generate images, videos, voice, and more from your terminal.").version("0.1.
|
|
395
|
+
program.name("nsketch").description("Nsketch AI \u2014 generate images, videos, voice, and more from your terminal.").version("0.1.1").option("--json", "machine-readable JSON output on stdout").option("--api-url <url>", "API base URL (default: https://nsketch.ai)").hook("preAction", (thisCommand) => {
|
|
395
396
|
setJsonMode(Boolean(thisCommand.opts().json));
|
|
396
397
|
});
|
|
397
398
|
var apiUrl = () => resolveApiUrl(program.opts().apiUrl);
|
|
@@ -583,22 +584,29 @@ addWaitOptions(
|
|
|
583
584
|
);
|
|
584
585
|
}
|
|
585
586
|
);
|
|
586
|
-
generate.command("lipsync").description("Lipsync a video (or animate a photo) to audio").requiredOption("--audio <pathOrUrl>").option("--video <pathOrUrl>", "video to lipsync").option("--image <pathOrUrl>", "photo to animate (talking photo)").option("--mode <mode>", "standard | pro").action(
|
|
587
|
+
generate.command("lipsync").description("Lipsync a video (or animate a photo) to audio").requiredOption("--audio <pathOrUrl>").requiredOption("--audio-duration <seconds>", "duration of the audio in seconds (determines credit cost)").option("--video <pathOrUrl>", "video to lipsync").option("--video-duration <seconds>", "duration of the input video in seconds").option("--image <pathOrUrl>", "photo to animate (talking photo)").option("--mode <mode>", "standard | pro").action(
|
|
587
588
|
async (opts) => {
|
|
588
589
|
if (!opts.video && !opts.image) fail("Provide --video or --image");
|
|
590
|
+
const audioDuration = Number(opts.audioDuration);
|
|
591
|
+
if (!Number.isFinite(audioDuration) || audioDuration <= 0) {
|
|
592
|
+
fail("--audio-duration must be a positive number of seconds");
|
|
593
|
+
}
|
|
589
594
|
const audioUrl = await resolveMedia(apiUrl(), opts.audio);
|
|
590
595
|
const result = opts.video ? await apiRequest(apiUrl(), "POST", "/api/video-lipsync", {
|
|
591
596
|
body: {
|
|
592
597
|
videoUrl: await resolveMedia(apiUrl(), opts.video),
|
|
593
598
|
audioUrl,
|
|
594
|
-
mode: opts.mode
|
|
599
|
+
mode: opts.mode,
|
|
600
|
+
audioDuration,
|
|
601
|
+
videoDuration: opts.videoDuration ? Number(opts.videoDuration) : void 0
|
|
595
602
|
}
|
|
596
603
|
}) : await apiRequest(apiUrl(), "POST", "/api/talking-photo", {
|
|
597
604
|
body: {
|
|
598
605
|
imageUrl: await resolveMedia(apiUrl(), opts.image),
|
|
599
606
|
audioUrl,
|
|
600
607
|
mode: opts.mode,
|
|
601
|
-
mediaType: "image"
|
|
608
|
+
mediaType: "image",
|
|
609
|
+
audioDuration
|
|
602
610
|
}
|
|
603
611
|
});
|
|
604
612
|
emit(result.json);
|
package/package.json
CHANGED