@doufunao123/asset-gateway 0.15.0 → 0.16.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 +45 -1
- 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
|
|
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,56 @@ 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 designData = data?.data;
|
|
1674
|
+
const b64Audio = designData?.preview_audio_data;
|
|
1675
|
+
if (b64Audio) {
|
|
1676
|
+
const { mkdirSync: mkdirSync5, writeFileSync: writeFileSync5 } = await import("fs");
|
|
1677
|
+
const { join: join5 } = await import("path");
|
|
1678
|
+
mkdirSync5(options.outputDir, { recursive: true });
|
|
1679
|
+
const buf = Buffer.from(b64Audio, "base64");
|
|
1680
|
+
const outPath = join5(options.outputDir, `${options.name}_preview.wav`);
|
|
1681
|
+
writeFileSync5(outPath, buf);
|
|
1682
|
+
data.preview_audio_path = outPath;
|
|
1683
|
+
}
|
|
1673
1684
|
printSuccess("voice.design", data, ctx);
|
|
1674
1685
|
} catch (error2) {
|
|
1675
1686
|
printError("voice.design", error2);
|
|
1676
1687
|
}
|
|
1677
1688
|
})
|
|
1678
1689
|
);
|
|
1690
|
+
command.addCommand(
|
|
1691
|
+
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) {
|
|
1692
|
+
try {
|
|
1693
|
+
const ctx = createContext(this);
|
|
1694
|
+
const body = {
|
|
1695
|
+
voice: options.voice,
|
|
1696
|
+
text: options.text
|
|
1697
|
+
};
|
|
1698
|
+
if (options.model) body.model = options.model;
|
|
1699
|
+
if (options.language) body.language = options.language;
|
|
1700
|
+
const data = await ctx.client.post("/api/voice/synthesize", body);
|
|
1701
|
+
const result = data.data;
|
|
1702
|
+
const output2 = result?.output;
|
|
1703
|
+
const audio = output2?.audio;
|
|
1704
|
+
const audioUrl = audio?.url ?? output2?.url;
|
|
1705
|
+
if (audioUrl && options.outputDir) {
|
|
1706
|
+
const { mkdirSync: mkdirSync5, writeFileSync: writeFileSync5 } = await import("fs");
|
|
1707
|
+
const { join: join5 } = await import("path");
|
|
1708
|
+
mkdirSync5(options.outputDir, { recursive: true });
|
|
1709
|
+
const resp = await fetch(audioUrl);
|
|
1710
|
+
if (resp.ok) {
|
|
1711
|
+
const buf = Buffer.from(await resp.arrayBuffer());
|
|
1712
|
+
const outPath = join5(options.outputDir, `tts_${Date.now()}.wav`);
|
|
1713
|
+
writeFileSync5(outPath, buf);
|
|
1714
|
+
data.local_path = outPath;
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
printSuccess("voice.synthesize", data, ctx);
|
|
1718
|
+
} catch (error2) {
|
|
1719
|
+
printError("voice.synthesize", error2);
|
|
1720
|
+
}
|
|
1721
|
+
})
|
|
1722
|
+
);
|
|
1679
1723
|
command.addCommand(
|
|
1680
1724
|
new Command9("list").description("List custom designed voices").option("--type <type>", "Voice type: vd").action(async function(options) {
|
|
1681
1725
|
try {
|