@nodaro/cli 1.1.2 → 1.4.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/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { stdout, stdin } from 'process';
5
5
  import pc3 from 'picocolors';
6
6
  import { writeFileSync, readFileSync, existsSync, mkdirSync, chmodSync } from 'fs';
7
7
  import { hostname, platform, homedir } from 'os';
8
- import { join } from 'path';
8
+ import { extname, basename, join } from 'path';
9
9
  import { createServer } from 'http';
10
10
  import { randomBytes } from 'crypto';
11
11
  import { spawn } from 'child_process';
@@ -17,7 +17,11 @@ import { CHARACTER_STYLES } from '@nodaro/shared';
17
17
 
18
18
  var __getOwnPropNames = Object.getOwnPropertyNames;
19
19
  var __commonJS = (cb, mod) => function __require() {
20
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
20
+ try {
21
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
22
+ } catch (e) {
23
+ throw mod = 0, e;
24
+ }
21
25
  };
22
26
 
23
27
  // package.json
@@ -25,7 +29,7 @@ var require_package = __commonJS({
25
29
  "package.json"(exports$1, module) {
26
30
  module.exports = {
27
31
  name: "@nodaro/cli",
28
- version: "1.1.2",
32
+ version: "1.4.0",
29
33
  description: "Command-line interface for Nodaro \u2014 list and run workflows, inspect jobs and executions, manage projects from the terminal.",
30
34
  type: "module",
31
35
  license: "Apache-2.0",
@@ -66,8 +70,8 @@ var require_package = __commonJS({
66
70
  "@inquirer/confirm": "^6.0.12",
67
71
  "@inquirer/input": "^5.0.12",
68
72
  "@inquirer/select": "^5.1.4",
69
- "@nodaro/sdk": "^1.1.1",
70
- "@nodaro/shared": "^1.4.1",
73
+ "@nodaro/sdk": "^1.6.0",
74
+ "@nodaro/shared": "^1.9.0",
71
75
  commander: "^12.1.0",
72
76
  picocolors: "^1.1.1",
73
77
  "@nodaro/prompts": "^1.0.1"
@@ -523,11 +527,28 @@ async function watchUntilTerminal(opts) {
523
527
  if (opts.json) emit(result.data, opts);
524
528
  else if (status === "completed") success(`completed in ${elapsed(start)}s`);
525
529
  else process.exit(status === "failed" ? 2 : 130);
526
- return;
530
+ return result;
527
531
  }
528
532
  await sleep(intervalMs);
529
533
  }
530
534
  }
535
+ async function reportQueuedJob(result, fetchJob, opts) {
536
+ if (opts.json && !opts.watch) {
537
+ emit(result, opts);
538
+ return void 0;
539
+ }
540
+ success(`job ${result.jobId} queued${opts.note ? ` (${opts.note})` : ""}`);
541
+ if (!opts.watch) {
542
+ dim(`follow: nodaro jobs get ${result.jobId}`);
543
+ return void 0;
544
+ }
545
+ return watchUntilTerminal({
546
+ fetch: fetchJob,
547
+ label: result.jobId,
548
+ intervalMs: opts.pollInterval,
549
+ json: opts.json
550
+ });
551
+ }
531
552
  function elapsed(startMs) {
532
553
  return ((Date.now() - startMs) / 1e3).toFixed(1);
533
554
  }
@@ -693,7 +714,7 @@ function workflowsCommand() {
693
714
  return cmd;
694
715
  }
695
716
  async function watchExecution(client, executionId, opts) {
696
- return watchUntilTerminal({
717
+ await watchUntilTerminal({
697
718
  fetch: () => client.executions.get(executionId),
698
719
  label: executionId,
699
720
  ...opts
@@ -1441,14 +1462,15 @@ function commonWizardFields(opts) {
1441
1462
  style: opts.style,
1442
1463
  aspectRatio: opts.aspectRatio,
1443
1464
  duration: opts.duration,
1444
- llmModel: opts.llmModel
1465
+ llmModel: opts.llmModel,
1466
+ reasoningEffort: opts.reasoningEffort
1445
1467
  };
1446
1468
  }
1447
1469
  function promptCommand() {
1448
1470
  const cmd = new Command("prompt").description(
1449
1471
  "AI prompt wizard \u2014 analyze, generate, and enhance prompts for generation nodes"
1450
1472
  );
1451
- cmd.command("wizard").description("interactive: answer guided questions and get an optimized prompt").option("--node-type <type>", "target node type (omit for an interactive picker)").option("--prompt <text>", "your rough idea (optional)").option("--provider <name>").option("--style <name>").option("--aspect-ratio <ratio>").option("--duration <seconds>", "clip duration in seconds", (v) => parseInt(v, 10)).option("--llm-model <id>").option("--profile <name>").action(async (opts) => {
1473
+ cmd.command("wizard").description("interactive: answer guided questions and get an optimized prompt").option("--node-type <type>", "target node type (omit for an interactive picker)").option("--prompt <text>", "your rough idea (optional)").option("--provider <name>").option("--style <name>").option("--aspect-ratio <ratio>").option("--duration <seconds>", "clip duration in seconds", (v) => parseInt(v, 10)).option("--llm-model <id>").option("--reasoning-effort <level>", "reasoning effort: none|low|medium|high|xhigh|max (model-dependent)").option("--profile <name>").action(async (opts) => {
1452
1474
  try {
1453
1475
  if (!isInteractive()) {
1454
1476
  warn("`prompt wizard` needs an interactive terminal \u2014 use `prompt analyze` + `prompt generate`, or `prompt enhance`, in scripts.");
@@ -1498,7 +1520,7 @@ function promptCommand() {
1498
1520
  handleError(err);
1499
1521
  }
1500
1522
  });
1501
- cmd.command("analyze").description("return guided questions for a rough prompt idea").requiredOption("--node-type <type>").option("--prompt <text>").option("--provider <name>").option("--style <name>").option("--aspect-ratio <ratio>").option("--duration <seconds>", "clip duration in seconds", (v) => parseInt(v, 10)).option("--llm-model <id>").option("--profile <name>").option("--json").action(async (opts) => {
1523
+ cmd.command("analyze").description("return guided questions for a rough prompt idea").requiredOption("--node-type <type>").option("--prompt <text>").option("--provider <name>").option("--style <name>").option("--aspect-ratio <ratio>").option("--duration <seconds>", "clip duration in seconds", (v) => parseInt(v, 10)).option("--llm-model <id>").option("--reasoning-effort <level>", "reasoning effort: none|low|medium|high|xhigh|max (model-dependent)").option("--profile <name>").option("--json").action(async (opts) => {
1502
1524
  try {
1503
1525
  const client = buildClient(opts.profile);
1504
1526
  const { jobId, questions } = await client.promptHelper.analyze({
@@ -1523,7 +1545,7 @@ function promptCommand() {
1523
1545
  handleError(err);
1524
1546
  }
1525
1547
  });
1526
- cmd.command("generate").description("build an optimized prompt from --selection category=value flags").requiredOption("--node-type <type>").option("--selection <pairs...>", "category=value (repeat); custom answers are wizard-only", collectVariadic).option("--original-prompt <text>").option("--provider <name>").option("--style <name>").option("--aspect-ratio <ratio>").option("--duration <seconds>", "clip duration in seconds", (v) => parseInt(v, 10)).option("--llm-model <id>").option("--profile <name>").option("--json").action(async (opts) => {
1548
+ cmd.command("generate").description("build an optimized prompt from --selection category=value flags").requiredOption("--node-type <type>").option("--selection <pairs...>", "category=value (repeat); custom answers are wizard-only", collectVariadic).option("--original-prompt <text>").option("--provider <name>").option("--style <name>").option("--aspect-ratio <ratio>").option("--duration <seconds>", "clip duration in seconds", (v) => parseInt(v, 10)).option("--llm-model <id>").option("--reasoning-effort <level>", "reasoning effort: none|low|medium|high|xhigh|max (model-dependent)").option("--profile <name>").option("--json").action(async (opts) => {
1527
1549
  try {
1528
1550
  const client = buildClient(opts.profile);
1529
1551
  const selections = parseSelectionPairs(opts.selection);
@@ -1543,7 +1565,7 @@ function promptCommand() {
1543
1565
  handleError(err);
1544
1566
  }
1545
1567
  });
1546
- cmd.command("enhance").description("rewrite a rough idea into one optimized prompt (no questions)").requiredOption("--node-type <type>").option("--prompt <text>").option("--provider <name>").option("--style <name>").option("--aspect-ratio <ratio>").option("--duration <seconds>", "clip duration in seconds", (v) => parseInt(v, 10)).option("--llm-model <id>").option("--profile <name>").option("--json").action(async (opts) => {
1568
+ cmd.command("enhance").description("rewrite a rough idea into one optimized prompt (no questions)").requiredOption("--node-type <type>").option("--prompt <text>").option("--provider <name>").option("--style <name>").option("--aspect-ratio <ratio>").option("--duration <seconds>", "clip duration in seconds", (v) => parseInt(v, 10)).option("--llm-model <id>").option("--reasoning-effort <level>", "reasoning effort: none|low|medium|high|xhigh|max (model-dependent)").option("--profile <name>").option("--json").action(async (opts) => {
1547
1569
  try {
1548
1570
  const client = buildClient(opts.profile);
1549
1571
  const result = await client.promptHelper.enhance({
@@ -1562,9 +1584,68 @@ function promptCommand() {
1562
1584
  });
1563
1585
  return cmd;
1564
1586
  }
1587
+ var FX_PRESETS = "room|bathroom|car|hall|concert-hall|church|cave|arena|outdoor|telephone|megaphone|echo|custom";
1588
+ var AUDIO_CONTENT_TYPES = {
1589
+ ".mp3": "audio/mpeg",
1590
+ ".wav": "audio/wav",
1591
+ ".m4a": "audio/mp4",
1592
+ ".aac": "audio/aac",
1593
+ ".ogg": "audio/ogg",
1594
+ ".flac": "audio/flac",
1595
+ ".webm": "audio/webm"
1596
+ };
1597
+ function buildVoiceFx(opts) {
1598
+ if ((opts.voiceFxMix !== void 0 || opts.voiceFxDelay !== void 0 || opts.voiceFxDecay !== void 0) && !opts.voiceFx) {
1599
+ warn("--voice-fx-mix / --voice-fx-delay / --voice-fx-decay require --voice-fx <preset>");
1600
+ process.exit(1);
1601
+ }
1602
+ return opts.voiceFx ? {
1603
+ preset: opts.voiceFx,
1604
+ ...opts.voiceFxMix !== void 0 ? { wetDryMix: opts.voiceFxMix } : {},
1605
+ ...opts.voiceFxDelay !== void 0 ? { delayMs: opts.voiceFxDelay } : {},
1606
+ ...opts.voiceFxDecay !== void 0 ? { decay: opts.voiceFxDecay } : {}
1607
+ } : void 0;
1608
+ }
1609
+ function readJsonFlag(inline, file, flagBase) {
1610
+ if (inline && file) {
1611
+ warn(`--${flagBase}-json and --${flagBase}-file are mutually exclusive \u2014 pass one`);
1612
+ process.exit(1);
1613
+ }
1614
+ const raw = file ? readFileSync(file, "utf8") : inline;
1615
+ if (raw === void 0) return void 0;
1616
+ try {
1617
+ return JSON.parse(raw);
1618
+ } catch {
1619
+ warn(`--${flagBase}-${file ? "file" : "json"} is not valid JSON`);
1620
+ process.exit(1);
1621
+ }
1622
+ }
1623
+ function renderAnalyzeOutput(outputData) {
1624
+ const out = outputData ?? {};
1625
+ if (out.suggestedTitle) info(`title: ${out.suggestedTitle}`);
1626
+ if (out.languageCode) {
1627
+ const p = out.languageProbability !== void 0 ? ` (confidence ${out.languageProbability.toFixed(2)})` : "";
1628
+ info(`language: ${out.languageCode}${p}`);
1629
+ }
1630
+ const speakers = Array.isArray(out.speakers) ? out.speakers : [];
1631
+ table(
1632
+ speakers.map((s, i) => ({
1633
+ "#": i + 1,
1634
+ id: s.id,
1635
+ "first heard": s.firstStartSec !== void 0 ? `${s.firstStartSec.toFixed(1)}s` : "",
1636
+ words: s.wordCount,
1637
+ snippet: s.snippet
1638
+ })),
1639
+ ["#", "id", "first heard", "words", "snippet"]
1640
+ );
1641
+ if (out.vocalsUrl) dim(`vocals stem: ${out.vocalsUrl}`);
1642
+ if (out.backgroundUrl) dim(`background stem: ${out.backgroundUrl}`);
1643
+ dim("next: nodaro voice recast --voices <v1,v2,...> maps entry N to speaker #N (`keep` keeps a speaker's original voice).");
1644
+ dim(" save this job's output_data as a JSON file and pass --analysis-file <path> to skip re-detection.");
1645
+ }
1565
1646
  function voiceCommand() {
1566
1647
  const cmd = new Command("voice").description("voice tools \u2014 revoice an audio track or a whole talking video");
1567
- cmd.command("changer").alias("change").description("replace the voice in an audio track (--audio) or a talking video (--video) with a different voice").requiredOption("--voice <id>", "target voice \u2014 premade name (Rachel, Aria, Roger, ...) or an ElevenLabs clone UUID").option("--audio <url>", "audio URL to revoice (audio \u2192 audio)").option("--video <url>", "video URL to revoice (returns the video + the new audio track). Wins over --audio when both are given.").option("--stability <n>", "voice stability 0..1", parseFloat).option("--similarity <n>", "similarity boost 0..1", parseFloat).option("--style <n>", "style exaggeration 0..1 \u2014 amplifies the source's delivery (default 0; higher adds latency / less stable)", parseFloat).option("--remove-background-noise", "clean, voice-only output; omit to keep the music/SFX bed under the new voice").option("--watch", "poll until the job completes").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--profile <name>").option("--json").addHelpText("after", `
1648
+ cmd.command("changer").alias("change").description("replace the voice in an audio track (--audio) or a talking video (--video) with a different voice").requiredOption("--voice <id>", "target voice \u2014 premade name (Rachel, Aria, Roger, ...) or an ElevenLabs clone UUID").option("--audio <url>", "audio URL to revoice (audio \u2192 audio)").option("--video <url>", "video URL to revoice (returns the video + the new audio track). Wins over --audio when both are given.").option("--model <id>", "speech-to-speech model override").option("--stability <n>", "voice stability 0..1", parseFloat).option("--similarity <n>", "similarity boost 0..1", parseFloat).option("--style <n>", "style exaggeration 0..1 \u2014 amplifies the source's delivery (default 0; higher adds latency / less stable)", parseFloat).option("--use-speaker-boost", "sharpen fidelity to the target speaker (small latency cost)").option("--seed <n>", "deterministic speech-to-speech seed for reproducible output (integer)", (v) => parseInt(v, 10)).option("--remove-background-noise", "clean, voice-only output; omit to keep the music/SFX bed under the new voice").option("--watch", "poll until the job completes").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--profile <name>").option("--json").addHelpText("after", `
1568
1649
  Examples:
1569
1650
  $ nodaro voice changer --audio https://.../speech.mp3 --voice Rachel --watch
1570
1651
  $ nodaro voice changer --video https://.../talking.mp4 --voice Aria --watch
@@ -1580,26 +1661,656 @@ Examples:
1580
1661
  voiceId: opts.voice,
1581
1662
  audioUrl: opts.audio,
1582
1663
  videoUrl: opts.video,
1664
+ model: opts.model,
1583
1665
  stability: opts.stability,
1584
1666
  similarityBoost: opts.similarity,
1585
1667
  style: opts.style,
1668
+ useSpeakerBoost: opts.useSpeakerBoost,
1669
+ seed: opts.seed,
1586
1670
  removeBackgroundNoise: opts.removeBackgroundNoise
1587
1671
  });
1588
- const jobId = result.jobId;
1672
+ await reportQueuedJob(result, () => client.jobs.get(result.jobId), {
1673
+ ...opts,
1674
+ note: `${opts.video ? "video" : "audio"} mode`
1675
+ });
1676
+ } catch (err) {
1677
+ handleError(err);
1678
+ }
1679
+ }
1680
+ );
1681
+ cmd.command("recast").alias("pro").description(
1682
+ "multi-speaker recast (Voice Changer Pro, Cloud only) \u2014 detects each speaker and recasts speaker N to the N-th entry of --voices; a `keep` entry keeps that speaker's original voice"
1683
+ ).option("--audio <url>", "audio URL to recast (audio \u2192 audio)").option("--video <url>", "video URL to recast (the audio track is recast and remuxed). Wins over --audio when both are given.").option(
1684
+ "--voices <list>",
1685
+ "comma-separated voices in speaker order \u2014 each entry is a premade name (Rachel), an ElevenLabs clone UUID, or the literal `keep` to keep that speaker's original voice"
1686
+ ).option(
1687
+ "--voices-json <json>",
1688
+ `JSON array for per-voice settings \u2014 entries are a voice id string, a {"voiceId","stability","similarityBoost","style","useSpeakerBoost","seed","volumeMode","volume"} object, or null to keep that speaker's original voice`
1689
+ ).option("--model <id>", "speech-to-speech model override").option("--output <mode>", "output mode: video (default \u2014 merged, rendered result) or stems (dry per-track stems for an interactive mix; render later with `voice export`)").option("--analysis-json <json>", "a completed `voice analyze` job's output_data, inline \u2014 skips re-detection (the interactive-flow fast-path)").option("--analysis-file <path>", "same as --analysis-json but read from a JSON file").option("--no-preserve-background", "drop the separated music/SFX bed for a clean voice-only result (kept by default)").option("--separation-quality <q>", "voice/music separation quality: fast (default) or best").option("--music-volume-mode <mode>", "preserved background level: match (default), normalize, or manual").option("--music-volume <n>", "background level % (0-200) when --music-volume-mode is manual", parseFloat).option("--remove-background-noise", "denoise for a cleaner voice-only result").option("--voice-fx <preset>", `reverb/echo on the combined recast voices: ${FX_PRESETS}`).option("--voice-fx-mix <n>", "reverb wet/dry mix % (0-100) \u2014 reverb presets", parseFloat).option("--voice-fx-delay <ms>", "echo delay in ms (20-2000) \u2014 echo/custom presets", (v) => parseInt(v, 10)).option("--voice-fx-decay <n>", "echo decay (0-1) \u2014 echo/custom presets", parseFloat).option("--watch", "poll until the job completes").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--profile <name>").option("--json").addHelpText("after", `
1690
+ Examples:
1691
+ $ nodaro voice recast --audio https://.../podcast.mp3 --voices Rachel,Aria --watch
1692
+ $ nodaro voice recast --video https://.../panel.mp4 --voices Rachel,keep,Aria --watch
1693
+ # speaker 1 \u2192 Rachel, speaker 2 keeps their original voice, speaker 3 \u2192 Aria
1694
+ $ nodaro voice recast --audio https://.../ad.mp3 \\
1695
+ --voices-json '[{"voiceId":"Rachel","stability":0.6},null,"Aria"]' --no-preserve-background
1696
+ $ nodaro voice recast --video https://.../panel.mp4 --voices Rachel,Aria \\
1697
+ --analysis-file analysis.json --output stems --watch
1698
+ # interactive flow: reuse a \`voice analyze\` result, get dry stems to mix, render with \`voice export\``).action(
1699
+ async (opts) => {
1700
+ try {
1701
+ if (!opts.audio && !opts.video) {
1702
+ warn("Provide --audio <url> or --video <url> (one is required)");
1703
+ process.exit(1);
1704
+ }
1705
+ if (opts.voices && opts.voicesJson) {
1706
+ warn("--voices and --voices-json are mutually exclusive \u2014 pass one");
1707
+ process.exit(1);
1708
+ }
1709
+ if (!opts.voices && !opts.voicesJson) {
1710
+ warn("Provide --voices <v1,v2,...> (use `keep` to keep a speaker's original voice) or --voices-json <json>");
1711
+ process.exit(1);
1712
+ }
1713
+ if (opts.output && opts.output !== "video" && opts.output !== "stems") {
1714
+ warn(`--output must be "video" or "stems" (got "${opts.output}")`);
1715
+ process.exit(1);
1716
+ }
1717
+ let orderedVoices;
1718
+ if (opts.voices) {
1719
+ const entries = opts.voices.split(",").map((s) => s.trim());
1720
+ if (entries.some((e) => e === "")) {
1721
+ warn(`--voices has an empty entry: ${JSON.stringify(opts.voices)}`);
1722
+ process.exit(1);
1723
+ }
1724
+ orderedVoices = entries.map((e) => e.toLowerCase() === "keep" ? null : e);
1725
+ } else {
1726
+ let parsed;
1727
+ try {
1728
+ parsed = JSON.parse(opts.voicesJson);
1729
+ } catch {
1730
+ warn("--voices-json is not valid JSON");
1731
+ process.exit(1);
1732
+ }
1733
+ if (!Array.isArray(parsed) || parsed.length === 0 || !parsed.every((v) => v === null || typeof v === "string" || typeof v === "object" && !Array.isArray(v))) {
1734
+ warn("--voices-json must be a non-empty JSON array of voice id strings, per-voice settings objects, or null keep-slots");
1735
+ process.exit(1);
1736
+ }
1737
+ orderedVoices = parsed;
1738
+ }
1739
+ if (!orderedVoices.some((v) => v !== null)) {
1740
+ warn("At least one speaker must get a new voice \u2014 `keep` only marks speakers whose original voice stays");
1741
+ process.exit(1);
1742
+ }
1743
+ const voiceFx = buildVoiceFx(opts);
1744
+ const analysisRaw = readJsonFlag(opts.analysisJson, opts.analysisFile, "analysis");
1745
+ let analysis;
1746
+ if (analysisRaw !== void 0) {
1747
+ const a = analysisRaw;
1748
+ if (!a || typeof a !== "object" || Array.isArray(a) || typeof a.vocalsUrl !== "string" || !Array.isArray(a.speakers)) {
1749
+ warn("--analysis-json/--analysis-file must be an analyze result object (vocalsUrl + speakers[]) \u2014 pass a completed `voice analyze` job's output_data");
1750
+ process.exit(1);
1751
+ }
1752
+ analysis = {
1753
+ vocalsUrl: a.vocalsUrl,
1754
+ ...a.backgroundUrl !== void 0 ? { backgroundUrl: a.backgroundUrl } : {},
1755
+ speakers: a.speakers,
1756
+ ...a.languageCode !== void 0 ? { languageCode: a.languageCode } : {},
1757
+ ...a.languageProbability !== void 0 ? { languageProbability: a.languageProbability } : {}
1758
+ };
1759
+ }
1760
+ const client = buildClient(opts.profile);
1761
+ const input2 = {
1762
+ orderedVoices,
1763
+ // Video wins when both are given (matches the route + `voice changer`).
1764
+ ...opts.video ? { videoUrl: opts.video } : { audioUrl: opts.audio },
1765
+ ...opts.model ? { model: opts.model } : {},
1766
+ ...opts.output ? { output: opts.output } : {},
1767
+ ...analysis ? { analysis } : {},
1768
+ // Only sent when --no-preserve-background was used; otherwise omitted
1769
+ // so the server default (true) applies.
1770
+ ...opts.preserveBackground === false ? { preserveBackground: false } : {},
1771
+ ...opts.separationQuality ? { separationQuality: opts.separationQuality } : {},
1772
+ ...opts.musicVolumeMode ? { musicVolumeMode: opts.musicVolumeMode } : {},
1773
+ ...opts.musicVolume !== void 0 ? { musicVolume: opts.musicVolume } : {},
1774
+ ...opts.removeBackgroundNoise ? { removeBackgroundNoise: true } : {},
1775
+ ...voiceFx ? { voiceFx } : {}
1776
+ };
1777
+ const result = await client.voices.recast(input2);
1778
+ await reportQueuedJob(result, () => client.jobs.get(result.jobId), {
1779
+ ...opts,
1780
+ note: `${opts.video ? "video" : "audio"} mode${opts.output === "stems" ? ", stems output" : ""}`
1781
+ });
1782
+ } catch (err) {
1783
+ handleError(err);
1784
+ }
1785
+ }
1786
+ );
1787
+ cmd.command("analyze").description(
1788
+ "detect the speakers in a clip WITHOUT recasting (Voice Changer Pro, Cloud only) \u2014 the first step of the interactive flow: pick voices against the printed speaker list, then `voice recast`"
1789
+ ).option("--audio <url>", "audio URL to analyze").option("--video <url>", "video URL to analyze (its audio track is used). Wins over --audio when both are given.").option("--separation-quality <q>", "voice/music separation quality: fast (default) or best").option("--suggest-title", "also suggest a title for the clip from its transcript").option("--watch", "poll until the job completes, then print the detected speakers").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--profile <name>").option("--json").addHelpText("after", `
1790
+ Examples:
1791
+ $ nodaro voice analyze --video https://.../panel.mp4 --watch
1792
+ $ nodaro voice analyze --audio https://.../podcast.mp3 --separation-quality best --suggest-title --watch
1793
+
1794
+ The completed job's output_data carries the separated stems + the speaker list;
1795
+ save it to a file and pass it to \`voice recast --analysis-file\` to skip re-detection.`).action(
1796
+ async (opts) => {
1797
+ try {
1798
+ if (!opts.audio && !opts.video) {
1799
+ warn("Provide --audio <url> or --video <url> (one is required)");
1800
+ process.exit(1);
1801
+ }
1802
+ const client = buildClient(opts.profile);
1803
+ const result = await client.voices.analyze({
1804
+ // Video wins when both are given (matches `voice recast`).
1805
+ ...opts.video ? { videoUrl: opts.video } : { audioUrl: opts.audio },
1806
+ ...opts.separationQuality ? { separationQuality: opts.separationQuality } : {},
1807
+ ...opts.suggestTitle ? { suggestTitle: true } : {}
1808
+ });
1809
+ const terminal = await reportQueuedJob(result, () => client.jobs.get(result.jobId), {
1810
+ ...opts,
1811
+ note: "speaker detection"
1812
+ });
1813
+ if (terminal && !opts.json && terminal.data.status === "completed") {
1814
+ renderAnalyzeOutput(terminal.data.output_data);
1815
+ }
1816
+ } catch (err) {
1817
+ handleError(err);
1818
+ }
1819
+ }
1820
+ );
1821
+ cmd.command("export").description(
1822
+ "render the final video from a mixed set of stems (Voice Changer Pro, Cloud only) \u2014 the last step of the interactive flow, after `voice recast --output stems`"
1823
+ ).requiredOption("--source <url>", "the source video to remux the mixed audio onto (stream-copied, never re-encoded)").option("--tracks-json <json>", 'the mix, inline \u2014 a JSON array of { "url", "gain" (0-200), "muted", "kind"? ("voice"|"background") } lanes (max 16)').option("--tracks-file <path>", "same as --tracks-json but read from a JSON file").option("--voice-fx <preset>", `reverb/echo on the voice lanes at render time: ${FX_PRESETS}`).option("--voice-fx-mix <n>", "reverb wet/dry mix % (0-100) \u2014 reverb presets", parseFloat).option("--voice-fx-delay <ms>", "echo delay in ms (20-2000) \u2014 echo/custom presets", (v) => parseInt(v, 10)).option("--voice-fx-decay <n>", "echo decay (0-1) \u2014 echo/custom presets", parseFloat).option("--watch", "poll until the job completes").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--profile <name>").option("--json").addHelpText("after", `
1824
+ Examples:
1825
+ $ nodaro voice export --source https://.../panel.mp4 --tracks-file mix.json --watch
1826
+ $ nodaro voice export --source https://.../panel.mp4 --voice-fx hall --voice-fx-mix 30 \\
1827
+ --tracks-json '[{"url":"https://.../s0.mp3","gain":100,"muted":false},
1828
+ {"url":"https://.../bg.mp3","gain":80,"muted":false,"kind":"background"}]'
1829
+
1830
+ Track urls come from a \`voice recast --output stems\` job's output_data. --voice-fx
1831
+ lands on the voice lanes only (never a "background" lane).`).action(
1832
+ async (opts) => {
1833
+ try {
1834
+ const parsed = readJsonFlag(opts.tracksJson, opts.tracksFile, "tracks");
1835
+ if (parsed === void 0) {
1836
+ warn("Provide --tracks-json <json> or --tracks-file <path> \u2014 the mix's track list");
1837
+ process.exit(1);
1838
+ }
1839
+ if (!Array.isArray(parsed) || parsed.length === 0 || !parsed.every((t) => t !== null && typeof t === "object" && !Array.isArray(t) && typeof t.url === "string")) {
1840
+ warn('tracks must be a non-empty JSON array of { "url", "gain", "muted", "kind"? } objects');
1841
+ process.exit(1);
1842
+ }
1843
+ const tracks = parsed;
1844
+ if (tracks.every((t) => t.muted === true)) {
1845
+ warn("At least one track must be un-muted \u2014 an all-muted mix renders silence and the server rejects it");
1846
+ process.exit(1);
1847
+ }
1848
+ const voiceFx = buildVoiceFx(opts);
1849
+ const client = buildClient(opts.profile);
1850
+ const input2 = {
1851
+ videoUrl: opts.source,
1852
+ tracks,
1853
+ ...voiceFx ? { voiceFx } : {}
1854
+ };
1855
+ const result = await client.voices.exportMix(input2);
1856
+ await reportQueuedJob(result, () => client.jobs.get(result.jobId), {
1857
+ ...opts,
1858
+ note: `${tracks.length} track${tracks.length === 1 ? "" : "s"}`
1859
+ });
1860
+ } catch (err) {
1861
+ handleError(err);
1862
+ }
1863
+ }
1864
+ );
1865
+ cmd.command("design").description("design a brand-new synthetic voice from a text description (ElevenLabs text-to-voice)").requiredOption("--text <line>", "a preview line (100-1000 chars) spoken in the designed voice").requiredOption("--description <desc>", "natural-language description of the voice to create").option("--model <id>", "voice-design model override").option("--loudness <n>", "output loudness (-1..1)", parseFloat).option("--guidance-scale <n>", "how strongly the description steers the design (0-100)", parseFloat).option("--seed <n>", "deterministic seed for a reproducible design (integer)", (v) => parseInt(v, 10)).option("--quality <n>", "design quality knob (provider-specific)", parseFloat).option("--enhance", "enhance the generated voice").option("--user-prompt <text>", "optional extra prompt context").option("--watch", "poll until the job completes").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--profile <name>").option("--json").addHelpText("after", `
1866
+ Example:
1867
+ $ nodaro voice design --description "a warm, gravelly narrator in his 60s" \\
1868
+ --text "Some stories don't begin at the beginning; they begin the moment everything changes, and this one is no different." --watch`).action(
1869
+ async (opts) => {
1870
+ try {
1871
+ const client = buildClient(opts.profile);
1872
+ const result = await client.voices.design({
1873
+ text: opts.text,
1874
+ voiceDescription: opts.description,
1875
+ ...opts.model ? { model: opts.model } : {},
1876
+ ...opts.loudness !== void 0 ? { loudness: opts.loudness } : {},
1877
+ ...opts.guidanceScale !== void 0 ? { guidanceScale: opts.guidanceScale } : {},
1878
+ ...opts.seed !== void 0 ? { seed: opts.seed } : {},
1879
+ ...opts.quality !== void 0 ? { quality: opts.quality } : {},
1880
+ ...opts.enhance ? { shouldEnhance: true } : {},
1881
+ ...opts.userPrompt ? { userPrompt: opts.userPrompt } : {}
1882
+ });
1883
+ await reportQueuedJob(result, () => client.jobs.get(result.jobId), { ...opts, note: "voice design" });
1884
+ } catch (err) {
1885
+ handleError(err);
1886
+ }
1887
+ }
1888
+ );
1889
+ cmd.command("remix").description("speak a text in a voice described in natural language, without cloning (ElevenLabs voice remix)").requiredOption("--text <text>", "the text (1-5000 chars) to speak").requiredOption("--description <desc>", "natural-language description of the voice to speak in").option("--user-prompt <text>", "optional extra prompt context").option("--watch", "poll until the job completes").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--profile <name>").option("--json").action(
1890
+ async (opts) => {
1891
+ try {
1892
+ const client = buildClient(opts.profile);
1893
+ const result = await client.voices.remix({
1894
+ text: opts.text,
1895
+ voiceDescription: opts.description,
1896
+ ...opts.userPrompt ? { userPrompt: opts.userPrompt } : {}
1897
+ });
1898
+ await reportQueuedJob(result, () => client.jobs.get(result.jobId), { ...opts, note: "voice remix" });
1899
+ } catch (err) {
1900
+ handleError(err);
1901
+ }
1902
+ }
1903
+ );
1904
+ cmd.command("dub").description("dub an audio clip into another language while preserving each speaker's voice").requiredOption("--audio <url>", "audio URL to dub").requiredOption("--target-language <code>", 'target language ISO code, e.g. "es", "fr", "pt-BR"').option("--source-language <code>", "source language ISO code (auto-detected when omitted)").option("--num-speakers <n>", "expected number of speakers (1-20) \u2014 improves separation when known", (v) => parseInt(v, 10)).option("--disable-voice-cloning", "keep the original voices instead of cloning them into the target language").option("--drop-background-audio", "drop the background/music bed from the dubbed output").option("--watch", "poll until the job completes").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--profile <name>").option("--json").addHelpText("after", `
1905
+ Example:
1906
+ $ nodaro voice dub --audio https://.../interview.mp3 --target-language es --num-speakers 2 --watch`).action(
1907
+ async (opts) => {
1908
+ try {
1909
+ const client = buildClient(opts.profile);
1910
+ const result = await client.voices.dub({
1911
+ audioUrl: opts.audio,
1912
+ targetLanguage: opts.targetLanguage,
1913
+ ...opts.sourceLanguage ? { sourceLanguage: opts.sourceLanguage } : {},
1914
+ ...opts.numSpeakers !== void 0 ? { numSpeakers: opts.numSpeakers } : {},
1915
+ ...opts.disableVoiceCloning ? { disableVoiceCloning: true } : {},
1916
+ ...opts.dropBackgroundAudio ? { dropBackgroundAudio: true } : {}
1917
+ });
1918
+ await reportQueuedJob(result, () => client.jobs.get(result.jobId), {
1919
+ ...opts,
1920
+ note: `dub \u2192 ${opts.targetLanguage}`
1921
+ });
1922
+ } catch (err) {
1923
+ handleError(err);
1924
+ }
1925
+ }
1926
+ );
1927
+ cmd.command("list").description("list the premade voices you can pass to --voice / --voices (or your voice clones with --clones)").option("--clones", "list your voice clones instead of the premade catalog").option("--profile <name>").option("--json").action(async (opts) => {
1928
+ try {
1929
+ const client = buildClient(opts.profile);
1930
+ if (opts.clones) {
1931
+ const clones2 = await client.voices.listClones();
1932
+ if (opts.json) {
1933
+ emit(clones2, opts);
1934
+ return;
1935
+ }
1936
+ table(
1937
+ clones2.map((c) => ({ name: c.name, voice_id: c.elevenlabsVoiceId, clone_id: c.id, created: c.createdAt })),
1938
+ ["name", "voice_id", "clone_id", "created"]
1939
+ );
1940
+ dim(`${clones2.length} clone${clones2.length === 1 ? "" : "s"} \u2014 pass voice_id to --voice / --voices`);
1941
+ return;
1942
+ }
1943
+ const voices = await client.voices.list();
1944
+ if (opts.json) {
1945
+ emit(voices, opts);
1946
+ return;
1947
+ }
1948
+ table(
1949
+ voices.map((v) => ({ name: v.name, voice_id: v.voice_id, gender: v.gender, accent: v.accent, age: v.age, category: v.category })),
1950
+ ["name", "voice_id", "gender", "accent", "age", "category"]
1951
+ );
1952
+ dim(`${voices.length} premade voice${voices.length === 1 ? "" : "s"} \u2014 pass a name or voice_id to --voice / --voices`);
1953
+ } catch (err) {
1954
+ handleError(err);
1955
+ }
1956
+ });
1957
+ const clones = new Command("clones").description("manage your voice clones (list / create / delete)");
1958
+ clones.command("list").description("list your voice clones").option("--profile <name>").option("--json").action(async (opts) => {
1959
+ try {
1960
+ const client = buildClient(opts.profile);
1961
+ const rows = await client.voices.listClones();
1962
+ if (opts.json) {
1963
+ emit(rows, opts);
1964
+ return;
1965
+ }
1966
+ table(
1967
+ rows.map((c) => ({ name: c.name, voice_id: c.elevenlabsVoiceId, clone_id: c.id, created: c.createdAt })),
1968
+ ["name", "voice_id", "clone_id", "created"]
1969
+ );
1970
+ dim(`${rows.length} clone${rows.length === 1 ? "" : "s"} \u2014 pass voice_id to --voice / --voices`);
1971
+ } catch (err) {
1972
+ handleError(err);
1973
+ }
1974
+ });
1975
+ clones.command("create").description("clone a voice from a sample \u2014 an already-uploaded URL (--audio) or a local file (--file). Costs credits.").requiredOption("--name <name>", "name for the new clone").option("--audio <url>", "URL of an uploaded audio sample to clone from").option("--file <path>", "local audio file to upload and clone from (mp3/wav/m4a/aac/ogg/flac/webm)").option("--profile <name>").option("--json").addHelpText("after", `
1976
+ Examples:
1977
+ $ nodaro voice clones create --name "Narrator" --audio https://.../sample.mp3
1978
+ $ nodaro voice clones create --name "Narrator" --file ./sample.wav`).action(async (opts) => {
1979
+ try {
1980
+ if (!opts.audio && !opts.file) {
1981
+ warn("Provide --audio <url> or --file <path> (one is required)");
1982
+ process.exit(1);
1983
+ }
1984
+ if (opts.audio && opts.file) {
1985
+ warn("--audio and --file are mutually exclusive \u2014 pass one");
1986
+ process.exit(1);
1987
+ }
1988
+ const client = buildClient(opts.profile);
1989
+ const clone = opts.file ? await client.voices.createCloneFromFile({
1990
+ name: opts.name,
1991
+ file: readFileSync(opts.file),
1992
+ filename: basename(opts.file),
1993
+ contentType: AUDIO_CONTENT_TYPES[extname(opts.file).toLowerCase()] ?? "audio/mpeg"
1994
+ }) : await client.voices.createClone({ name: opts.name, audioUrl: opts.audio });
1995
+ if (opts.json) {
1996
+ emit(clone, opts);
1997
+ return;
1998
+ }
1999
+ success(`created voice clone "${clone.name}"`);
2000
+ info(`voice_id: ${clone.elevenlabsVoiceId}`);
2001
+ dim(`use it: nodaro voice changer --voice ${clone.elevenlabsVoiceId} --audio <url>`);
2002
+ } catch (err) {
2003
+ handleError(err);
2004
+ }
2005
+ });
2006
+ clones.command("delete <id>").description("delete one of your voice clones (the clone row id, not the voice_id)").option("--profile <name>").option("--json").action(async (id, opts) => {
2007
+ try {
2008
+ const client = buildClient(opts.profile);
2009
+ await client.voices.deleteClone(id);
2010
+ if (opts.json) emit({ id, deleted: true }, opts);
2011
+ else success(`deleted voice clone ${id}`);
2012
+ } catch (err) {
2013
+ handleError(err);
2014
+ }
2015
+ });
2016
+ cmd.addCommand(clones);
2017
+ return cmd;
2018
+ }
2019
+ function parseSection(raw) {
2020
+ const m = raw.match(/^([0-9]+(?:\.[0-9]+)?)-([0-9]+(?:\.[0-9]+)?)$/);
2021
+ const start = m ? parseFloat(m[1]) : NaN;
2022
+ const end = m ? parseFloat(m[2]) : NaN;
2023
+ if (!m || !(start < end)) {
2024
+ warn(`--section must be "<start>-<end>" in seconds with start < end (got "${raw}")`);
2025
+ process.exit(1);
2026
+ }
2027
+ return { sectionStartSec: start, sectionEndSec: end };
2028
+ }
2029
+ function mediaCommand() {
2030
+ const cmd = new Command("media").description(
2031
+ "media ingestion \u2014 pull a social video into storage, trim video/audio, save a URL to storage, probe metadata"
2032
+ );
2033
+ cmd.command("download <url>").description("download a social video (YouTube / TikTok / Instagram / X / Facebook) into your storage").option("--max-height <px>", "cap the resolution (e.g. 720); omit for best available", (v) => parseInt(v, 10)).option("--section <a-b>", 'fetch ONLY this time range in seconds (e.g. "30-90"); the cut lands on keyframes, so pad and trim after').option("--watch", "stream the download's live progress until it completes").option("--profile <name>").option("--json").addHelpText("after", `
2034
+ Examples:
2035
+ $ nodaro media download https://youtu.be/dQw4w9WgXcQ --max-height 720 --watch
2036
+ $ nodaro media download https://youtu.be/dQw4w9WgXcQ --section 30-90 --watch
2037
+
2038
+ The finished file lands in your library. Without --watch, the progress state
2039
+ expires shortly after completion \u2014 there is no job to poll later.`).action(
2040
+ async (url, opts) => {
2041
+ try {
2042
+ const section = opts.section !== void 0 ? parseSection(opts.section) : void 0;
2043
+ const client = buildClient(opts.profile);
2044
+ const result = await client.media.downloadVideo({
2045
+ url,
2046
+ ...opts.maxHeight !== void 0 ? { maxHeight: opts.maxHeight } : {},
2047
+ ...section ?? {}
2048
+ });
1589
2049
  if (opts.json && !opts.watch) {
1590
2050
  emit(result, opts);
1591
2051
  return;
1592
2052
  }
1593
- success(`job ${jobId} queued (${opts.video ? "video" : "audio"} mode)`);
2053
+ success(`download ${result.downloadId} started`);
1594
2054
  if (!opts.watch) {
1595
- dim(`follow: nodaro jobs get ${jobId}`);
2055
+ dim("re-run with --watch to stream progress (the progress state expires \u2014 start watching promptly)");
1596
2056
  return;
1597
2057
  }
1598
- await watchUntilTerminal({
1599
- fetch: () => client.jobs.get(jobId),
1600
- label: jobId,
1601
- intervalMs: opts.pollInterval,
1602
- ...opts
2058
+ const start = Date.now();
2059
+ let lastPhase = "";
2060
+ let lastLoggedPercent = -1;
2061
+ let terminal;
2062
+ for await (const ev of client.media.downloadVideoProgress(result.downloadId)) {
2063
+ terminal = ev;
2064
+ if (opts.json) continue;
2065
+ const secs = ((Date.now() - start) / 1e3).toFixed(1);
2066
+ if (ev.phase !== lastPhase) {
2067
+ info(`[${secs}s] ${result.downloadId} \u2192 ${ev.phase}`);
2068
+ lastPhase = ev.phase;
2069
+ lastLoggedPercent = -1;
2070
+ }
2071
+ if (ev.phase === "downloading" && ev.percent - lastLoggedPercent >= 25) {
2072
+ info(`[${secs}s] ${Math.floor(ev.percent)}%`);
2073
+ lastLoggedPercent = ev.percent;
2074
+ }
2075
+ }
2076
+ if (opts.json) {
2077
+ emit(terminal ?? { phase: "failed", percent: 0, error: "progress stream ended without a terminal event" }, opts);
2078
+ if (terminal?.phase !== "completed") process.exit(2);
2079
+ return;
2080
+ }
2081
+ if (terminal?.phase === "completed") {
2082
+ success(`downloaded in ${((Date.now() - start) / 1e3).toFixed(1)}s`);
2083
+ if (terminal.videoUrl) info(`video: ${terminal.videoUrl}`);
2084
+ if (terminal.thumbnailUrl) dim(`thumbnail: ${terminal.thumbnailUrl}`);
2085
+ } else {
2086
+ warn(`download failed: ${terminal?.error ?? "progress stream ended unexpectedly"}`);
2087
+ process.exit(2);
2088
+ }
2089
+ } catch (err) {
2090
+ handleError(err);
2091
+ }
2092
+ }
2093
+ );
2094
+ cmd.command("metadata <url>").description("probe a social video's metadata (duration, dimensions, title, live status) WITHOUT downloading it").option("--profile <name>").option("--json").action(async (url, opts) => {
2095
+ try {
2096
+ const client = buildClient(opts.profile);
2097
+ const meta = await client.media.videoMetadata({ url });
2098
+ if (opts.json) emit(meta, opts);
2099
+ else detail(meta);
2100
+ } catch (err) {
2101
+ handleError(err);
2102
+ }
2103
+ });
2104
+ cmd.command("trim-video").description("trim a video to a range").requiredOption("--video <url>", "video URL to trim").option("--start <sec>", "range start in seconds", parseFloat).option("--end <sec>", "range end in seconds", parseFloat).option("--keep-first <sec>", "keep only the first N seconds", parseFloat).option("--keep-last <sec>", "keep only the last N seconds", parseFloat).option("--watch", "poll until the job completes").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--profile <name>").option("--json").addHelpText("after", `
2105
+ Examples:
2106
+ $ nodaro media trim-video --video https://.../clip.mp4 --start 12 --end 48 --watch
2107
+ $ nodaro media trim-video --video https://.../clip.mp4 --keep-first 60 --watch`).action(
2108
+ async (opts) => {
2109
+ try {
2110
+ if (opts.start === void 0 && opts.end === void 0 && opts.keepFirst === void 0 && opts.keepLast === void 0) {
2111
+ warn("Provide a range: --start/--end, --keep-first, or --keep-last");
2112
+ process.exit(1);
2113
+ }
2114
+ const client = buildClient(opts.profile);
2115
+ const result = await client.media.trimVideo({
2116
+ videoUrl: opts.video,
2117
+ ...opts.start !== void 0 ? { startTime: opts.start } : {},
2118
+ ...opts.end !== void 0 ? { endTime: opts.end } : {},
2119
+ ...opts.keepFirst !== void 0 ? { keepFirstSeconds: opts.keepFirst } : {},
2120
+ ...opts.keepLast !== void 0 ? { keepLastSeconds: opts.keepLast } : {}
2121
+ });
2122
+ await reportQueuedJob(result, () => client.jobs.get(result.jobId), { ...opts, note: "trim video" });
2123
+ } catch (err) {
2124
+ handleError(err);
2125
+ }
2126
+ }
2127
+ );
2128
+ cmd.command("trim-audio").description("trim (and extract) audio from a video or audio source").option("--video <url>", "video URL to extract + trim audio from").option("--audio <url>", "audio URL to trim").option("--start <sec>", "range start in seconds", parseFloat).option("--end <sec>", "range end in seconds", parseFloat).option("--format <fmt>", "output format: mp3 (default), wav, or aac").option("--watch", "poll until the job completes").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--profile <name>").option("--json").addHelpText("after", `
2129
+ Example:
2130
+ $ nodaro media trim-audio --video https://.../clip.mp4 --start 0 --end 30 --format wav --watch`).action(
2131
+ async (opts) => {
2132
+ try {
2133
+ if (!opts.video && !opts.audio) {
2134
+ warn("Provide --video <url> or --audio <url> (one is required)");
2135
+ process.exit(1);
2136
+ }
2137
+ if (opts.format && !["mp3", "wav", "aac"].includes(opts.format)) {
2138
+ warn(`--format must be mp3, wav, or aac (got "${opts.format}")`);
2139
+ process.exit(1);
2140
+ }
2141
+ const client = buildClient(opts.profile);
2142
+ const result = await client.media.trimAudio({
2143
+ ...opts.video ? { videoUrl: opts.video } : {},
2144
+ ...opts.audio ? { audioUrl: opts.audio } : {},
2145
+ ...opts.start !== void 0 ? { startTime: opts.start } : {},
2146
+ ...opts.end !== void 0 ? { endTime: opts.end } : {},
2147
+ ...opts.format ? { audioFormat: opts.format } : {}
2148
+ });
2149
+ await reportQueuedJob(result, () => client.jobs.get(result.jobId), { ...opts, note: "trim audio" });
2150
+ } catch (err) {
2151
+ handleError(err);
2152
+ }
2153
+ }
2154
+ );
2155
+ cmd.command("save <url>").description("copy an external media URL into your Nodaro storage (server-side fetch)").option("--filename <name>", "filename to store it under").option("--type <type>", "media type hint: image, video, or audio").option("--watch", "poll until the job completes").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--profile <name>").option("--json").action(
2156
+ async (url, opts) => {
2157
+ try {
2158
+ if (opts.type && !["image", "video", "audio"].includes(opts.type)) {
2159
+ warn(`--type must be image, video, or audio (got "${opts.type}")`);
2160
+ process.exit(1);
2161
+ }
2162
+ const client = buildClient(opts.profile);
2163
+ const result = await client.media.saveToStorage({
2164
+ mediaUrl: url,
2165
+ ...opts.filename ? { filename: opts.filename } : {},
2166
+ ...opts.type ? { mediaType: opts.type } : {}
2167
+ });
2168
+ await reportQueuedJob(result, () => client.jobs.get(result.jobId), { ...opts, note: "save to storage" });
2169
+ } catch (err) {
2170
+ handleError(err);
2171
+ }
2172
+ }
2173
+ );
2174
+ return cmd;
2175
+ }
2176
+ var FX_PRESETS2 = "room|bathroom|car|hall|concert-hall|church|cave|arena|outdoor|telephone|megaphone|echo|custom";
2177
+ function parseSegment(raw) {
2178
+ const at = raw.lastIndexOf("@");
2179
+ if (at < 0) return { url: raw };
2180
+ const range = raw.slice(at + 1);
2181
+ const m = range.match(/^([0-9]+(?:\.[0-9]+)?)-([0-9]+(?:\.[0-9]+)?)$/);
2182
+ const start = m ? parseFloat(m[1]) : NaN;
2183
+ const end = m ? parseFloat(m[2]) : NaN;
2184
+ if (!m || !(start < end)) {
2185
+ warn(`--segment range must be "url@<start>-<end>" in seconds with start < end (got "${raw}")`);
2186
+ process.exit(1);
2187
+ }
2188
+ return { url: raw.slice(0, at), startTime: start, endTime: end };
2189
+ }
2190
+ function audioCommand() {
2191
+ const cmd = new Command("audio").description(
2192
+ "audio primitives \u2014 the building blocks Voice Changer Pro composes: separate, isolate, fx, mix, level, combine"
2193
+ );
2194
+ cmd.command("separate").description("separate an audio track into stems (Demucs) \u2014 voice vs music/SFX, or the full stem breakdown").requiredOption("--audio <url>", "audio URL to separate").option("--mode <mode>", "vocal_instrumental (default) or stems (drums/bass/other/\u2026)").option("--quality <q>", "separation quality: auto (default), fast, or best").option("--watch", "poll until the job completes").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--profile <name>").option("--json").action(
2195
+ async (opts) => {
2196
+ try {
2197
+ if (opts.mode && !["vocal_instrumental", "stems"].includes(opts.mode)) {
2198
+ warn(`--mode must be vocal_instrumental or stems (got "${opts.mode}")`);
2199
+ process.exit(1);
2200
+ }
2201
+ if (opts.quality && !["auto", "fast", "best"].includes(opts.quality)) {
2202
+ warn(`--quality must be auto, fast, or best (got "${opts.quality}")`);
2203
+ process.exit(1);
2204
+ }
2205
+ const client = buildClient(opts.profile);
2206
+ const result = await client.audio.separate({
2207
+ audioUrl: opts.audio,
2208
+ ...opts.mode ? { mode: opts.mode } : {},
2209
+ ...opts.quality ? { quality: opts.quality } : {}
2210
+ });
2211
+ await reportQueuedJob(result, () => client.jobs.get(result.jobId), { ...opts, note: opts.mode ?? "vocal_instrumental" });
2212
+ } catch (err) {
2213
+ handleError(err);
2214
+ }
2215
+ }
2216
+ );
2217
+ cmd.command("isolate").description("isolate the primary voice and strip background noise (ElevenLabs voice isolation)").requiredOption("--audio <url>", "audio URL to isolate").option("--watch", "poll until the job completes").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--profile <name>").option("--json").action(async (opts) => {
2218
+ try {
2219
+ const client = buildClient(opts.profile);
2220
+ const result = await client.audio.isolate({ audioUrl: opts.audio });
2221
+ await reportQueuedJob(result, () => client.jobs.get(result.jobId), { ...opts, note: "voice isolation" });
2222
+ } catch (err) {
2223
+ handleError(err);
2224
+ }
2225
+ });
2226
+ cmd.command("fx").description("apply a reverb / echo / telephone / megaphone effect to an audio track \u2014 the same presets VCP's voice-fx uses, standalone").requiredOption("--audio <url>", "audio URL to process").option("--preset <preset>", `effect preset: ${FX_PRESETS2} (server default when omitted)`).option("--mix <n>", "reverb wet/dry mix % (0-100) \u2014 reverb presets", parseFloat).option("--delay <ms>", "echo delay in ms (20-2000) \u2014 echo/custom presets", (v) => parseInt(v, 10)).option("--decay <n>", "echo decay (0-1) \u2014 echo/custom presets", parseFloat).option("--eq-low <db>", "low-shelf gain in dB \u2014 telephone/megaphone shaping", parseFloat).option("--eq-high <db>", "high-shelf gain in dB \u2014 telephone/megaphone shaping", parseFloat).option("--watch", "poll until the job completes").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--profile <name>").option("--json").addHelpText("after", `
2227
+ Example:
2228
+ $ nodaro audio fx --audio https://.../voice.mp3 --preset hall --mix 35 --watch`).action(
2229
+ async (opts) => {
2230
+ try {
2231
+ const client = buildClient(opts.profile);
2232
+ const result = await client.audio.applyFx({
2233
+ audioUrl: opts.audio,
2234
+ ...opts.preset ? { preset: opts.preset } : {},
2235
+ ...opts.mix !== void 0 ? { mix: opts.mix } : {},
2236
+ ...opts.delay !== void 0 ? { delayMs: opts.delay } : {},
2237
+ ...opts.decay !== void 0 ? { decay: opts.decay } : {},
2238
+ ...opts.eqLow !== void 0 ? { eqLow: opts.eqLow } : {},
2239
+ ...opts.eqHigh !== void 0 ? { eqHigh: opts.eqHigh } : {}
2240
+ });
2241
+ await reportQueuedJob(result, () => client.jobs.get(result.jobId), { ...opts, note: opts.preset ?? "audio fx" });
2242
+ } catch (err) {
2243
+ handleError(err);
2244
+ }
2245
+ }
2246
+ );
2247
+ cmd.command("mix").description("layer multiple audio tracks into one (tracks are summed)").option("--audio <url>", "audio track URL \u2014 repeat the flag for each track (2-20)", collectVariadic).option("--volumes <csv>", 'per-track level %, positionally (0-200 each), e.g. "100,80"').option("--watch", "poll until the job completes").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--profile <name>").option("--json").addHelpText("after", `
2248
+ Example:
2249
+ $ nodaro audio mix --audio https://.../voice.mp3 --audio https://.../bed.mp3 --volumes 100,60 --watch`).action(
2250
+ async (opts) => {
2251
+ try {
2252
+ const urls = opts.audio ?? [];
2253
+ if (urls.length < 2) {
2254
+ warn("Provide at least two tracks: --audio <url> --audio <url> ...");
2255
+ process.exit(1);
2256
+ }
2257
+ let trackVolumes;
2258
+ if (opts.volumes) {
2259
+ trackVolumes = opts.volumes.split(",").map((s) => parseFloat(s.trim()));
2260
+ if (trackVolumes.length !== urls.length || trackVolumes.some((v) => Number.isNaN(v))) {
2261
+ warn(`--volumes must be ${urls.length} comma-separated numbers (one per --audio, in order)`);
2262
+ process.exit(1);
2263
+ }
2264
+ }
2265
+ const client = buildClient(opts.profile);
2266
+ const result = await client.audio.mix({
2267
+ audioUrls: urls,
2268
+ ...trackVolumes ? { trackVolumes } : {}
2269
+ });
2270
+ await reportQueuedJob(result, () => client.jobs.get(result.jobId), { ...opts, note: `${urls.length} tracks` });
2271
+ } catch (err) {
2272
+ handleError(err);
2273
+ }
2274
+ }
2275
+ );
2276
+ cmd.command("adjust-volume").description("adjust an audio (or a video's audio) level \u2014 set %, loudness-normalize, fade in/out").option("--audio <url>", "audio URL to adjust").option("--video <url>", "video URL whose audio to adjust").option("--volume <n>", "level % (default 100)", parseFloat).option("--normalize", "apply loudness normalization").option("--fade-in <sec>", "fade-in duration in seconds", parseFloat).option("--fade-out <sec>", "fade-out duration in seconds", parseFloat).option("--watch", "poll until the job completes").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--profile <name>").option("--json").action(
2277
+ async (opts) => {
2278
+ try {
2279
+ if (!opts.audio && !opts.video) {
2280
+ warn("Provide --audio <url> or --video <url> (one is required)");
2281
+ process.exit(1);
2282
+ }
2283
+ const client = buildClient(opts.profile);
2284
+ const result = await client.audio.adjustVolume({
2285
+ ...opts.audio ? { audioUrl: opts.audio } : {},
2286
+ ...opts.video ? { videoUrl: opts.video } : {},
2287
+ ...opts.volume !== void 0 ? { volume: opts.volume } : {},
2288
+ ...opts.normalize ? { normalize: true } : {},
2289
+ ...opts.fadeIn !== void 0 ? { fadeIn: opts.fadeIn } : {},
2290
+ ...opts.fadeOut !== void 0 ? { fadeOut: opts.fadeOut } : {}
2291
+ });
2292
+ await reportQueuedJob(result, () => client.jobs.get(result.jobId), { ...opts, note: "adjust volume" });
2293
+ } catch (err) {
2294
+ handleError(err);
2295
+ }
2296
+ }
2297
+ );
2298
+ cmd.command("combine").description("concatenate audio segments end-to-end").option("--segment <url[@a-b]>", 'segment URL with an optional "@start-end" sub-range in seconds \u2014 repeat per segment, in order', collectVariadic).option("--watch", "poll until the job completes").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--profile <name>").option("--json").addHelpText("after", `
2299
+ Example:
2300
+ $ nodaro audio combine --segment https://.../intro.mp3 --segment "https://.../talk.mp3@12-95" --watch`).action(
2301
+ async (opts) => {
2302
+ try {
2303
+ const raws = opts.segment ?? [];
2304
+ if (raws.length === 0) {
2305
+ warn("Provide at least one segment: --segment <url[@start-end]> ...");
2306
+ process.exit(1);
2307
+ }
2308
+ const segments = raws.map(parseSegment);
2309
+ const client = buildClient(opts.profile);
2310
+ const result = await client.audio.combine({ segments });
2311
+ await reportQueuedJob(result, () => client.jobs.get(result.jobId), {
2312
+ ...opts,
2313
+ note: `${segments.length} segment${segments.length === 1 ? "" : "s"}`
1603
2314
  });
1604
2315
  } catch (err) {
1605
2316
  handleError(err);
@@ -2664,6 +3375,8 @@ program.addCommand(executionsCommand());
2664
3375
  program.addCommand(charactersCommand());
2665
3376
  program.addCommand(promptCommand());
2666
3377
  program.addCommand(voiceCommand());
3378
+ program.addCommand(mediaCommand());
3379
+ program.addCommand(audioCommand());
2667
3380
  program.addCommand(presetsCommand());
2668
3381
  program.addCommand(communityCommand());
2669
3382
  program.addCommand(pickerCatalogsCommand());