@doufunao123/asset-gateway 0.15.0 → 0.16.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.
Files changed (2) hide show
  1. package/dist/index.js +44 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1660,7 +1660,7 @@ function withVoiceType(path, type) {
1660
1660
  function createVoiceCommand() {
1661
1661
  const command = new Command9("voice").description("Manage Qwen3-TTS voice designs");
1662
1662
  command.addCommand(
1663
- new Command9("design").description("Create a synthetic voice from a text description").requiredOption("--prompt <text>", "Voice description prompt").requiredOption("--preview-text <text>", "Preview text for the generated sample").requiredOption("--name <name>", "Name for the designed voice").option("--target-model <model>", "Voice design model, e.g. qwen3-tts-vd-2026-01-26").action(async function(options) {
1663
+ new Command9("design").description("Create a synthetic voice and save the preview audio file").requiredOption("--prompt <text>", "Voice description prompt").requiredOption("--preview-text <text>", "Preview text for the generated sample").requiredOption("--name <name>", "Name for the designed voice").option("--target-model <model>", "Voice design model, e.g. qwen3-tts-vd-2026-01-26").option("--output-dir <dir>", "Directory to save preview audio", ".").action(async function(options) {
1664
1664
  try {
1665
1665
  const ctx = createContext(this);
1666
1666
  const body = {
@@ -1670,12 +1670,55 @@ function createVoiceCommand() {
1670
1670
  };
1671
1671
  if (options.targetModel) body.target_model = options.targetModel;
1672
1672
  const data = await ctx.client.post("/api/voice/design", body);
1673
+ const b64Audio = data?.preview_audio_data;
1674
+ if (b64Audio) {
1675
+ const { mkdirSync: mkdirSync5, writeFileSync: writeFileSync5 } = await import("fs");
1676
+ const { join: join5 } = await import("path");
1677
+ mkdirSync5(options.outputDir, { recursive: true });
1678
+ const buf = Buffer.from(b64Audio, "base64");
1679
+ const outPath = join5(options.outputDir, `${options.name}_preview.wav`);
1680
+ writeFileSync5(outPath, buf);
1681
+ data.preview_audio_path = outPath;
1682
+ }
1673
1683
  printSuccess("voice.design", data, ctx);
1674
1684
  } catch (error2) {
1675
1685
  printError("voice.design", error2);
1676
1686
  }
1677
1687
  })
1678
1688
  );
1689
+ command.addCommand(
1690
+ new Command9("synthesize").description("Synthesize speech using a designed voice").requiredOption("--voice <name>", "Voice name from voice design").requiredOption("--text <text>", "Text to synthesize").option("--model <model>", "TTS model (default: qwen3-tts-vd-realtime-2025-12-16)").option("--language <lang>", "Language: zh, en, ja, etc. (default: Auto)").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
1691
+ try {
1692
+ const ctx = createContext(this);
1693
+ const body = {
1694
+ voice: options.voice,
1695
+ text: options.text
1696
+ };
1697
+ if (options.model) body.model = options.model;
1698
+ if (options.language) body.language = options.language;
1699
+ const data = await ctx.client.post("/api/voice/synthesize", body);
1700
+ const result = data.data;
1701
+ const output2 = result?.output;
1702
+ const audio = output2?.audio;
1703
+ const audioUrl = audio?.url ?? output2?.url;
1704
+ if (audioUrl && options.outputDir) {
1705
+ const { mkdirSync: mkdirSync5, writeFileSync: writeFileSync5 } = await import("fs");
1706
+ const { join: join5 } = await import("path");
1707
+ mkdirSync5(options.outputDir, { recursive: true });
1708
+ const resp = await fetch(audioUrl);
1709
+ if (resp.ok) {
1710
+ const buf = Buffer.from(await resp.arrayBuffer());
1711
+ const outPath = join5(options.outputDir, `tts_${Date.now()}.wav`);
1712
+ writeFileSync5(outPath, buf);
1713
+ data.local_path = outPath;
1714
+ }
1715
+ }
1716
+ printSuccess("voice.synthesize", data, ctx);
1717
+ } catch (error2) {
1718
+ printError("voice.synthesize", error2);
1719
+ }
1720
+ })
1721
+ );
1679
1722
  command.addCommand(
1680
1723
  new Command9("list").description("List custom designed voices").option("--type <type>", "Voice type: vd").action(async function(options) {
1681
1724
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doufunao123/asset-gateway",
3
- "version": "0.15.0",
3
+ "version": "0.16.1",
4
4
  "description": "Universal asset generation gateway CLI",
5
5
  "type": "module",
6
6
  "bin": {