Skip to content

Commit 1bcf84c

Browse files
committed
fix(speech): drop server-error TTS hints; cover token-plan --list-voices
1 parent 0e00151 commit 1bcf84c

4 files changed

Lines changed: 36 additions & 251 deletions

File tree

packages/commands/src/commands/speech/synthesize-hint.ts

Lines changed: 0 additions & 71 deletions
This file was deleted.

packages/commands/src/commands/speech/synthesize.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import { downloadFile } from "bailian-cli-runtime";
2424
import { runConcurrent, downloadParallel, getConcurrency } from "bailian-cli-runtime";
2525
import { emitResult, emitBare } from "bailian-cli-runtime";
2626
import { VOICE_TTS_PAGE } from "bailian-cli-runtime";
27-
import { rethrowWithSpeechSynthesizeHint } from "./synthesize-hint.ts";
2827

2928
const COSYVOICE_CLONE_DESIGN_DOC = `${DOCS_HOSTS.cn}/cosyvoice-clone-design-api`;
3029
const QWEN_AUDIO_TTS_VOICE_DOC = `${DOCS_HOSTS.cn}/qwen-audio-tts-voice-list`;
@@ -438,17 +437,10 @@ export default defineCommand({
438437
process.stderr.write(`[Model: ${model}] [Voice: ${voice}]\n`);
439438
}
440439

441-
try {
442-
if (useStream) {
443-
await handleStreamMode(ctx.client, settings, body, flags, format);
444-
} else {
445-
await handleNonStreamMode(ctx.client, settings, body, flags, format);
446-
}
447-
} catch (error) {
448-
rethrowWithSpeechSynthesizeHint(error, {
449-
binName: ctx.identity.binName,
450-
model,
451-
});
440+
if (useStream) {
441+
await handleStreamMode(ctx.client, settings, body, flags, format);
442+
} else {
443+
await handleNonStreamMode(ctx.client, settings, body, flags, format);
452444
}
453445
},
454446
});

packages/commands/tests/e2e/speech-list-voices.e2e.test.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import { writeFileSync } from "node:fs";
2+
import { join } from "node:path";
13
import { describe, expect, test } from "vite-plus/test";
2-
import { isDashScopeE2EReady, runCommandHelp, runCommandE2e } from "./helpers.ts";
4+
import { isDashScopeE2EReady, makeE2eOutputDir, runCommandHelp, runCommandE2e } from "./helpers.ts";
35
import { SPEECH_ROUTES } from "./topic-routes.ts";
46

57
/**
@@ -57,6 +59,35 @@ describe("e2e: speech list-voices", () => {
5759
expect(stdout).toContain("longanfengyue");
5860
expect(stdout).toContain("loongjohn");
5961
});
62+
63+
// 激活 token-plan 后不传 --model,应打出默认 qwen-audio plus 音色
64+
test("Token Plan 未显式传 --model 时 --list-voices 使用默认 qwen-audio TTS", async () => {
65+
const configDir = makeE2eOutputDir("speech-list-voices-token-plan-default");
66+
writeFileSync(
67+
join(configDir, "config.json"),
68+
JSON.stringify({
69+
"token-plan": {
70+
api_key: "sk-sp-e2e-placeholder",
71+
base_url: "https://token-plan.cn-beijing.maas.aliyuncs.com",
72+
default_speech_model: "qwen-audio-3.0-tts-plus",
73+
},
74+
}),
75+
);
76+
77+
const { stdout, stderr, exitCode } = await runCommandE2e(
78+
SPEECH_ROUTES,
79+
["speech", "synthesize", "--config", "token-plan", "--list-voices"],
80+
{
81+
BAILIAN_CONFIG_DIR: configDir,
82+
DASHSCOPE_API_KEY: "",
83+
DASHSCOPE_BASE_URL: "",
84+
},
85+
);
86+
87+
expect(exitCode, stderr).toBe(0);
88+
expect(stdout).toContain("longanlingxin");
89+
expect(stdout).toContain("longanlufeng");
90+
});
6091
});
6192

6293
describe.skipIf(!isDashScopeE2EReady())("e2e: speech list-voices", () => {

packages/commands/tests/speech-synthesize-hint.test.ts

Lines changed: 0 additions & 167 deletions
This file was deleted.

0 commit comments

Comments
 (0)