Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

feat(desktop): populate Alibaba speech voice catalogs

JiangJiahao43bc5fd2c196
diff --git a/apps/desktop/scripts/fixtures/voice-settings/ui-page.mjs b/apps/desktop/scripts/fixtures/voice-settings/ui-page.mjs
index 72dceea5ff..fbaccac669 100644
--- a/apps/desktop/scripts/fixtures/voice-settings/ui-page.mjs
+++ b/apps/desktop/scripts/fixtures/voice-settings/ui-page.mjs
@@ -50,6 +50,39 @@ export default {
about: 'Eleven v3 keeps voice and preview but does not offer a speed slider',
data: { modelId: 'eleven_v3' },
},
+ 'qwen-catalog': {
+ about: 'Complete Qwen3 system catalog with official display names and keyboard navigation',
+ data: {
+ protocol: 'qwen-tts',
+ modelId: 'qwen3-tts-flash',
+ voiceId: 'Cherry',
+ systemCatalog: true,
+ menu: true,
+ },
+ },
+ 'cosy-catalog': {
+ about: 'Complete CosyVoice system catalog plus a matching account voice in a narrow drawer',
+ viewport: { width: 320, height: 900 },
+ data: {
+ protocol: 'dashscope-tts',
+ modelId: 'cosyvoice-v3-flash',
+ voiceId: 'longanyang',
+ systemCatalog: true,
+ customCatalog: true,
+ menu: true,
+ },
+ },
+ 'cosy-custom-failure': {
+ about: 'Account catalog failure preserves system choices, selected voice, and refresh',
+ viewport: { width: 320, height: 900 },
+ data: {
+ protocol: 'dashscope-tts',
+ modelId: 'cosyvoice-v3-flash',
+ voiceId: 'longanyang',
+ systemCatalog: true,
+ customCatalogFailure: true,
+ },
+ },
empty: {
about: 'No models keeps only the existing setup introduction and provider link',
data: { empty: true },
@@ -80,7 +113,9 @@ export default {
const label = await page.evaluate(() => window.__uiPage.t('bots.voiceMode.voiceId'));
await page.getByRole('textbox', { name: label, exact: true }).waitFor();
} else {
- const voice = await page.evaluate(() => window.__uiPage.ctx.data.voiceId);
+ const voice = await page.evaluate(
+ () => window.__uiPage.ctx.data.voiceLabel ?? window.__uiPage.ctx.data.voiceId,
+ );
await page
.getByText(voice ?? 'River — Relaxed, Neutral, Informative', { exact: true })
.waitFor();
@@ -135,6 +170,40 @@ export default {
return;
}
assert.equal(await standalonePreview.count(), 0);
+ if (ui.data.systemCatalog) {
+ const label = await ui.t('bots.voiceMode.voice');
+ const trigger = page.getByRole('button', { name: label, exact: true });
+ const menu = page.getByRole('dialog', { name: label });
+ if (ui.data.customCatalogFailure) {
+ await page.getByText(await ui.t('bots.voiceMode.voicesCustomError')).waitFor();
+ await page
+ .getByRole('button', { name: await ui.t('bots.voiceMode.refreshVoices'), exact: true })
+ .click();
+ await trigger.click();
+ }
+ await menu.waitFor();
+ const firstName = ui.data.protocol === 'qwen-tts' ? '芊悦' : '龙安洋';
+ const lastName = ui.data.customCatalog
+ ? 'My Custom Voice'
+ : ui.data.protocol === 'qwen-tts'
+ ? '粤语-阿清'
+ : 'Bella3.0';
+ await menu.getByRole('button', { name: firstName, exact: true }).focus();
+ await page.keyboard.press('End');
+ // Manual entry is the final action after all provider/system voices.
+ await page.keyboard.press('ArrowUp');
+ const last = menu.getByRole('button', { name: lastName, exact: true });
+ assert.equal(await last.evaluate((el) => el === document.activeElement), true);
+ await ui.capture('catalog-end');
+ await page.keyboard.press('Home');
+ await ui.capture('catalog-start');
+ assert.equal(await page.evaluate(() => window.__uiPage.ctx.data.savedVoice), ui.data.voiceId);
+ assert.equal(await page.evaluate(() => window.__uiPage.ctx.data.previewRequests.length), 0);
+ await page.keyboard.press('Escape');
+ await menu.waitFor({ state: 'hidden' });
+ assert.equal(await trigger.evaluate((el) => el === document.activeElement), true);
+ return;
+ }
if (ui.data.menu) {
const label = await ui.t('bots.voiceMode.voice');
const trigger = page.getByRole('button', { name: label, exact: true });
diff --git a/apps/desktop/scripts/fixtures/voice-settings/voice-settings-fixture.tsx b/apps/desktop/scripts/fixtures/voice-settings/voice-settings-fixture.tsx
index 65cee5bf22..54a9540dc5 100644
--- a/apps/desktop/scripts/fixtures/voice-settings/voice-settings-fixture.tsx
+++ b/apps/desktop/scripts/fixtures/voice-settings/voice-settings-fixture.tsx
@@ -1,5 +1,6 @@
import { mountPage, forbid } from '../../ui-page/harness';
import { CompanionVoiceSettings } from '../../../src/renderer/features/bots/voice/CompanionVoiceSettings';
+import { alibabaSystemVoices } from '../../../src/shared/alibabaSpeechVoices';
import type {
SpeechProtocol,
VoiceConversationPreference,
@@ -19,6 +20,10 @@ mountPage({
const modelId = String(ctx.data.modelId ?? 'eleven_flash_v2_5');
const referenceVoice = String(ctx.data.voiceId ?? 'river');
const initialVoice = ctx.data.manual ? 'custom-voice' : referenceVoice;
+ const systemVoices = alibabaSystemVoices(modelId, protocol);
+ ctx.data.voiceLabel = ctx.data.systemCatalog
+ ? systemVoices.find((voice) => voice.id === referenceVoice)?.name
+ : undefined;
const pending = new Map<string, () => void>();
const previews: Array<{ voice: string; speed?: number; previewId: string }> = [];
const stops: string[] = [];
@@ -64,26 +69,40 @@ mountPage({
defaultVoice: referenceVoice,
},
],
- voices: async () => ({
- source: ctx.data.voiceId ? 'reference' : 'provider',
- voices: [
- {
- id: referenceVoice,
- name: ctx.data.voiceId ? referenceVoice : 'River — Relaxed, Neutral, Informative',
- },
- ...(ctx.data.menu
- ? [
- { id: 'bella', name: 'Bella — Professional, Bright, Warm' },
- { id: 'sarah', name: 'Sarah — Mature, Reassuring, Confident' },
- { id: 'roger', name: 'Roger — Laid-Back, Casual, Resonant' },
- { id: 'laura', name: 'Laura — Enthusiast, Quirky Attitude' },
- { id: 'charlie', name: 'Charlie — Deep, Confident, Energetic' },
- { id: 'george', name: 'George — Warm, Captivating Storyteller' },
- { id: 'callum', name: 'Callum — Husky, Trickster' },
- ]
- : []),
- ],
- }),
+ voices: async () =>
+ ctx.data.systemCatalog
+ ? {
+ source: ctx.data.customCatalog ? 'mixed' : 'reference',
+ ...(ctx.data.customCatalogFailure ? { customVoicesUnavailable: true } : {}),
+ voices: [
+ ...systemVoices,
+ ...(ctx.data.customCatalog
+ ? [{ id: 'account-clone', name: 'My Custom Voice' }]
+ : []),
+ ],
+ }
+ : {
+ source: ctx.data.voiceId ? 'reference' : 'provider',
+ voices: [
+ {
+ id: referenceVoice,
+ name: ctx.data.voiceId
+ ? referenceVoice
+ : 'River — Relaxed, Neutral, Informative',
+ },
+ ...(ctx.data.menu
+ ? [
+ { id: 'bella', name: 'Bella — Professional, Bright, Warm' },
+ { id: 'sarah', name: 'Sarah — Mature, Reassuring, Confident' },
+ { id: 'roger', name: 'Roger — Laid-Back, Casual, Resonant' },
+ { id: 'laura', name: 'Laura — Enthusiast, Quirky Attitude' },
+ { id: 'charlie', name: 'Charlie — Deep, Confident, Energetic' },
+ { id: 'george', name: 'George — Warm, Captivating Storyteller' },
+ { id: 'callum', name: 'Callum — Husky, Trickster' },
+ ]
+ : []),
+ ],
+ },
preference: async () => preference,
setPreference: async (
_botId: string,
diff --git a/apps/desktop/src/main/voice-conversation/__tests__/dashscopeVoices.test.ts b/apps/desktop/src/main/voice-conversation/__tests__/dashscopeVoices.test.ts
new file mode 100644
index 0000000000..a05535e990
--- /dev/null
+++ b/apps/desktop/src/main/voice-conversation/__tests__/dashscopeVoices.test.ts
@@ -0,0 +1,202 @@
+import { expect, it, vi } from 'vitest';
+import { loadSpeechVoices } from '../voices.js';
+import type { SpeechConnection } from '../speech.js';
+
+const model = 'cosyvoice-v3-flash';
+const connection: SpeechConnection = {
+ protocol: 'dashscope-tts',
+ baseUrl: 'https://workspace.cn-beijing.maas.aliyuncs.com/api/v1',
+ headers: { authorization: 'Bearer test-key' },
+};
+const json = (output: unknown) => new Response(JSON.stringify({ output }));
+const list = (voice_list: unknown[]) => json({ voice_list });
+const ready = (voice_id: string, target_model = model) => ({
+ voice_id,
+ target_model,
+ status: 'OK',
+});
+const load = (fetcher: typeof fetch, modelId = model, baseUrl = connection.baseUrl) =>
+ loadSpeechVoices({ ...connection, baseUrl }, modelId, fetcher, () => {});
+
+// Unit tier: exercise the production catalog entry with the documented provider
+// response shapes. Prevent cross-model/private voice leakage, lost public fallbacks,
+// and unbounded catalog requests without requiring a paid account or audio output.
+it('loads the complete Qwen3 system catalog without an account discovery request', async () => {
+ const fetcher = vi.fn();
+ const result = await loadSpeechVoices(
+ { ...connection, protocol: 'qwen-tts' },
+ 'qwen3-tts-flash',
+ fetcher,
+ () => {},
+ );
+ expect(result.source).toBe('reference');
+ expect(result.voices).toHaveLength(48);
+ expect(result.voices).toContainEqual({ id: 'Cherry', name: '芊悦' });
+ expect(result.voices).toContainEqual({ id: 'Eldric Sage', name: '沧明子' });
+ expect(fetcher).not.toHaveBeenCalled();
+});
+
+it.each([
+ ['cosyvoice-v3-flash', 88, 32],
+ ['cosyvoice-v3-plus', 2, 2],
+ ['cosyvoice-v2', 106, 0],
+ ['qwen-audio-3.1-tts-flash', 68, 19],
+ ['qwen-audio-3.0-tts-plus', 2, 2],
+ ['qwen-audio-3.0-tts-flash', 12, 12],
+ ['cosyvoice-v3.5-plus', 0, 0],
+] as const)('keeps %s system voices specific to the exact model and region', async (id, bj, sg) => {
+ const fetcher = vi.fn<typeof fetch>().mockImplementation(async () => list([]));
+ expect((await load(fetcher, id)).voices).toHaveLength(bj);
+ const result = await load(
+ fetcher,
+ id,
+ 'https://workspace.ap-southeast-1.maas.aliyuncs.com/api/v1',
+ );
+ expect(result.voices).toHaveLength(sg);
+ expect(new Set(result.voices.map((voice) => voice.id)).size).toBe(sg);
+});
+
+it('merges only ready custom voices bound to the exact model, querying missing metadata', async () => {
+ const fetcher = vi
+ .fn<typeof fetch>()
+ .mockResolvedValueOnce(
+ list([
+ { ...ready('named'), voice_name: 'My Voice', preview_url: 'https://untrusted.test' },
+ { voice_id: 'opaque-id', status: 'OK' },
+ ready('other', 'cosyvoice-v3-plus'),
+ { ...ready('pending'), status: 'DEPLOYING' },
+ { ...ready('retired'), status: 'UNDEPLOYED' },
+ ready('bad/path'),
+ ready('longanyang'),
+ ]),
+ )
+ .mockResolvedValueOnce(
+ json({ target_model: model, status: 'OK', resource_link: 'https://untrusted.test' }),
+ );
+ const result = await load(fetcher);
+ expect(result.source).toBe('mixed');
+ expect(result.voices).toHaveLength(90);
+ expect(result.voices.slice(-2)).toEqual([
+ { id: 'named', name: 'My Voice' },
+ { id: 'opaque-id', name: 'opaque-id' },
+ ]);
+ expect(result.voices[0]).toEqual({ id: 'longanyang', name: '龙安洋' });
+ expect(fetcher).toHaveBeenCalledTimes(2);
+ expect(fetcher).toHaveBeenNthCalledWith(
+ 2,
+ 'https://workspace.cn-beijing.maas.aliyuncs.com/api/v1/services/audio/tts/customization',
+ expect.objectContaining({
+ method: 'POST',
+ redirect: 'error',
+ headers: { authorization: 'Bearer test-key', 'content-type': 'application/json' },
+ body: JSON.stringify({
+ model: 'voice-enrollment',
+ input: { action: 'query_voice', voice_id: 'opaque-id' },
+ }),
+ }),
+ );
+});
+
+it('paginates in the selected proxy and keeps clone-only model catalogs independent', async () => {
+ const customModel = 'cosyvoice-v3.5-plus';
+ const fetcher = vi
+ .fn<typeof fetch>()
+ .mockResolvedValueOnce(
+ list(Array.from({ length: 100 }, (_, i) => ready(`voice-${i}`, customModel))),
+ )
+ .mockResolvedValueOnce(list([ready('voice-100', customModel), ready('voice-0', customModel)]));
+ const result = await load(fetcher, customModel, 'https://proxy.test/prefix/api/v1/');
+ expect(result.source).toBe('provider');
+ expect(result.voices).toHaveLength(101);
+ expect(fetcher).toHaveBeenNthCalledWith(
+ 2,
+ 'https://proxy.test/prefix/api/v1/services/audio/tts/customization',
+ expect.objectContaining({
+ body: JSON.stringify({
+ model: 'voice-enrollment',
+ input: { action: 'list_voice', page_index: 1, page_size: 100 },
+ }),
+ }),
+ );
+});
+
+it('never infers a custom voice binding from its ID or copies unknown metadata', async () => {
+ const fetcher = vi
+ .fn<typeof fetch>()
+ .mockResolvedValueOnce(
+ list([{ voice_id: `${model}-clone`, status: 'OK' }, { voice_id: 'unknown' }]),
+ )
+ .mockResolvedValueOnce(json({ target_model: 'qwen-audio-3.1-tts-flash', status: 'OK' }))
+ .mockResolvedValueOnce(json({ status: 'OK', voice_prompt: 'private prompt' }));
+ const result = await load(fetcher);
+ expect(result.voices).toHaveLength(88);
+ expect(JSON.stringify(result)).not.toContain('private');
+});
+
+it.each([
+ () => new Response('private error', { status: 403 }),
+ () => new Response(JSON.stringify({ code: 'InvalidApiKey', message: 'private error' })),
+ () => json({ voice_list: 'invalid' }),
+ () => new Response(' '.repeat(2 * 1024 * 1024 + 1)),
+])('keeps public voices and a controlled warning when custom discovery fails', async (response) => {
+ const result = await load(vi.fn<typeof fetch>().mockResolvedValue(response()));
+ expect(result.source).toBe('reference');
+ expect(result.voices).toHaveLength(88);
+ expect(result).toHaveProperty('customVoicesUnavailable', true);
+ expect(JSON.stringify(result)).not.toMatch(/private|InvalidApiKey/);
+});
+
+it('does not swallow connection changes in the public-list fallback', async () => {
+ let current = true;
+ const fetcher = vi.fn(async () => {
+ current = false;
+ return list([ready('private')]);
+ });
+ await expect(
+ loadSpeechVoices(connection, model, fetcher, () => {
+ if (!current) throw new Error('connection_changed');
+ }),
+ ).rejects.toThrow('connection_changed');
+});
+
+it('bounds details and list pages while keeping already verified voices', async () => {
+ const fetcher = vi.fn<typeof fetch>(async (_url, init) => {
+ const input = JSON.parse(String(init?.body)).input;
+ return input.action === 'query_voice'
+ ? json({ target_model: model, status: 'OK' })
+ : list(
+ Array.from({ length: 100 }, (_, i) => ({
+ voice_id: `opaque-${input.page_index}-${i}`,
+ status: 'OK',
+ })),
+ );
+ });
+ const result = await load(fetcher);
+ expect(result.truncated).toBe(true);
+ expect(result.voices).toHaveLength(188);
+ expect(
+ fetcher.mock.calls.filter(
+ ([, init]) => JSON.parse(String(init?.body)).input.action === 'query_voice',
+ ),
+ ).toHaveLength(100);
+ expect(fetcher.mock.calls.length).toBeLessThanOrEqual(110);
+});
+
+it('cancels stalled custom discovery at the shared deadline and returns public voices', async () => {
+ vi.useFakeTimers();
+ const cancelled = vi.fn();
+ try {
+ const pending = load(
+ vi
+ .fn<typeof fetch>()
+ .mockResolvedValue(new Response(new ReadableStream({ cancel: cancelled }))),
+ );
+ await vi.advanceTimersByTimeAsync(15_000);
+ const result = await pending;
+ expect(cancelled).toHaveBeenCalledOnce();
+ expect(result.voices).toHaveLength(88);
+ expect(result).toHaveProperty('customVoicesUnavailable', true);
+ } finally {
+ vi.useRealTimers();
+ }
+});
diff --git a/apps/desktop/src/main/voice-conversation/__tests__/models.test.ts b/apps/desktop/src/main/voice-conversation/__tests__/models.test.ts
index 6922290ab2..a5e07b4791 100644
--- a/apps/desktop/src/main/voice-conversation/__tests__/models.test.ts
+++ b/apps/desktop/src/main/voice-conversation/__tests__/models.test.ts
@@ -337,7 +337,7 @@ it.each([
'https://work.ap-southeast-1.maas.aliyuncs.com/api/v1',
'qwen-audio-3.0-tts-plus',
'dashscope-tts',
- '',
+ 'longanlingxin',
],
] as const)(
'binds %s %s to its verified HTTP adapter',
diff --git a/apps/desktop/src/main/voice-conversation/__tests__/voices.test.ts b/apps/desktop/src/main/voice-conversation/__tests__/voices.test.ts
index 951cf12dd6..de0532f371 100644
--- a/apps/desktop/src/main/voice-conversation/__tests__/voices.test.ts
+++ b/apps/desktop/src/main/voice-conversation/__tests__/voices.test.ts
@@ -184,6 +184,7 @@ describe('provider voice catalogs', () => {
// Unit tier: native references must not accidentally fall through to ElevenLabs
// account discovery or invent a default for clone-only/unknown model variants.
+// Known DashScope models may query their own read-only customization directory.
it.each([
['qwen-tts', 'qwen3-tts-flash', 'Cherry'],
['qwen-tts', 'qwen3-tts-flash-realtime', undefined],
@@ -192,14 +193,18 @@ it.each([
['dashscope-tts', 'cosyvoice-v3.5-plus', undefined],
['dashscope-tts', 'private-model', undefined],
] as const)(
- 'loads %s %s reference/manual voices without network discovery',
+ 'loads %s %s without falling through to another provider API',
async (protocol, modelId, voice) => {
- const fetcher = vi.fn();
- expect(await loadSpeechVoices(connection(protocol), modelId, fetcher, () => {})).toEqual({
- source: voice ? 'reference' : 'manual',
- voices: voice ? [{ id: voice, name: voice }] : [],
- });
- expect(fetcher).not.toHaveBeenCalled();
+ const fetcher = vi.fn<typeof fetch>().mockResolvedValue(json({ output: { voice_list: [] } }));
+ const result = await loadSpeechVoices(connection(protocol), modelId, fetcher, () => {});
+ expect(result.source).toBe(voice ? 'reference' : 'manual');
+ expect(result.voices[0]?.id).toBe(voice);
+ if (protocol === 'dashscope-tts' && modelId !== 'private-model') {
+ expect(fetcher).toHaveBeenCalledOnce();
+ expect(fetcher.mock.calls[0][0]).toBe(
+ 'https://provider.test/prefix/v1/services/audio/tts/customization',
+ );
+ } else expect(fetcher).not.toHaveBeenCalled();
const choice = {
providerId: 'ali',
agent: 'codex',
diff --git a/apps/desktop/src/main/voice-conversation/dashscopeVoices.ts b/apps/desktop/src/main/voice-conversation/dashscopeVoices.ts
new file mode 100644
index 0000000000..9bd65b39a8
--- /dev/null
+++ b/apps/desktop/src/main/voice-conversation/dashscopeVoices.ts
@@ -0,0 +1,86 @@
+import { alibabaSystemVoices } from '../../shared/alibabaSpeechVoices.js';
+import { isCosyVoiceHttpModel, isQwenAudioHttpModel } from '../../shared/speechProtocols.js';
+import { normalizeSpeechVoiceId, type SpeechVoiceCatalog } from '../../shared/voiceConversation.js';
+
+type RecordValue = Record<string, unknown>;
+const record = (value: unknown): RecordValue =>
+ value && typeof value === 'object' && !Array.isArray(value) ? (value as RecordValue) : {};
+
+/** List/query only: never creates, edits, deletes or downloads a voice. The list
+ * response may omit target_model, so query details instead of guessing from IDs.
+ * https://help.aliyun.com/zh/model-studio/voice-clone-design-http-api
+ */
+export async function loadDashscopeVoices(
+ modelId: string,
+ baseUrl: string,
+ request: (url: URL, body: unknown) => Promise<RecordValue>,
+ assertCurrent: () => void,
+): Promise<SpeechVoiceCatalog> {
+ const system = alibabaSystemVoices(modelId, 'dashscope-tts', baseUrl);
+ if (!isCosyVoiceHttpModel(modelId) && !isQwenAudioHttpModel(modelId))
+ return { voices: [], source: 'manual' };
+ const voices = new Map(system.map((voice) => [voice.id, voice]));
+ const seen = new Set<string>();
+ const url = new URL(`${baseUrl.replace(/\/+$/, '')}/services/audio/tts/customization`);
+ let truncated = false;
+ let customVoicesUnavailable = false;
+ let details = 0;
+ const query = async (input: RecordValue): Promise<RecordValue> => {
+ const json = await request(url, { model: 'voice-enrollment', input });
+ if (json.code || !json.output || typeof json.output !== 'object' || Array.isArray(json.output))
+ throw new Error('invalid_voice_catalog');
+ return record(json.output);
+ };
+ try {
+ for (let page = 0; page < 10; page++) {
+ const output = await query({ action: 'list_voice', page_index: page, page_size: 100 });
+ if (!Array.isArray(output.voice_list)) throw new Error('invalid_voice_catalog');
+ const entries = output.voice_list;
+ for (const raw of entries.slice(0, 100)) {
+ const entry = record(raw);
+ const id = normalizeSpeechVoiceId(entry.voice_id);
+ if (!id || seen.has(id) || voices.has(id)) continue;
+ seen.add(id);
+ if (entry.status !== undefined && entry.status !== 'OK') continue;
+ if (typeof entry.target_model === 'string' && entry.target_model !== modelId) continue;
+ let metadata = entry;
+ if (!entry.target_model || !entry.status) {
+ // The total 15s deadline also covers these requests. Bound the fan-out
+ // independently of list size; unverified entries remain manual-only.
+ if (details >= 100) {
+ truncated = true;
+ continue;
+ }
+ details++;
+ metadata = await query({ action: 'query_voice', voice_id: id });
+ }
+ if (metadata.target_model !== modelId || metadata.status !== 'OK') continue;
+ if (voices.size >= 1000) {
+ truncated = true;
+ continue;
+ }
+ const name =
+ typeof entry.voice_name === 'string' ? entry.voice_name.trim().slice(0, 256) : '';
+ voices.set(id, { id, name: name || id });
+ }
+ if (entries.length < 100) break;
+ if (entries.length > 100 || page === 9 || voices.size >= 1000) {
+ truncated = true;
+ break;
+ }
+ }
+ } catch {
+ // Do not turn an ownership/credential change into a successful fallback with
+ // private results. Provider failure alone leaves known public/verified voices.
+ assertCurrent();
+ customVoicesUnavailable = true;
+ }
+ assertCurrent();
+ const custom = voices.size > system.length;
+ return {
+ voices: [...voices.values()],
+ source: system.length ? (custom ? 'mixed' : 'reference') : custom ? 'provider' : 'manual',
+ ...(truncated ? { truncated: true } : {}),
+ ...(customVoicesUnavailable ? { customVoicesUnavailable: true } : {}),
+ };
+}
diff --git a/apps/desktop/src/main/voice-conversation/voices.ts b/apps/desktop/src/main/voice-conversation/voices.ts
index 6626eca9f6..407f8c18f4 100644
--- a/apps/desktop/src/main/voice-conversation/voices.ts
+++ b/apps/desktop/src/main/voice-conversation/voices.ts
@@ -4,6 +4,8 @@ import {
type SpeechVoice,
} from '../../shared/voiceConversation.js';
import { referenceSpeechVoices } from '../../shared/speechVoices.js';
+import { alibabaSystemVoices } from '../../shared/alibabaSpeechVoices.js';
+import { loadDashscopeVoices } from './dashscopeVoices.js';
import type { SpeechConnection } from './speech.js';
type RecordValue = Record<string, unknown>;
@@ -51,11 +53,14 @@ export async function loadSpeechVoices(
assertCurrent: () => void,
): Promise<SpeechVoiceCatalog> {
assertCurrent();
- if (['openai', 'qwen-tts', 'dashscope-tts'].includes(connection.protocol)) {
- const voices = referenceSpeechVoices(modelId, connection.protocol).map((id) => ({
- id,
- name: id,
- }));
+ if (connection.protocol === 'openai' || connection.protocol === 'qwen-tts') {
+ const voices =
+ connection.protocol === 'qwen-tts'
+ ? alibabaSystemVoices(modelId, connection.protocol, connection.baseUrl)
+ : referenceSpeechVoices(modelId, connection.protocol).map((id) => ({
+ id,
+ name: id,
+ }));
return { source: voices.length ? 'reference' : 'manual', voices };
}
const controller = new AbortController();
@@ -70,6 +75,7 @@ export async function loadSpeechVoices(
};
const request = async (url: URL, body?: unknown): Promise<RecordValue> => {
assertCurrent();
+ controller.signal.throwIfAborted();
const response = await fetcher(url.toString(), {
method: body ? 'POST' : 'GET',
headers: { ...connection.headers, ...(body ? { 'content-type': 'application/json' } : {}) },
@@ -83,6 +89,8 @@ export async function loadSpeechVoices(
};
try {
const base = connection.baseUrl.replace(/\/+$/, '');
+ if (connection.protocol === 'dashscope-tts')
+ return await loadDashscopeVoices(modelId, base, request, assertCurrent);
if (connection.protocol === 'minimax') {
// https://platform.minimax.io/docs/api-reference/voice-management-get
const json = await request(new URL(`${base}/get_voice`), { voice_type: 'all' });
diff --git a/apps/desktop/src/renderer/features/bots/voice/SpeechVoicePicker.tsx b/apps/desktop/src/renderer/features/bots/voice/SpeechVoicePicker.tsx
index f75b97e92b..3f94659a2c 100644
--- a/apps/desktop/src/renderer/features/bots/voice/SpeechVoicePicker.tsx
+++ b/apps/desktop/src/renderer/features/bots/voice/SpeechVoicePicker.tsx
@@ -76,21 +76,26 @@ export function SpeechVoicePicker({
() => readSpeechVoiceLabel(owner, botId, selectionRouteKey, voice),
[owner, botId, selectionRouteKey, voice, catalog],
);
- // A saved label bridges initial loading and offline re-entry. A successful
- // response is authoritative for display, but never changes the saved ID.
- const showCachedLabel = !!cachedLabel && !catalog && (initialLoading || failed);
+ // A partial private lookup is not evidence that the saved voice was removed.
+ // Keep its known label as well as the public choices, without changing the ID.
+ const showCachedLabel =
+ !!cachedLabel &&
+ !listed &&
+ ((!catalog && (initialLoading || failed)) || !!catalog?.customVoicesUnavailable);
const showManual =
manual ||
(!initialLoading && !showCachedLabel && ((!!voice && !listed) || !catalog?.voices.length));
const catalogHint = failed
? t('bots.voiceMode.voicesError')
- : catalog?.source === 'reference'
- ? t('bots.voiceMode.voicesReference')
+ : catalog?.customVoicesUnavailable
+ ? t('bots.voiceMode.voicesCustomError')
: catalog?.truncated
? t('bots.voiceMode.voicesTruncated')
- : !initialLoading && !catalog?.voices.length
- ? t('bots.voiceMode.voicesManual')
- : '';
+ : catalog?.source === 'reference' || catalog?.source === 'mixed'
+ ? t('bots.voiceMode.voicesReference')
+ : !initialLoading && !catalog?.voices.length
+ ? t('bots.voiceMode.voicesManual')
+ : '';
const voiceOptions = useMemo(() => {
const voices = (catalog?.voices ?? []).map((item) => ({
...item,
@@ -154,13 +159,9 @@ export function SpeechVoicePicker({
useEffect(() => {
if (currentCatalog?.phase !== 'ready' || !catalog || !voice) return;
- rememberSpeechVoiceLabel(
- owner,
- botId,
- selectionRouteKey,
- voice,
- voiceOptions.find((option) => option.value === `voice:${voice}`)?.label,
- );
+ const label = voiceOptions.find((option) => option.value === `voice:${voice}`)?.label;
+ if (catalog.customVoicesUnavailable && !label) return;
+ rememberSpeechVoiceLabel(owner, botId, selectionRouteKey, voice, label);
}, [owner, botId, selectionRouteKey, voice, currentCatalog, catalog, voiceOptions]);
useEffect(() => {
@@ -207,7 +208,7 @@ export function SpeechVoicePicker({
}
options={[
...(showCachedLabel
- ? [{ value: `voice:${voice}`, label: cachedLabel! }]
+ ? [{ value: `voice:${voice}`, label: cachedLabel! }, ...voiceOptions]
: initialLoading
? [{ value: LOADING, label: t('bots.voiceMode.voicesLoading'), disabled: true }]
: voiceOptions),
diff --git a/apps/desktop/src/renderer/features/bots/voice/__tests__/CompanionVoiceSettings.test.tsx b/apps/desktop/src/renderer/features/bots/voice/__tests__/CompanionVoiceSettings.test.tsx
index 2930231645..89b58b218e 100644
--- a/apps/desktop/src/renderer/features/bots/voice/__tests__/CompanionVoiceSettings.test.tsx
+++ b/apps/desktop/src/renderer/features/bots/voice/__tests__/CompanionVoiceSettings.test.tsx
@@ -927,6 +927,98 @@ it('shows the last selected label on re-entry, refreshes renamed voices, and ret
expect(audio.start).not.toHaveBeenCalled();
});
+// Unit tier: a partial private catalog is still a usable public catalog, but may
+// omit the saved custom ID. Refresh must not silently select the first system voice.
+it('keeps the saved custom ID and usable system choices after private discovery fails', async () => {
+ models = [
+ {
+ id: 'cosyvoice-v3-flash',
+ name: 'CosyVoice',
+ providerId: 'mine',
+ agent: 'codex',
+ protocol: 'dashscope-tts',
+ },
+ ];
+ vi.mocked(window.electronAPI.voiceConversation.preference).mockResolvedValue({
+ selection: {
+ providerId: 'mine',
+ agent: 'codex',
+ modelId: 'cosyvoice-v3-flash',
+ voice: 'my-clone',
+ },
+ customized: true,
+ });
+ vi.mocked(window.electronAPI.voiceConversation.voices).mockResolvedValue({
+ source: 'reference',
+ customVoicesUnavailable: true,
+ voices: [
+ { id: 'longanyang', name: '龙安洋' },
+ { id: 'longanhuan', name: '龙安欢' },
+ ],
+ });
+ renderSettings();
+ await screen.findByText('bots.voiceMode.voicesCustomError');
+ expect((screen.getByLabelText('bots.voiceMode.voiceId') as HTMLInputElement).value).toBe(
+ 'my-clone',
+ );
+ const menu = await openVoices();
+ expect(menu.getByRole('button', { name: '龙安欢' })).toBeTruthy();
+ closeVoices();
+ fireEvent.click(screen.getByRole('button', { name: 'bots.voiceMode.refreshVoices' }));
+ await waitFor(() => expect(window.electronAPI.voiceConversation.voices).toHaveBeenCalledTimes(2));
+ expect(window.electronAPI.voiceConversation.setPreference).not.toHaveBeenCalled();
+ expect(window.electronAPI.voiceConversation.preview).not.toHaveBeenCalled();
+});
+
+it('retains the selected custom name and public options when a refresh returns a partial catalog', async () => {
+ models = [
+ {
+ id: 'cosyvoice-v3-flash',
+ name: 'CosyVoice',
+ providerId: 'mine',
+ agent: 'codex',
+ protocol: 'dashscope-tts',
+ },
+ ];
+ vi.mocked(window.electronAPI.voiceConversation.preference).mockResolvedValue({
+ selection: {
+ providerId: 'mine',
+ agent: 'codex',
+ modelId: 'cosyvoice-v3-flash',
+ voice: 'my-clone',
+ },
+ customized: true,
+ });
+ vi.mocked(window.electronAPI.voiceConversation.voices)
+ .mockResolvedValueOnce({
+ source: 'mixed',
+ voices: [
+ { id: 'my-clone', name: 'My Voice' },
+ { id: 'longanyang', name: '龙安洋' },
+ ],
+ })
+ .mockResolvedValue({
+ source: 'reference',
+ customVoicesUnavailable: true,
+ voices: [{ id: 'longanyang', name: '龙安洋' }],
+ });
+ const first = renderSettings();
+ await screen.findByText('My Voice');
+ fireEvent.click(screen.getByRole('button', { name: 'bots.voiceMode.refreshVoices' }));
+ await screen.findByText('bots.voiceMode.voicesCustomError');
+ expect(voicePicker().textContent).toBe('My Voice');
+ expect(screen.queryByLabelText('bots.voiceMode.voiceId')).toBeNull();
+ const menu = await openVoices();
+ expect(menu.getByRole('button', { name: '龙安洋' })).toBeTruthy();
+ expect(menu.getByRole('button', { name: 'My Voice' })).toBeTruthy();
+ first.unmount();
+ renderSettings();
+ await screen.findByText('bots.voiceMode.voicesCustomError');
+ expect(voicePicker().textContent).toBe('My Voice');
+ expect(window.electronAPI.voiceConversation.setPreference).not.toHaveBeenCalled();
+ expect(window.electronAPI.voiceConversation.preview).not.toHaveBeenCalled();
+});
+
it('does not display or cache a late catalog from the previous account', async () => {
models = [
{ id: 'speech', name: 'Speech', providerId: 'mine', agent: 'codex', protocol: 'elevenlabs' },
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index be2828e9e8..255079dafc 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -10193,6 +10193,7 @@
"refreshVoices": "Refresh voices",
"voicesLoading": "Loading voices…",
"voicesError": "Couldn't load voices. Retry or enter a voice ID.",
+ "voicesCustomError": "Couldn’t load all custom voices. Retry or enter a voice ID.",
"voicesReference": "These are reference voices for this model. Compatible services may support different voices.",
"voicesTruncated": "Showing part of the voice list. Enter an ID to use an unlisted voice.",
"voicesManual": "No voice list is available for this interface. Enter a voice ID.",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index 998191522c..9d66b51893 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -10153,6 +10153,7 @@
"refreshVoices": "音声リストを更新",
"voicesLoading": "音声を取得中…",
"voicesError": "音声を取得できませんでした。再試行するか、音声 ID を入力してください。",
+ "voicesCustomError": "カスタム音声をすべて取得できませんでした。再試行するか、音声 ID を入力してください。",
"voicesReference": "このモデルの参考音声です。互換サービスで使える音声は異なる場合があります。",
"voicesTruncated": "音声リストの一部を表示しています。未掲載の音声は ID を入力してください。",
"voicesManual": "このインターフェースには音声リストがありません。音声 ID を入力してください。",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index db92d4023a..d3998bdfab 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -10153,6 +10153,7 @@
"refreshVoices": "음성 목록 새로고침",
"voicesLoading": "음성 불러오는 중…",
"voicesError": "음성을 불러오지 못했습니다. 다시 시도하거나 음성 ID를 입력하세요.",
+ "voicesCustomError": "사용자 지정 음성을 모두 불러오지 못했습니다. 다시 시도하거나 음성 ID를 입력하세요.",
"voicesReference": "이 모델의 참고 음성입니다. 호환 서비스에서 지원하는 음성은 다를 수 있습니다.",
"voicesTruncated": "음성 목록의 일부만 표시합니다. 목록에 없는 음성은 ID를 입력하세요.",
"voicesManual": "이 인터페이스에는 음성 목록이 없습니다. 음성 ID를 입력하세요.",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index 3de53b4a32..32c3e448d5 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -10153,6 +10153,7 @@
"refreshVoices": "刷新音色列表",
"voicesLoading": "正在获取音色…",
"voicesError": "未能获取音色列表。可重试,或手动输入音色 ID。",
+ "voicesCustomError": "未能完整获取自定义音色。可重试,或手动输入音色 ID。",
"voicesReference": "这是该型号的参考音色;兼容服务的实际支持可能不同。",
"voicesTruncated": "仅显示部分音色;未列出的音色可手动输入 ID。",
"voicesManual": "此接口没有可用的音色列表,请手动输入音色 ID。",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
index 39d131d596..c2da68984e 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -10153,6 +10153,7 @@
"refreshVoices": "重新整理音色清單",
"voicesLoading": "正在取得音色…",
"voicesError": "無法取得音色清單。請重試,或手動輸入音色 ID。",
+ "voicesCustomError": "無法完整取得自訂音色。請重試,或手動輸入音色 ID。",
"voicesReference": "這是此型號的參考音色;相容服務的實際支援可能不同。",
"voicesTruncated": "僅顯示部分音色;未列出的音色可手動輸入 ID。",
"voicesManual": "此介面沒有可用的音色清單,請手動輸入音色 ID。",
diff --git a/apps/desktop/src/shared/alibabaSpeechVoices.ts b/apps/desktop/src/shared/alibabaSpeechVoices.ts
new file mode 100644
index 0000000000..849276f285
--- /dev/null
+++ b/apps/desktop/src/shared/alibabaSpeechVoices.ts
@@ -0,0 +1,377 @@
+import type { SpeechProtocol, SpeechVoice } from './voiceConversation.js';
+
+/** Public system voice IDs/names only, checked 2026-10-21. Keep exact model IDs and
+ * case-sensitive voice IDs; do not copy descriptions, sample URLs or account voices.
+ * Sources: https://help.aliyun.com/zh/model-studio/qwen-tts-voice-list
+ * https://help.aliyun.com/zh/model-studio/cosyvoice-voice-list
+ * https://help.aliyun.com/zh/model-studio/qwen-audio-tts-voice-list
+ * The separate downloadable basic-voice packs are not system voice catalogs.
+ * CosyVoice 3.5 has no system voices; its account voices are discovered in Main.
+ */
+type SystemVoice = readonly [id: string, name: string, region?: 'beijing'];
+const SYSTEM_VOICES: Readonly<Record<string, readonly SystemVoice[]>> = {
+ 'qwen3-tts-flash': [
+ ['Cherry', '芊悦'],
+ ['Serena', '苏瑶'],
+ ['Ethan', '晨煦'],
+ ['Chelsie', '千雪'],
+ ['Momo', '茉兔'],
+ ['Vivian', '十三'],
+ ['Moon', '月白'],
+ ['Maia', '四月'],
+ ['Kai', '凯'],
+ ['Nofish', '不吃鱼'],
+ ['Bella', '萌宝'],
+ ['Jennifer', '詹妮弗'],
+ ['Ryan', '甜茶'],
+ ['Katerina', '卡捷琳娜'],
+ ['Aiden', '艾登'],
+ ['Eldric Sage', '沧明子'],
+ ['Mia', '乖小妹'],
+ ['Mochi', '沙小弥'],
+ ['Bellona', '燕铮莺'],
+ ['Vincent', '田叔'],
+ ['Bunny', '萌小姬'],
+ ['Neil', '阿闻'],
+ ['Elias', '墨讲师'],
+ ['Arthur', '徐大爷'],
+ ['Nini', '邻家妹妹'],
+ ['Seren', '小婉'],
+ ['Pip', '顽屁小孩'],
+ ['Stella', '少女阿月'],
+ ['Bodega', '博德加'],
+ ['Sonrisa', '索尼莎'],
+ ['Alek', '阿列克'],
+ ['Dolce', '多尔切'],
+ ['Sohee', '素熙'],
+ ['Ono Anna', '小野杏'],
+ ['Lenn', '莱恩'],
+ ['Emilien', '埃米尔安'],
+ ['Andre', '安德雷'],
+ ['Radio Gol', '拉迪奥·戈尔'],
+ ['Jada', '上海-阿珍'],
+ ['Dylan', '北京-晓东'],
+ ['Li', '南京-老李'],
+ ['Marcus', '陕西-秦川'],
+ ['Roy', '闽南-阿杰'],
+ ['Peter', '天津-李彼得'],
+ ['Sunny', '四川-晴儿'],
+ ['Eric', '四川-程川'],
+ ['Rocky', '粤语-阿强'],
+ ['Kiki', '粤语-阿清'],
+ ],
+ 'cosyvoice-v3-flash': [
+ ['longanyang', '龙安洋'],
+ ['longanhuan_v3', '龙安欢(V3)', 'beijing'],
+ ['longanhuan', '龙安欢'],
+ ['longhuhu_v3', '龙呼呼'],
+ ['longpaopao_v3', '龙泡泡', 'beijing'],
+ ['longjielidou_v3', '龙杰力豆'],
+ ['longxian_v3', '龙仙', 'beijing'],
+ ['longling_v3', '龙铃', 'beijing'],
+ ['longshanshan_v3', '龙闪闪'],
+ ['longniuniu_v3', '龙牛牛'],
+ ['longjiaxin_v3', '龙嘉欣', 'beijing'],
+ ['longjiayi_v3', '龙嘉怡', 'beijing'],
+ ['longanyue_v3', '龙安粤'],
+ ['longlaotie_v3', '龙老铁', 'beijing'],
+ ['longshange_v3', '龙陕哥'],
+ ['longanmin_v3', '龙安闽'],
+ ['loongkyong_v3', 'loongkyong', 'beijing'],
+ ['loongriko_v3', 'Riko', 'beijing'],
+ ['loongtomoka_v3', 'loongtomoka', 'beijing'],
+ ['loongabby_v3', 'loongabby', 'beijing'],
+ ['loongandy_v3', 'loongandy'],
+ ['loongannie_v3', 'loongannie', 'beijing'],
+ ['loongava_v3', 'loongava', 'beijing'],
+ ['loongbeth_v3', 'loongbeth', 'beijing'],
+ ['loongbetty_v3', 'loongbetty', 'beijing'],
+ ['loongcally_v3', 'loongcally', 'beijing'],
+ ['loongcindy_v3', 'loongcindy', 'beijing'],
+ ['loongdavid_v3', 'loongdavid', 'beijing'],
+ ['loongdonna_v3', 'loongdonna', 'beijing'],
+ ['loongemily_v3', 'loongemily', 'beijing'],
+ ['loongeric_v3', 'loongeric', 'beijing'],
+ ['loongluna_v3', 'loongluna', 'beijing'],
+ ['loongluca_v3', 'loongluca', 'beijing'],
+ ['loongtomoya_v3', 'loongtomoya', 'beijing'],
+ ['loongyuuna_v3', 'Yuuna', 'beijing'],
+ ['loongyuuma_v3', 'Yuuma', 'beijing'],
+ ['loongjihun_v3', 'Jihun', 'beijing'],
+ ['loongindah_v3', 'loongindah'],
+ ['longfei_v3', '龙飞', 'beijing'],
+ ['longyingxiao_v3', '龙应笑'],
+ ['longyingxun_v3', '龙应询'],
+ ['longyingjing_v3', '龙应静', 'beijing'],
+ ['longyingling_v3', '龙应聆', 'beijing'],
+ ['longyingtao_v3', '龙应桃'],
+ ['longxiaochun_v3', '龙小淳', 'beijing'],
+ ['longxiaoxia_v3', '龙小夏', 'beijing'],
+ ['longyumi_v3', 'YUMI', 'beijing'],
+ ['longanyun_v3', '龙安昀'],
+ ['longanwen_v3', '龙安温'],
+ ['longanli_v3', '龙安莉'],
+ ['longanlang_v3', '龙安朗'],
+ ['longyingmu_v3', '龙应沐'],
+ ['longantai_v3', '龙安台', 'beijing'],
+ ['longhua_v3', '龙华'],
+ ['longcheng_v3', '龙橙', 'beijing'],
+ ['longze_v3', '龙泽', 'beijing'],
+ ['longzhe_v3', '龙哲', 'beijing'],
+ ['longyan_v3', '龙颜', 'beijing'],
+ ['longxing_v3', '龙星', 'beijing'],
+ ['longtian_v3', '龙天', 'beijing'],
+ ['longwan_v3', '龙婉'],
+ ['longqiang_v3', '龙嫱', 'beijing'],
+ ['longfeifei_v3', '龙菲菲', 'beijing'],
+ ['longhao_v3', '龙浩', 'beijing'],
+ ['longanrou_v3', '龙安柔', 'beijing'],
+ ['longhan_v3', '龙寒', 'beijing'],
+ ['longanzhi_v3', '龙安智'],
+ ['longanling_v3', '龙安灵', 'beijing'],
+ ['longanya_v3', '龙安雅'],
+ ['longanqin_v3', '龙安亲'],
+ ['longmiao_v3', '龙妙', 'beijing'],
+ ['longsanshu_v3', '龙三叔', 'beijing'],
+ ['longyuan_v3', '龙媛', 'beijing'],
+ ['longyue_v3', '龙悦', 'beijing'],
+ ['longxiu_v3', '龙修', 'beijing'],
+ ['longnan_v3', '龙楠', 'beijing'],
+ ['longwanjun_v3', '龙婉君'],
+ ['longyichen_v3', '龙逸尘'],
+ ['longlaobo_v3', '龙老伯'],
+ ['longlaoyi_v3', '龙老姨'],
+ ['longjiqi_v3', '龙机器'],
+ ['longhouge_v3', '龙猴哥'],
+ ['longdaiyu_v3', '龙黛玉'],
+ ['longanran_v3', '龙安燃', 'beijing'],
+ ['longanxuan_v3', '龙安宣'],
+ ['longshuo_v3', '龙硕', 'beijing'],
+ ['longshu_v3', '龙书', 'beijing'],
+ ['loongbella_v3', 'Bella3.0', 'beijing'],
+ ],
+ 'cosyvoice-v3-plus': [
+ ['longanyang', '龙安洋'],
+ ['longanhuan', '龙安欢'],
+ ],
+ 'cosyvoice-v2': [
+ ['longyingxiao', '龙应笑', 'beijing'],
+ ['longjiqi', '龙机器', 'beijing'],
+ ['longhouge', '龙猴哥', 'beijing'],
+ ['longjixin', '龙机心', 'beijing'],
+ ['longanyue', '龙安粤', 'beijing'],
+ ['longshange', '龙陕哥', 'beijing'],
+ ['longanmin', '龙安敏', 'beijing'],
+ ['longdaiyu', '龙黛玉', 'beijing'],
+ ['longgaoseng', '龙高僧', 'beijing'],
+ ['longanli', '龙安莉', 'beijing'],
+ ['longanlang', '龙安朗', 'beijing'],
+ ['longanwen', '龙安温', 'beijing'],
+ ['longanyun', '龙安昀', 'beijing'],
+ ['longyumi_v2', 'YUMI', 'beijing'],
+ ['longxiaochun_v2', '龙小淳', 'beijing'],
+ ['longxiaoxia_v2', '龙小夏', 'beijing'],
+ ['longyichen', '龙逸尘', 'beijing'],
+ ['longwanjun', '龙婉君', 'beijing'],
+ ['longlaobo', '龙老伯', 'beijing'],
+ ['longlaoyi', '龙老姨', 'beijing'],
+ ['longbaizhi', '龙白芷', 'beijing'],
+ ['longsanshu', '龙三叔', 'beijing'],
+ ['longxiu_v2', '龙修', 'beijing'],
+ ['longmiao_v2', '龙妙', 'beijing'],
+ ['longyue_v2', '龙悦', 'beijing'],
+ ['longnan_v2', '龙楠', 'beijing'],
+ ['longyuan_v2', '龙媛', 'beijing'],
+ ['longanqin', '龙安亲', 'beijing'],
+ ['longanya', '龙安雅', 'beijing'],
+ ['longanshuo', '龙安朔', 'beijing'],
+ ['longanling', '龙安灵', 'beijing'],
+ ['longanzhi', '龙安智', 'beijing'],
+ ['longanrou', '龙安柔', 'beijing'],
+ ['longqiang_v2', '龙嫱', 'beijing'],
+ ['longhan_v2', '龙寒', 'beijing'],
+ ['longxing_v2', '龙星', 'beijing'],
+ ['longhua_v2', '龙华', 'beijing'],
+ ['longwan_v2', '龙婉', 'beijing'],
+ ['longcheng_v2', '龙橙', 'beijing'],
+ ['longfeifei_v2', '龙菲菲', 'beijing'],
+ ['longxiaocheng_v2', '龙小诚', 'beijing'],
+ ['longzhe_v2', '龙哲', 'beijing'],
+ ['longyan_v2', '龙颜', 'beijing'],
+ ['longtian_v2', '龙天', 'beijing'],
+ ['longze_v2', '龙泽', 'beijing'],
+ ['longshao_v2', '龙邵', 'beijing'],
+ ['longhao_v2', '龙浩', 'beijing'],
+ ['kabuleshen_v2', '龙深', 'beijing'],
+ ['longhuhu', '龙呼呼', 'beijing'],
+ ['longanpei', '龙安培', 'beijing'],
+ ['longwangwang', '龙汪汪', 'beijing'],
+ ['longpaopao', '龙泡泡', 'beijing'],
+ ['longshanshan', '龙闪闪', 'beijing'],
+ ['longniuniu', '龙牛牛', 'beijing'],
+ ['longyingmu', '龙应沐', 'beijing'],
+ ['longyingxun', '龙应询', 'beijing'],
+ ['longyingcui', '龙应催', 'beijing'],
+ ['longyingda', '龙应答', 'beijing'],
+ ['longyingjing', '龙应静', 'beijing'],
+ ['longyingyan', '龙应严', 'beijing'],
+ ['longyingtian', '龙应甜', 'beijing'],
+ ['longyingbing', '龙应冰', 'beijing'],
+ ['longyingtao', '龙应桃', 'beijing'],
+ ['longyingling', '龙应聆', 'beijing'],
+ ['longanran', '龙安燃', 'beijing'],
+ ['longanxuan', '龙安宣', 'beijing'],
+ ['longanchong', '龙安冲', 'beijing'],
+ ['longanping', '龙安萍', 'beijing'],
+ ['longjielidou_v2', '龙杰力豆', 'beijing'],
+ ['longling_v2', '龙铃', 'beijing'],
+ ['longke_v2', '龙可', 'beijing'],
+ ['longxian_v2', '龙仙', 'beijing'],
+ ['longlaotie_v2', '龙老铁', 'beijing'],
+ ['longjiayi_v2', '龙嘉怡', 'beijing'],
+ ['longtao_v2', '龙桃', 'beijing'],
+ ['longfei_v2', '龙飞', 'beijing'],
+ ['libai_v2', '李白', 'beijing'],
+ ['longjin_v2', '龙津', 'beijing'],
+ ['longshu_v2', '龙书', 'beijing'],
+ ['loongbella_v2', 'Bella2.0', 'beijing'],
+ ['longshuo_v2', '龙硕', 'beijing'],
+ ['longxiaobai_v2', '龙小白', 'beijing'],
+ ['longjing_v2', '龙婧', 'beijing'],
+ ['loongstella_v2', 'loongstella', 'beijing'],
+ ['loongyuuna_v2', 'loongyuuna', 'beijing'],
+ ['loongyuuma_v2', 'loongyuuma', 'beijing'],
+ ['loongjihun_v2', 'loongjihun', 'beijing'],
+ ['loongeva_v2', 'loongeva', 'beijing'],
+ ['loongbrian_v2', 'loongbrian', 'beijing'],
+ ['loongluna_v2', 'loongluna', 'beijing'],
+ ['loongluca_v2', 'loongluca', 'beijing'],
+ ['loongemily_v2', 'loongemily', 'beijing'],
+ ['loongeric_v2', 'loongeric', 'beijing'],
+ ['loongabby_v2', 'loongabby', 'beijing'],
+ ['loongannie_v2', 'loongannie', 'beijing'],
+ ['loongandy_v2', 'loongandy', 'beijing'],
+ ['loongava_v2', 'loongava', 'beijing'],
+ ['loongbeth_v2', 'loongbeth', 'beijing'],
+ ['loongbetty_v2', 'loongbetty', 'beijing'],
+ ['loongcindy_v2', 'loongcindy', 'beijing'],
+ ['loongcally_v2', 'loongcally', 'beijing'],
+ ['loongdavid_v2', 'loongdavid', 'beijing'],
+ ['loongdonna_v2', 'loongdonna', 'beijing'],
+ ['loongkyong_v2', 'loongkyong', 'beijing'],
+ ['loongtomoka_v2', 'loongtomoka', 'beijing'],
+ ['loongtomoya_v2', 'loongtomoya', 'beijing'],
+ ],
+ 'qwen-audio-3.1-tts-flash': [
+ ['longanhuan_v3.1', '龙安欢_v3.1'],
+ ['longanlingxin_v3.1', '龙安灵心_v3.1'],
+ ['longanfengyue_v3.1', '龙安风悦_v3.1'],
+ ['xunanchuan_v3.1', '许南川'],
+ ['yuxiaoyun_v3.1', '于小云', 'beijing'],
+ ['qiaoxiaojiao_v3.1', '乔小娇', 'beijing'],
+ ['xiaxiaochen_v3.1', '夏小晨', 'beijing'],
+ ['anmingyuan_v3.1', '安明远', 'beijing'],
+ ['wenhuaiqing_v3.1', '温怀清', 'beijing'],
+ ['anxiaolan_v3.1', '安小岚', 'beijing'],
+ ['xieshurou_v3.1', '谢舒柔', 'beijing'],
+ ['baiqinglan_v3.1', '白清岚', 'beijing'],
+ ['xuyuyuan_v3.1', '许玉远', 'beijing'],
+ ['anruorou_v3.1', '安若柔', 'beijing'],
+ ['wenhuaizhi_v3.1', '闻怀之', 'beijing'],
+ ['xiaoxingzhi_v3.1', '萧行之', 'beijing'],
+ ['guyunshu_v3.1', '顾云舒', 'beijing'],
+ ['huozhuoshi_v3.1', '霍拙石', 'beijing'],
+ ['yeqinghe_v3.1', '叶清禾', 'beijing'],
+ ['yunhuanhuan_v3.1', '云欢欢', 'beijing'],
+ ['xuxiaoqiao_v3.1', '徐小俏', 'beijing'],
+ ['baianran_v3.1', '白安然', 'beijing'],
+ ['xuyanchu_v3.1', '许言初', 'beijing'],
+ ['yezhiqing_v3.1', '叶知晴', 'beijing'],
+ ['andi_v3.1', '安迪', 'beijing'],
+ ['anyuqing_v3.1', '安语晴', 'beijing'],
+ ['Emily_v3.1', 'Emily'],
+ ['Luna_v3.1', 'Luna'],
+ ['Eric_v3.1', 'Eric'],
+ ['Luca_v3.1', 'Luca'],
+ ['Abby_v3.1', 'Abby'],
+ ['Annie_v3.1', 'Annie'],
+ ['Ava_v3.1', 'Ava'],
+ ['Beth_v3.1', 'Beth'],
+ ['Betty_v3.1', 'Betty'],
+ ['Cally_v3.1', 'Cally'],
+ ['Cindy_v3.1', 'Cindy'],
+ ['Donna_v3.1', 'Donna'],
+ ['Andy_v3.1', 'Andy'],
+ ['Brian_v3.1', 'Brian'],
+ ['David_v3.1', 'David'],
+ ['longanyuanfei_v3.1', '龙安元妃_v3.1', 'beijing'],
+ ['longjielidou_v3.1', '龙杰力豆_v3.1', 'beijing'],
+ ['longanlingxi_v3.1', '龙安灵希_v3.1', 'beijing'],
+ ['longhuohuo_v3.1', '龙火火_v3.1', 'beijing'],
+ ['longyingtao_v3.1', '龙应桃_v3.1', 'beijing'],
+ ['longanya_v3.1', '龙安雅_v3.1', 'beijing'],
+ ['longwan_v3.1', '龙婉_v3.1', 'beijing'],
+ ['longxing_v3.1', '龙星_v3.1', 'beijing'],
+ ['longhua_v3.1', '龙华_v3.1', 'beijing'],
+ ['longhan_v3.1', '龙寒_v3.1', 'beijing'],
+ ['longanzhi_v3.1', '龙安智_v3.1', 'beijing'],
+ ['longzhe_v3.1', '龙哲_v3.1', 'beijing'],
+ ['longanyang_v3.1', '龙安洋_v3.1', 'beijing'],
+ ['libai_v3.1', '李白_v3.1', 'beijing'],
+ ['longling_v3.1', '龙铃_v3.1', 'beijing'],
+ ['longniuniu_v3.1', '龙牛牛_v3.1', 'beijing'],
+ ['longshanshan_v3.1', '龙闪闪_v3.1', 'beijing'],
+ ['longpaopao_v3.1', '龙泡泡_v3.1', 'beijing'],
+ ['loongstella_v3.1', 'loongstella_v3.1', 'beijing'],
+ ['longyuan_v3.1', '龙媛_v3.1', 'beijing'],
+ ['longmiao_v3.1', '龙妙_v3.1', 'beijing'],
+ ['longsanshu_v3.1', '龙三叔_v3.1', 'beijing'],
+ ['longanli_v3.1', '龙安莉_v3.1', 'beijing'],
+ ['longanwen_v3.1', '龙安温_v3.1', 'beijing'],
+ ['longanlang_v3.1', '龙安朗_v3.1', 'beijing'],
+ ['longxiaoxia_v3.1', '龙小夏_v3.1', 'beijing'],
+ ['longanchong_v3.1', '龙安冲_v3.1', 'beijing'],
+ ],
+ 'qwen-audio-3.0-tts-plus': [
+ ['longanlingxin', '龙安灵心'],
+ ['longanlufeng', '龙安鲁风'],
+ ],
+ 'qwen-audio-3.0-tts-flash': [
+ ['longanfengyue', '龙安风悦'],
+ ['longanyuanfei', '龙安元妃'],
+ ['longanlingxi', '龙安灵希'],
+ ['longanxiaoxin', '龙安小昕'],
+ ['longanhuan_v3.6', '龙安欢'],
+ ['longjielidou_v3.6', '龙杰力豆'],
+ ['longpaopao_v3.6', '龙泡泡'],
+ ['longhuohuo_v3.6', '龙火火'],
+ ['longchuanshu_v3.6', '龙川叔'],
+ ['loongmary', 'loongmary'],
+ ['loongeva_v3.6', 'loongeva'],
+ ['loongjohn', 'loongJohn'],
+ ],
+};
+
+function regionForEndpoint(baseUrl?: string): 'beijing' | 'singapore' | undefined {
+ if (!baseUrl) return undefined;
+ const hostname = new URL(baseUrl).hostname;
+ if (hostname === 'dashscope.aliyuncs.com') return 'beijing';
+ if (hostname === 'dashscope-intl.aliyuncs.com') return 'singapore';
+ const workspace = /^[a-z0-9-]+\.(cn-beijing|ap-southeast-1)\.maas\.aliyuncs\.com$/.exec(hostname);
+ return workspace ? (workspace[1] === 'cn-beijing' ? 'beijing' : 'singapore') : undefined;
+}
+
+/** Unknown proxy locations retain the model's reference set, without guessing a
+ * region or changing the selected connection. A reference never proves execution.
+ */
+export function alibabaSystemVoices(
+ modelId: string,
+ protocol: SpeechProtocol,
+ baseUrl?: string,
+): SpeechVoice[] {
+ if (protocol !== (modelId === 'qwen3-tts-flash' ? 'qwen-tts' : 'dashscope-tts')) return [];
+ const region = regionForEndpoint(baseUrl);
+ return (SYSTEM_VOICES[modelId] ?? [])
+ .filter(([, , onlyRegion]) => !region || !onlyRegion || region === onlyRegion)
+ .map(([id, name]) => ({ id, name }));
+}
diff --git a/apps/desktop/src/shared/speechVoices.ts b/apps/desktop/src/shared/speechVoices.ts
index 7403433900..da136d8ebd 100644
--- a/apps/desktop/src/shared/speechVoices.ts
+++ b/apps/desktop/src/shared/speechVoices.ts
@@ -1,4 +1,4 @@
-import { isQwenHttpModel } from './speechProtocols.js';
+import { alibabaSystemVoices } from './alibabaSpeechVoices.js';
import type { SpeechProtocol } from './voiceConversation.js';
// Model-specific reference lists, not a provider capability declaration. Compatible
@@ -25,15 +25,8 @@ export function referenceSpeechVoices(
modelId: string,
protocol?: SpeechProtocol,
): readonly string[] {
- // Model Studio reference examples, not account voice discovery. Custom/cloned
- // voices remain manual and must belong to the selected model and region.
- // https://www.alibabacloud.com/help/en/model-studio/non-realtime-tts-user-guide
- if (protocol === 'qwen-tts') return isQwenHttpModel(modelId) ? ['Cherry'] : [];
- if (protocol === 'dashscope-tts') {
- if (['cosyvoice-v3-plus', 'cosyvoice-v3-flash'].includes(modelId)) return ['longanyang'];
- if (modelId === 'qwen-audio-3.1-tts-flash') return ['longanhuan_v3.1'];
- return []; // Including CosyVoice 3.5: requires a voice bound to that model.
- }
+ if (protocol === 'qwen-tts' || protocol === 'dashscope-tts')
+ return alibabaSystemVoices(modelId, protocol).map(({ id }) => id);
if (protocol !== 'openai') return [];
if (/^gpt-4o-mini-tts(?:-\d{4}-\d{2}-\d{2})?$/.test(modelId)) return EXPRESSIVE;
if (/^tts-1(?:-hd)?(?:-1106)?$/.test(modelId)) return STANDARD;
diff --git a/apps/desktop/src/shared/voiceConversation.ts b/apps/desktop/src/shared/voiceConversation.ts
index fccfbf38d8..be14f67c74 100644
--- a/apps/desktop/src/shared/voiceConversation.ts
+++ b/apps/desktop/src/shared/voiceConversation.ts
@@ -69,8 +69,10 @@ export type SpeechVoice = { id: string; name: string };
export type SpeechVoiceCatalog = {
voices: SpeechVoice[];
/** References are model-specific suggestions, not proof a compatible proxy supports them. */
- source: 'provider' | 'reference' | 'manual';
+ source: 'provider' | 'reference' | 'mixed' | 'manual';
truncated?: boolean;
+ /** Public references and verified entries remain usable after a partial private lookup. */
+ customVoicesUnavailable?: boolean;
};
export type SpeechPreviewStart = VoiceConversationSelection & {
previewId: string;
diff --git a/docs/product-rules/companion-voice-mode.md b/docs/product-rules/companion-voice-mode.md
index 9ab9298eb0..dd6ebef970 100644
--- a/docs/product-rules/companion-voice-mode.md
+++ b/docs/product-rules/companion-voice-mode.md
@@ -76,12 +76,16 @@
- 配置沿用“模型供应商”中的连接、密钥和模型列表:已发现或手动添加并标记为“语音合成”的模型,才进入伙伴设置候选。型号资料不增加账户授权。自定义代理保留 API base 前缀,并可显式选择 `Qwen3-TTS (HTTP)` 或 `Qwen-Audio / CosyVoice (HTTP)`;代理必须实现选中的实际接口。无匹配协议时继续要求用户选择,不换 origin、地域或密钥。
- Qwen3 每个 HTTP 请求最多 600 字符:传输层按 UTF-16 长度保守切分,优先句子/空白边界且不切断代理对,不截断文本。播放拉取到上一段完成后才请求下一段;每段重新核查当前连接,取消、插话、账号变更或读取失败后不再请求剩余段。每段单独检查非空且 PCM 字节对齐。既有整次朗读大小、超时和播放背压上限继续生效。
- Qwen3 HTTP 没有已验证的语速参数,因此隐藏语速滑块,切换到它时不携带旧语速;Qwen-Audio / CosyVoice 支持 `0.5–2`,由 UI 与 Main 共用限制。输出统一为 PCM 24kHz 单声道,不改变播放器。
-- 当前只提供文档确认的参考音色:Qwen3 的 `Cherry`、Qwen-Audio 3.1 的 `longanhuan_v3.1`、CosyVoice v3 的 `longanyang`;未提供参考值的型号保留手动输入。CosyVoice v3.5 需填写绑定该型号的音色 ID。不查询私有克隆目录,不创建/删除音色,参考值不保证当前账户可执行。
+- 系统音色按官方目录、精确型号和已知地域收录,展示官方名称,选择与请求保留完整且区分大小写的 ID。Qwen3-TTS Flash 为 48 个;北京 CosyVoice v3-flash / v3-plus / v2 分别为 88 / 2 / 106 个;Qwen-Audio 3.1 Flash / 3.0 Plus / 3.0 Flash 分别为 68 / 2 / 12 个(2026-10-21 核对)。新加坡按文档排除仅北京的音色;自定义代理地域未知时保留该型号参考集并提示兼容服务支持可能不同。CosyVoice v3.5 没有系统音色。系统目录不包含另行下载的基础音色包,也不保证当前账户可执行。
+- Qwen-Audio / CosyVoice 使用当前连接 `<base>/services/audio/tts/customization` 的 `voice-enrollment` 查询自定义音色:`list_voice` 分页获取,缺少型号或状态时以 `query_voice` 补齐,只合并 `target_model` 精确匹配且状态为 `OK` 的音色,不按音色 ID 前缀猜测绑定。请求不换 origin、路径前缀、地域或密钥;最多 10 页、每页 100 条,额外详情查询最多 100 次,共用 15 秒总时限。达到上限提示手动输入,查询失败保留系统音色及本轮已核实的结果并提示重试。账号或连接变化仍丢弃所有结果,不将它当作可恢复的供应商故障。
+- Qwen3 标准 Flash 仅使用系统目录;不向它调用另一系列的自定义音色 API。所有查询均不创建、更新、删除或克隆音色,不下载返回的音频 URL,不传递音色设计提示词等私有元数据到 Renderer。所选 ID 与已有偏好不因刷新自动更改。
- SSE 共享有界分帧器,Base64 与 MiniMax hex 分别解码;业务错误、无结束标记、无效编码或空音频都按既有合成失败处理。音频只在内存中;最终 URL 不请求,不向它传递凭证。适配器仍是代码,不接受服务器下发请求模板。
- 这是客户端执行器与本地伙伴偏好的扩展:不修改公共 Registry、服务端 schema、Gateway 鉴权或模型下发;没有服务端合并顺序要求。不包含 Realtime/WebSocket 增量文本、音色克隆、语言/情绪/SSML 设置。真实供应商联调独立记录,单元测试与 UI 截图不代表账户授权或端到端语音验收。
契约来源(2026-10-21 核对):[Qwen3-TTS HTTP](https://www.alibabacloud.com/help/en/model-studio/qwen-tts-api)、[Qwen-Audio HTTP](https://www.alibabacloud.com/help/en/model-studio/qwen-audio-tts-http-api)、[CosyVoice HTTP](https://www.alibabacloud.com/help/en/model-studio/cosyvoice-tts-http-api)、[型号和地域](https://www.alibabacloud.com/help/en/model-studio/non-realtime-tts-user-guide)。
+音色目录来源:[Qwen3](https://help.aliyun.com/zh/model-studio/qwen-tts-voice-list)、[CosyVoice](https://help.aliyun.com/zh/model-studio/cosyvoice-voice-list)、[Qwen-Audio](https://help.aliyun.com/zh/model-studio/qwen-audio-tts-voice-list)、[账号音色查询契约](https://help.aliyun.com/zh/model-studio/voice-clone-design-http-api)。
+
## 音色目录与试听
- 音色菜单在悬停或键盘聚焦的行内提供试听按钮;准备和播放中的按钮保持可见并可停止。悬停/聚焦不请求语音,点击试听复用当前模型与语速,保持菜单打开且不改变已选音色;只有点击名称才保存。切换试听对象先停止上一段,关闭菜单(含 Escape/点外部)、改选音色、切换模型或离页均停止试听,复用既有取消与迟到结果保护。菜单由共享 Popover、菜单行和 Button 组成,选择与试听是同级按钮,支持方向键浏览、Tab 到试听及 Enter/Space 激活;不在 listbox option 内嵌交互按钮。菜单内保留试听状态和失败反馈,设置页不再重复展示独立试听区;手动音色在输入框旁保留试听/停止按钮及状态反馈,试听采用当前语速。