maoda-commander-tt 0.0.41 → 0.0.43
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 +3 -3
- package/dist/main.js +17 -81
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ pnpm start -- --help
|
|
|
61
61
|
## AI 音频生成
|
|
62
62
|
|
|
63
63
|
`ai audio` 接受一段自然语言提示词并等待 XYQ 返回 MP3。参考音频可选;提供时,
|
|
64
|
-
|
|
64
|
+
提示词需自行用 `@音频1` 引用它,命令不会改写提示词。
|
|
65
65
|
|
|
66
66
|
```bash
|
|
67
67
|
# 纯文本生成音频
|
|
@@ -69,11 +69,11 @@ tt ai audio '萝莉音说:“我今天不回来了”'
|
|
|
69
69
|
|
|
70
70
|
# 参考一段本地音频的音色
|
|
71
71
|
tt ai audio --audio ./reference.mp3 \
|
|
72
|
-
'
|
|
72
|
+
'@音频1 参考它的音色,说:“我生气了,哼”'
|
|
73
73
|
|
|
74
74
|
# 等待生成并下载到本地;省略 --output 时返回远端地址
|
|
75
75
|
tt ai audio --audio ./reference.mp3 --output ./result.mp3 \
|
|
76
|
-
'
|
|
76
|
+
'@音频1 参考它的音色,说:“我生气了,哼”'
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
命令固定使用 `seedaudio_1.0`、MP3 和 44.1 kHz,最多等待 60 秒。参考音频直接
|
package/dist/main.js
CHANGED
|
@@ -3289,6 +3289,7 @@ var ASSET_TYPE = {
|
|
|
3289
3289
|
image: "2",
|
|
3290
3290
|
audio: "4"
|
|
3291
3291
|
};
|
|
3292
|
+
var VIDEO_POLL_INTERVAL_SECONDS = 3;
|
|
3292
3293
|
var IMAGE_EXTENSIONS2 = /* @__PURE__ */ new Set([
|
|
3293
3294
|
".jpg",
|
|
3294
3295
|
".jpeg",
|
|
@@ -3353,7 +3354,7 @@ var XyqSession = class {
|
|
|
3353
3354
|
const submittedAt = this._now();
|
|
3354
3355
|
const body = buildSubmitAudioBody({
|
|
3355
3356
|
prompt,
|
|
3356
|
-
|
|
3357
|
+
referenceAudioPippitAssetId: normalizeString2(input.pippitAssetId),
|
|
3357
3358
|
threadId,
|
|
3358
3359
|
clientRunId,
|
|
3359
3360
|
messageId,
|
|
@@ -3584,15 +3585,11 @@ var XyqSession = class {
|
|
|
3584
3585
|
) : void 0) ?? runList.at(-1);
|
|
3585
3586
|
const runRecord = isRecord2(run) ? run : {};
|
|
3586
3587
|
const serverRunId = normalizeString2(runRecord.run_id);
|
|
3587
|
-
const queueInfo = await this._queryQueueInfoBestEffort(
|
|
3588
|
-
threadId,
|
|
3589
|
-
serverRunId ?? requestedRunId
|
|
3590
|
-
);
|
|
3591
3588
|
const entryList = Array.isArray(runRecord.entry_list) ? runRecord.entry_list : [];
|
|
3592
3589
|
const artifacts = entryList.map(extractVideoArtifact).filter((artifact) => artifact !== void 0);
|
|
3593
3590
|
const providerState = mapXyqRunState(toNumber(runRecord.state));
|
|
3594
3591
|
const state = hasUsableVideoOutput(artifacts) ? "completed" : providerState;
|
|
3595
|
-
const retryAfterSeconds = isTerminalXyqTaskState(state) ? 0 :
|
|
3592
|
+
const retryAfterSeconds = isTerminalXyqTaskState(state) ? 0 : VIDEO_POLL_INTERVAL_SECONDS;
|
|
3596
3593
|
return ok19({
|
|
3597
3594
|
taskId: createXyqTaskId(threadId),
|
|
3598
3595
|
threadId,
|
|
@@ -3600,7 +3597,7 @@ var XyqSession = class {
|
|
|
3600
3597
|
state,
|
|
3601
3598
|
retryAfterSeconds,
|
|
3602
3599
|
artifacts,
|
|
3603
|
-
...
|
|
3600
|
+
...runRecord.RunQueueInfo !== void 0 ? { queueInfo: camelizeValue(runRecord.RunQueueInfo) } : {},
|
|
3604
3601
|
...runRecord.fail_reason !== void 0 ? { failReason: camelizeValue(runRecord.fail_reason) } : {},
|
|
3605
3602
|
raw: camelizeValue(threadResult.value.data)
|
|
3606
3603
|
});
|
|
@@ -3815,31 +3812,6 @@ var XyqSession = class {
|
|
|
3815
3812
|
} : {};
|
|
3816
3813
|
return ok19(headers);
|
|
3817
3814
|
}
|
|
3818
|
-
async _queryQueueInfoBestEffort(threadId, runId) {
|
|
3819
|
-
const result = await requestXyqJson(
|
|
3820
|
-
this._fetcher,
|
|
3821
|
-
`${XYQ_ORIGIN}/api/biz/v1/agent/get_user_queue_info`,
|
|
3822
|
-
{
|
|
3823
|
-
method: "POST",
|
|
3824
|
-
headers: {
|
|
3825
|
-
...this._headers(),
|
|
3826
|
-
"content-type": "application/json"
|
|
3827
|
-
},
|
|
3828
|
-
body: JSON.stringify({
|
|
3829
|
-
uid: this.context.uid,
|
|
3830
|
-
thread_id: threadId,
|
|
3831
|
-
...runId ? { run_id: runId } : {},
|
|
3832
|
-
need_earliest_submitted_working_run: true
|
|
3833
|
-
})
|
|
3834
|
-
},
|
|
3835
|
-
{
|
|
3836
|
-
requestFailedCode: XyqErrorCode.VideoQueryRequestFailed,
|
|
3837
|
-
responseInvalidCode: XyqErrorCode.VideoQueryResponseInvalid,
|
|
3838
|
-
operation: "\u67E5\u8BE2 XYQ \u89C6\u9891\u4EFB\u52A1\u961F\u5217"
|
|
3839
|
-
}
|
|
3840
|
-
);
|
|
3841
|
-
return result.ok ? result.value.data : void 0;
|
|
3842
|
-
}
|
|
3843
3815
|
};
|
|
3844
3816
|
function buildSubmitAudioBody(input) {
|
|
3845
3817
|
const contentData = {
|
|
@@ -3853,7 +3825,14 @@ function buildSubmitAudioBody(input) {
|
|
|
3853
3825
|
loudness_rate: 0,
|
|
3854
3826
|
pitch_rate: 0
|
|
3855
3827
|
},
|
|
3856
|
-
...input.
|
|
3828
|
+
...input.referenceAudioPippitAssetId ? {
|
|
3829
|
+
references: [
|
|
3830
|
+
{
|
|
3831
|
+
type: "audio",
|
|
3832
|
+
pippit_asset_id: input.referenceAudioPippitAssetId
|
|
3833
|
+
}
|
|
3834
|
+
]
|
|
3835
|
+
} : {}
|
|
3857
3836
|
};
|
|
3858
3837
|
const runExtra = {
|
|
3859
3838
|
babi_param: {
|
|
@@ -4098,19 +4077,6 @@ function extractVideoArtifact(entry) {
|
|
|
4098
4077
|
raw: camelizeValue(artifact)
|
|
4099
4078
|
};
|
|
4100
4079
|
}
|
|
4101
|
-
function resolveRetryAfterSeconds(queueInfo) {
|
|
4102
|
-
const parsed = parseJsonRecord(queueInfo) ?? queueInfo;
|
|
4103
|
-
const value = deepFindStringByKey(parsed, [
|
|
4104
|
-
"estimated_wait_seconds",
|
|
4105
|
-
"wait_seconds",
|
|
4106
|
-
"queue_wait_seconds"
|
|
4107
|
-
]);
|
|
4108
|
-
const seconds = Number(value ?? 0);
|
|
4109
|
-
if (Number.isFinite(seconds) && seconds > 0) {
|
|
4110
|
-
return Math.max(1, Math.min(Math.ceil(seconds), 5));
|
|
4111
|
-
}
|
|
4112
|
-
return 3;
|
|
4113
|
-
}
|
|
4114
4080
|
function deepCollectAudioOutputs(value) {
|
|
4115
4081
|
const results = /* @__PURE__ */ new Map();
|
|
4116
4082
|
collectAudioOutputs(value, void 0, results, 0);
|
|
@@ -4290,36 +4256,6 @@ function collectExplicitVideo(value, inheritedPippitAssetId, results, depth) {
|
|
|
4290
4256
|
function videoQualityScore(output) {
|
|
4291
4257
|
return (output.width ?? 0) * (output.height ?? 0);
|
|
4292
4258
|
}
|
|
4293
|
-
function deepFindStringByKey(value, keys, depth = 0) {
|
|
4294
|
-
if (depth > 6) {
|
|
4295
|
-
return void 0;
|
|
4296
|
-
}
|
|
4297
|
-
if (Array.isArray(value)) {
|
|
4298
|
-
for (const item of value) {
|
|
4299
|
-
const found = deepFindStringByKey(item, keys, depth + 1);
|
|
4300
|
-
if (found) {
|
|
4301
|
-
return found;
|
|
4302
|
-
}
|
|
4303
|
-
}
|
|
4304
|
-
return void 0;
|
|
4305
|
-
}
|
|
4306
|
-
if (!isRecord2(value)) {
|
|
4307
|
-
return void 0;
|
|
4308
|
-
}
|
|
4309
|
-
for (const key of keys) {
|
|
4310
|
-
const found = normalizeString2(value[key]);
|
|
4311
|
-
if (found) {
|
|
4312
|
-
return found;
|
|
4313
|
-
}
|
|
4314
|
-
}
|
|
4315
|
-
for (const child of Object.values(value)) {
|
|
4316
|
-
const found = deepFindStringByKey(child, keys, depth + 1);
|
|
4317
|
-
if (found) {
|
|
4318
|
-
return found;
|
|
4319
|
-
}
|
|
4320
|
-
}
|
|
4321
|
-
return void 0;
|
|
4322
|
-
}
|
|
4323
4259
|
function parseJsonRecord(value) {
|
|
4324
4260
|
if (isRecord2(value)) {
|
|
4325
4261
|
return value;
|
|
@@ -4757,7 +4693,7 @@ var AiAudioCommand = class extends AiBaseCommand {
|
|
|
4757
4693
|
}
|
|
4758
4694
|
_configureOptions(cmd) {
|
|
4759
4695
|
cmd.addOption(
|
|
4760
|
-
new Option8("--audio <path>", "\u53EF\u9009\u53C2\u8003\u97F3\u9891\uFF0C\u6700\u591A\u4E00\u4E2A").argParser(appendAudioPath)
|
|
4696
|
+
new Option8("--audio <path>", "\u53EF\u9009\u53C2\u8003\u97F3\u9891\uFF0C\u6700\u591A\u4E00\u4E2A\uFF1B\u63D0\u793A\u8BCD\u9700\u7528 @\u97F3\u98911 \u5F15\u7528").argParser(appendAudioPath)
|
|
4761
4697
|
);
|
|
4762
4698
|
cmd.addOption(
|
|
4763
4699
|
new Option8(
|
|
@@ -4793,7 +4729,7 @@ var AiAudioCommand = class extends AiBaseCommand {
|
|
|
4793
4729
|
return this._fail(sessionResult.code, sessionResult.msg);
|
|
4794
4730
|
}
|
|
4795
4731
|
const session = sessionResult.value;
|
|
4796
|
-
let
|
|
4732
|
+
let referenceAudioPippitAssetId;
|
|
4797
4733
|
if (audioPath) {
|
|
4798
4734
|
const uploadResult = await session.uploadAudio(audioPath, {
|
|
4799
4735
|
useCache: false
|
|
@@ -4801,14 +4737,14 @@ var AiAudioCommand = class extends AiBaseCommand {
|
|
|
4801
4737
|
if (!uploadResult.ok) {
|
|
4802
4738
|
return this._fail(uploadResult.code, uploadResult.msg);
|
|
4803
4739
|
}
|
|
4804
|
-
|
|
4805
|
-
if (!
|
|
4740
|
+
referenceAudioPippitAssetId = uploadResult.value.pippitAssetId?.trim();
|
|
4741
|
+
if (!referenceAudioPippitAssetId) {
|
|
4806
4742
|
return this._fail(1, "\u53C2\u8003\u97F3\u9891\u4E0A\u4F20\u6210\u529F\uFF0C\u4F46\u672A\u8FD4\u56DE pippitAssetId");
|
|
4807
4743
|
}
|
|
4808
4744
|
}
|
|
4809
4745
|
const submitResult = await session.submitAudio({
|
|
4810
4746
|
prompt,
|
|
4811
|
-
...
|
|
4747
|
+
...referenceAudioPippitAssetId ? { pippitAssetId: referenceAudioPippitAssetId } : {}
|
|
4812
4748
|
});
|
|
4813
4749
|
if (!submitResult.ok) {
|
|
4814
4750
|
return this._fail(submitResult.code, submitResult.msg);
|