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。

fix(desktop): distinguish speech timeouts in voice mode

JiangJiahao6023e3aec6b2
diff --git a/apps/desktop/scripts/fixtures/voice-call/ui-page.mjs b/apps/desktop/scripts/fixtures/voice-call/ui-page.mjs
index d8373a9b59..ee53c1227f 100644
--- a/apps/desktop/scripts/fixtures/voice-call/ui-page.mjs
+++ b/apps/desktop/scripts/fixtures/voice-call/ui-page.mjs
@@ -24,6 +24,16 @@ export default {
about: 'Retained failed original appears once in the unified transcript',
data: { failed: true },
},
+ 'speech-timeout': {
+ about: 'Audio timeout explains stopped read-aloud and retained text at 320 px',
+ viewport: { width: 320, height: 900 },
+ data: { mode: 'speechTimeout' },
+ },
+ 'speech-error': {
+ about:
+ 'Unknown read-aloud failure retains the reply without prescribing configuration changes',
+ data: { mode: 'speech' },
+ },
empty: {
about: 'Ending an empty call leaves the existing conversation without a call card',
data: { empty: true },
@@ -100,7 +110,12 @@ export default {
// second paragraph/caption. These fixture originals are not translations.
const retained = transcript.getByText('还有一个想法,请先记下来。');
if (await retained.count()) assert.equal(await retained.count(), 1);
- else assert.equal(await transcript.getByText('听起来不错。').count(), 1);
+ else if (ui.data.mode === 'speech' || ui.data.mode === 'speechTimeout') {
+ assert.equal(
+ await page.getByRole('alert').textContent(),
+ await ui.t(`bots.voiceMode.errors.${ui.data.mode}`),
+ );
+ } else assert.equal(await transcript.getByText('听起来不错。').count(), 1);
await ui.capture('expanded');
if (ui.data.mode === 'long') {
await transcript.hover();
diff --git a/apps/desktop/scripts/fixtures/voice-call/voice-call-fixture.tsx b/apps/desktop/scripts/fixtures/voice-call/voice-call-fixture.tsx
index 9941663fa6..928d4e02a5 100644
--- a/apps/desktop/scripts/fixtures/voice-call/voice-call-fixture.tsx
+++ b/apps/desktop/scripts/fixtures/voice-call/voice-call-fixture.tsx
@@ -66,6 +66,7 @@ function Fixture({
const [countdown, setCountdown] = useState(mode === 'countdown');
const [muted, setMuted] = useState(mode === 'muted');
const [reading, setReading] = useState(mode === 'speaking');
+ const speechError = mode === 'speech' || mode === 'speechTimeout' ? mode : null;
const call: VoiceCallRecord = {
...record,
endedAt: live ? undefined : record.endedAt,
@@ -140,17 +141,17 @@ function Fixture({
<CompanionVoiceToolbar
bot={{ id: 'fixture', name: 'Cindy', avatar: 'cindy://avatar/preset/cindy' }}
state={{
- phase: failed
+ phase: failed || speechError
? 'error'
: reading
? 'speaking'
: mode === 'thinking'
? 'thinking'
: 'listening',
- transcript: failed || empty ? '' : '听起来不错。',
+ transcript: failed || empty || speechError ? '' : '听起来不错。',
unsent: failed ? '还有一个想法,请先记下来。' : '',
level: 0.2,
- error: failed ? 'send' : null,
+ error: failed ? 'send' : speechError,
muted,
microphonePending: false,
microphoneError: false,
diff --git a/apps/desktop/src/main/voice-conversation/__tests__/ipc.test.ts b/apps/desktop/src/main/voice-conversation/__tests__/ipc.test.ts
index da67f9620a..041427aed8 100644
--- a/apps/desktop/src/main/voice-conversation/__tests__/ipc.test.ts
+++ b/apps/desktop/src/main/voice-conversation/__tests__/ipc.test.ts
@@ -108,6 +108,66 @@ const start = () =>
voice: 'alloy',
});
+// Oct 21 TTS stall: transport tests did not cover the IPC catch-all losing its
+// timeout cause. Unit: real handlers/service/transport, stalled fetch or PCM read.
+it.each(['headers', 'read'] as const)(
+ 'exposes only a safe timeout code for stalled speech %s',
+ async (stage) => {
+ vi.useFakeTimers();
+ try {
+ await start();
+ if (stage === 'headers') {
+ vi.mocked(outboundFetch).mockImplementation(
+ (_url, init) =>
+ new Promise((_resolve, reject) => {
+ init?.signal?.addEventListener(
+ 'abort',
+ () => reject(new Error('private network detail')),
+ { once: true },
+ );
+ }),
+ );
+ } else {
+ vi.mocked(outboundFetch).mockResolvedValue(
+ new Response(
+ new ReadableStream({
+ start(controller) {
+ controller.enqueue(new Uint8Array([1, 2]));
+ },
+ }),
+ { headers: { 'Content-Type': 'audio/pcm' } },
+ ),
+ );
+ }
+ const speech = call('speak', { callId: 'call', requestId: 'one', text: 'hello' });
+ let pending = speech;
+ if (stage === 'read') {
+ await speech;
+ await call('read-speech', 'call', 'one');
+ pending = call('read-speech', 'call', 'one');
+ }
+ const result = expect(pending).rejects.toThrow(
+ '[VOICE_SPEECH_TIMEOUT] Speech response timed out.',
+ );
+ await vi.advanceTimersByTimeAsync(stage === 'headers' ? 30_000 : 15_000);
+ await result;
+ expect(outboundFetch).toHaveBeenCalledOnce();
+ } finally {
+ vi.useRealTimers();
+ }
+ },
+);
+
+it('keeps untrusted upstream errors generic rather than forwarding their text or claimed timeout code', async () => {
+ await start();
+ vi.mocked(outboundFetch).mockRejectedValue(
+ new Error('[VOICE_SPEECH_TIMEOUT] private upstream detail'),
+ );
+ await expect(call('speak', { callId: 'call', requestId: 'one', text: 'hello' })).rejects.toThrow(
+ '[PRECONDITION_FAILED] Voice conversation is unavailable.',
+ );
+});
+
it('patches playback without replacing the saved route and validates boolean overrides', async () => {
const choice = { modelId: 'voice-test', voice: 'alloy', speed: 1.15 };
await call('set-preference', 'bot-a', choice);
diff --git a/apps/desktop/src/main/voice-conversation/__tests__/speech.test.ts b/apps/desktop/src/main/voice-conversation/__tests__/speech.test.ts
index acd4ec0605..0aa00ecf00 100644
--- a/apps/desktop/src/main/voice-conversation/__tests__/speech.test.ts
+++ b/apps/desktop/src/main/voice-conversation/__tests__/speech.test.ts
@@ -508,7 +508,9 @@ it('cancels late segment headers and keeps the replacement speech reader', async
expect(fetcher).toHaveBeenCalledTimes(3);
});
-it('keeps the safe headers-timeout diagnostic and aborts native synthesis', async () => {
+// Oct 21 read-aloud failure: timeout diagnostics previously became generic IPC
+// failures. Unit: native synthesis with fake time; assert the safe public cause.
+it('keeps the safe headers-timeout cause and aborts native synthesis', async () => {
vi.useFakeTimers();
try {
const diagnostic = vi.fn();
@@ -532,7 +534,7 @@ it('keeps the safe headers-timeout diagnostic and aborts native synthesis', asyn
fetch: fetcher,
diagnostic,
});
- const result = expect(speech.start(input)).rejects.toThrow('request');
+ const result = expect(speech.start(input)).rejects.toMatchObject({ code: 'timeout' });
await vi.advanceTimersByTimeAsync(30_000);
await result;
expect(
@@ -544,3 +546,49 @@ it('keeps the safe headers-timeout diagnostic and aborts native synthesis', asyn
vi.useRealTimers();
}
});
+
+it('preserves a stalled native audio read as timeout after cancelling its stream', async () => {
+ vi.useFakeTimers();
+ try {
+ const cancelled = vi.fn();
+ const diagnostic = vi.fn();
+ const speech = new SpeechSynthesisSession({
+ connection: () => ({
+ baseUrl: 'https://provider.test/api/v1',
+ protocol: 'dashscope-tts',
+ headers: {},
+ }),
+ assertCurrent: () => {},
+ diagnostic,
+ fetch: vi.fn(
+ async () =>
+ new Response(
+ new ReadableStream({
+ start(controller) {
+ controller.enqueue(
+ new TextEncoder().encode('data: {"output":{"audio":{"data":"AQI="}}}\n\n'),
+ );
+ },
+ cancel: cancelled,
+ }),
+ { headers: { 'Content-Type': 'text/event-stream' } },
+ ),
+ ),
+ });
+ await speech.start(input);
+ expect(new Uint8Array((await speech.read('one')).pcm)).toEqual(new Uint8Array([1, 2]));
+ const result = expect(speech.read('one')).rejects.toMatchObject({ code: 'timeout' });
+ await vi.advanceTimersByTimeAsync(15_000);
+ await result;
+ expect(cancelled).toHaveBeenCalledOnce();
+ expect(diagnostic).toHaveBeenCalledWith(
+ expect.objectContaining({
+ stage: 'error',
+ code: 'read_timeout',
+ bytes: 2,
+ }),
+ );
+ } finally {
+ vi.useRealTimers();
+ }
+});
diff --git a/apps/desktop/src/main/voice-conversation/index.ts b/apps/desktop/src/main/voice-conversation/index.ts
index f67496bfe7..82461b327b 100644
--- a/apps/desktop/src/main/voice-conversation/index.ts
+++ b/apps/desktop/src/main/voice-conversation/index.ts
@@ -17,6 +17,7 @@ import { isProviderModelRouteDisabled } from '../utility-model/oneShotCandidates
import { assertTrustedAppRendererEvent } from '../security/trustedAppRenderer.js';
import { requireObject, requireString, throwIpcError } from '../utils/ipcValidate.js';
import { VoiceConversationService } from './service.js';
+import { SpeechError } from './speechError.js';
import { resolveSpeechConnection, speechModels, type SpeechCatalogDeps } from './models.js';
import {
companionVoicePreference,
@@ -95,9 +96,11 @@ export function registerVoiceConversationIpc(deps: {
assertTrustedAppRendererEvent(event);
try {
return await action(event, ...args);
- } catch {
+ } catch (error) {
// Do not log args or upstream errors: either can include text or secrets.
log.warn('IPC operation failed', { operation: name });
+ if (error instanceof SpeechError && error.code === 'timeout')
+ throwIpcError('VOICE_SPEECH_TIMEOUT', 'Speech response timed out.');
throwIpcError('PRECONDITION_FAILED', 'Voice conversation is unavailable.');
}
});
diff --git a/apps/desktop/src/main/voice-conversation/speech.ts b/apps/desktop/src/main/voice-conversation/speech.ts
index 77ec89db8e..2e54cb9a75 100644
--- a/apps/desktop/src/main/voice-conversation/speech.ts
+++ b/apps/desktop/src/main/voice-conversation/speech.ts
@@ -71,6 +71,7 @@ export class SpeechSynthesisSession {
const { url, body, headers } = requests[index];
let timedOut = false;
const timer = setTimeout(() => {
+ if (epoch !== this.epoch) return;
timedOut = true;
controller.abort();
}, 30_000);
@@ -101,6 +102,7 @@ export class SpeechSynthesisSession {
if (timedOut && epoch === this.epoch) {
this.diagnostic?.('error', { code: 'headers_timeout' });
this.cancel('failed');
+ throw new SpeechError('timeout');
}
throw error instanceof SpeechError ? error : new SpeechError('request');
} finally {
@@ -138,8 +140,10 @@ export class SpeechSynthesisSession {
const reader = this.reader;
const epoch = this.epoch;
this.reading = true;
+ let timedOut = false;
const timer = setTimeout(() => {
if (epoch === this.epoch) {
+ timedOut = true;
this.diagnostic?.('error', { code: 'read_timeout' });
this.cancel('failed');
}
@@ -165,6 +169,9 @@ export class SpeechSynthesisSession {
}
return { pcm: Uint8Array.from(value).buffer, done: result.done };
} catch (error) {
+ // Timeout cleanup invalidates the reader just like interruption. Preserve
+ // its cause before the epoch check can collapse it into cancellation.
+ if (timedOut) throw new SpeechError('timeout');
if (epoch === this.epoch) {
this.diagnostic?.('error', { code: error instanceof SpeechError ? error.code : 'request' });
this.cancel('failed');
diff --git a/apps/desktop/src/main/voice-conversation/speechError.ts b/apps/desktop/src/main/voice-conversation/speechError.ts
index 6b4dcc918a..94e63b695c 100644
--- a/apps/desktop/src/main/voice-conversation/speechError.ts
+++ b/apps/desktop/src/main/voice-conversation/speechError.ts
@@ -1,6 +1,6 @@
/** Safe errors only: never send upstream bodies, paths or credentials across IPC. */
export class SpeechError extends Error {
- constructor(readonly code: 'unavailable' | 'request' | 'format' | 'cancelled') {
+ constructor(readonly code: 'unavailable' | 'request' | 'format' | 'cancelled' | 'timeout') {
super(code);
}
}
diff --git a/apps/desktop/src/renderer/features/bots/voice/SpeechPlaybackQueue.ts b/apps/desktop/src/renderer/features/bots/voice/SpeechPlaybackQueue.ts
index 91e27eafa9..b26b3241c5 100644
--- a/apps/desktop/src/renderer/features/bots/voice/SpeechPlaybackQueue.ts
+++ b/apps/desktop/src/renderer/features/bots/voice/SpeechPlaybackQueue.ts
@@ -2,7 +2,7 @@ import type { SpeechStartResult, VoiceConversationApi } from '@/../shared/voiceC
import type { SpeechPlayer } from './PcmSpeechPlayer';
type Segment = { text: string; streaming: boolean };
-type Prepared = { requestId: string; ready: Promise<SpeechStartResult | { error: true }> };
+type Prepared = { requestId: string; ready: Promise<SpeechStartResult | { error: unknown }> };
/** Ordered playback with one bounded lookahead. Text may keep arriving while
* audio plays; an empty queue is not the end of an unfinished model reply.
@@ -30,7 +30,7 @@ export class SpeechPlaybackQueue {
phase(phase: 'thinking' | 'preparing' | 'speaking' | null): void;
drained(): void;
deferred(alreadyPlayed: boolean): void;
- failed(): void;
+ failed(error: unknown): void;
diagnostic(event: string, details: Record<string, string | number | boolean>): void;
},
) {}
@@ -80,7 +80,7 @@ export class SpeechPlaybackQueue {
text: segment.text,
...(segment.streaming ? { streaming: true } : {}),
})
- .catch(() => ({ error: true as const }));
+ .catch((error: unknown) => ({ error }));
// Observe rejection immediately, even if playback never reaches this segment.
this.prepared.push({ requestId, ready });
}
@@ -110,7 +110,7 @@ export class SpeechPlaybackQueue {
this.deps.deferred(this.played);
return;
}
- if ('error' in result) throw new Error('Speech preparation failed');
+ if ('error' in result) throw result.error;
await this.deps.player.play(
() => this.deps.api.readSpeech(this.deps.callId, segment.requestId),
result.sampleRate,
@@ -132,10 +132,10 @@ export class SpeechPlaybackQueue {
this.deps.diagnostic('playback completed', { requestId: segment.requestId });
this.active = false;
this.pump();
- } catch {
+ } catch (error) {
if (!this.cancelled) {
this.cancel();
- this.deps.failed();
+ this.deps.failed(error);
}
}
}
diff --git a/apps/desktop/src/renderer/features/bots/voice/VoiceConversationController.ts b/apps/desktop/src/renderer/features/bots/voice/VoiceConversationController.ts
index cee8f8e92d..a34adeb66a 100644
--- a/apps/desktop/src/renderer/features/bots/voice/VoiceConversationController.ts
+++ b/apps/desktop/src/renderer/features/bots/voice/VoiceConversationController.ts
@@ -5,6 +5,7 @@ import type {
} from '@/../shared/voiceConversation';
import type { ChatMessage } from '@/lib/makerChatStore';
import { createLogger } from '@/lib/logger';
+import { extractIpcError } from '@/utils/ipcError';
import type { PcmChunk } from '@/voice-input/WebMicAudioEngine';
import type { SpeechPlayer } from './PcmSpeechPlayer';
import { speechChunks, VoiceReplyTracker, type VoiceTaskFailure } from './VoiceReplyTracker';
@@ -50,7 +51,7 @@ export type VoiceSnapshot = {
/** Partial question answers must never be concatenated into ordinary chat. */
questionDraft?: string;
level: number;
- error: 'connection' | 'microphone' | 'send' | 'speech' | null;
+ error: 'connection' | 'microphone' | 'send' | 'speech' | 'speechTimeout' | null;
muted: boolean;
microphonePending: boolean;
microphoneError: boolean;
@@ -1004,8 +1005,9 @@ export class VoiceConversationController {
if (epoch === this.epoch && deferredEpoch === this.speechEpoch) this.fail('speech');
});
},
- failed: () => {
- if (current()) this.fail('speech');
+ failed: (error) => {
+ if (current())
+ this.fail(extractIpcError(error)?.code === 'VOICE_SPEECH_TIMEOUT' ? 'speechTimeout' : 'speech');
},
diagnostic: (event, details) => {
if (current())
diff --git a/apps/desktop/src/renderer/features/bots/voice/__tests__/VoiceConversationController.test.ts b/apps/desktop/src/renderer/features/bots/voice/__tests__/VoiceConversationController.test.ts
index 94049c8dc2..de84aadd95 100644
--- a/apps/desktop/src/renderer/features/bots/voice/__tests__/VoiceConversationController.test.ts
+++ b/apps/desktop/src/renderer/features/bots/voice/__tests__/VoiceConversationController.test.ts
@@ -1802,29 +1802,48 @@ describe('companion voice loop', () => {
});
});
-it('keeps the ordinary final text and stops voice on a BYOK synthesis failure without fallback or resend', async () => {
- const f = fixture();
- f.api.speak.mockRejectedValueOnce(new Error('upstream error'));
- await f.controller.start({
- ...selection,
- providerId: 'byok',
- agent: 'codex',
- protocol: 'openai',
- });
- f.utterance();
- await vi.waitFor(() => expect(f.send).toHaveBeenCalledOnce());
- await Promise.resolve();
- const messages = [user(), reply()];
- f.controller.updateMessages(messages);
- await vi.waitFor(() => expect(f.controller.getSnapshot().phase).toBe('error'));
- expect(f.controller.getSnapshot().error).toBe('speech');
- expect(f.microphone.stop).toHaveBeenCalledOnce();
- expect(messages[1]).toEqual(reply());
- expect(f.api.start).toHaveBeenCalledOnce();
- expect(f.api.speak).toHaveBeenCalledOnce();
- expect(f.send).toHaveBeenCalledOnce();
- f.controller.end();
-});
+// Oct 21 TTS stall: the existing failure case did not distinguish preparation
+// and audio-read timeouts. Unit: real controller/queue, serialized IPC failures.
+it.each([
+ { stage: 'prepare', code: 'PRECONDITION_FAILED', error: 'speech' },
+ { stage: 'prepare', code: 'VOICE_SPEECH_TIMEOUT', error: 'speechTimeout' },
+ { stage: 'read', code: 'VOICE_SPEECH_TIMEOUT', error: 'speechTimeout' },
+] as const)(
+ 'retains text and reports $code during $stage without fallback or resend',
+ async ({ stage, code, error }) => {
+ const f = fixture();
+ const failure = new Error(
+ `Error invoking remote method 'voice-conversation:${stage === 'prepare' ? 'speak' : 'read-speech'}': Error: [${code}] Safe failure.`,
+ );
+ if (stage === 'prepare') f.api.speak.mockRejectedValueOnce(failure);
+ else {
+ f.api.readSpeech.mockRejectedValueOnce(failure);
+ f.player.play.mockImplementationOnce(async (read, _rate, onStarted) => {
+ onStarted?.();
+ await read();
+ });
+ }
+ await f.controller.start({
+ ...selection,
+ providerId: 'byok',
+ agent: 'codex',
+ protocol: 'openai',
+ });
+ f.utterance();
+ await vi.waitFor(() => expect(f.send).toHaveBeenCalledOnce());
+ await Promise.resolve();
+ const messages = [user(), reply()];
+ f.controller.updateMessages(messages);
+ await vi.waitFor(() => expect(f.controller.getSnapshot().phase).toBe('error'));
+ expect(f.controller.getSnapshot().error).toBe(error);
+ expect(f.microphone.stop).toHaveBeenCalledOnce();
+ expect(messages[1]).toEqual(reply());
+ expect(f.api.start).toHaveBeenCalledOnce();
+ expect(f.api.speak).toHaveBeenCalledOnce();
+ expect(f.send).toHaveBeenCalledOnce();
+ f.controller.end();
+ },
+);
describe('microphone-only mute', () => {
it('keeps the same call and spoken reply running, and rejects stale input after unmute', async () => {
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 255079dafc..424f432717 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -10253,7 +10253,8 @@
"connection": "Voice connection interrupted. Your unsent text is kept below.",
"microphone": "Microphone stopped. Check its permission and connection, then resume.",
"send": "This message was not accepted. Your text is kept below.",
- "speech": "Could not read the reply aloud. The text reply remains in the conversation. Check the speech model and voice."
+ "speech": "Could not read the reply aloud. The text reply remains in the conversation.",
+ "speechTimeout": "The speech response timed out and read-aloud stopped. The text reply remains in the conversation."
},
"voiceIdHint": "Enter a voice ID available to this provider account.",
"speed": "Speech speed",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index 9d66b51893..a08c72dd55 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -10213,7 +10213,8 @@
"connection": "音声接続が途切れました。未送信のテキストは保持されています。",
"microphone": "マイクが停止しました。権限と接続を確認して再開してください。",
"send": "メッセージは受け付けられませんでした。テキストは保持されています。",
- "speech": "読み上げに失敗しました。返答のテキストは会話に残っています。モデルと音声を確認してください。"
+ "speech": "読み上げに失敗しました。返答のテキストは会話に残っています。",
+ "speechTimeout": "音声の応答がタイムアウトしたため、読み上げを停止しました。返答のテキストは会話に残っています。"
},
"voiceIdHint": "このプロバイダーのアカウントで利用できる音声 ID を入力してください。",
"speed": "読み上げ速度",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index d3998bdfab..6af5904b2c 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -10213,7 +10213,8 @@
"connection": "음성 연결이 끊겼습니다. 전송되지 않은 텍스트는 유지됩니다.",
"microphone": "마이크가 중지되었습니다. 권한과 연결을 확인한 후 계속하세요.",
"send": "메시지가 접수되지 않았습니다. 텍스트는 유지됩니다.",
- "speech": "답변을 읽지 못했습니다. 텍스트 답변은 대화에 남아 있습니다. 모델과 목소리를 확인하세요."
+ "speech": "답변을 읽지 못했습니다. 텍스트 답변은 대화에 남아 있습니다.",
+ "speechTimeout": "음성 응답 시간이 초과되어 읽기를 중지했습니다. 텍스트 답변은 대화에 남아 있습니다."
},
"voiceIdHint": "이 제공자 계정에서 사용할 수 있는 음성 ID를 입력하세요.",
"speed": "읽기 속도",
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 32c3e448d5..a1327e2c01 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -10213,7 +10213,8 @@
"connection": "语音连接中断,未发送的文字已保留。",
"microphone": "麦克风已停止,请检查权限和设备连接后继续。",
"send": "这条消息未被接收,文字已保留。",
- "speech": "回复朗读失败,文字回复仍保留在对话中。请检查朗读模型和音色。"
+ "speech": "回复朗读失败,文字回复仍保留在对话中。",
+ "speechTimeout": "语音响应超时,朗读已停止。文字回复仍保留在对话中。"
},
"voiceIdHint": "填写该供应商账号可用的音色 ID。",
"speed": "语速",
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 c2da68984e..198b1fd0bc 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -10213,7 +10213,8 @@
"connection": "語音連線中斷,未傳送的文字已保留。",
"microphone": "麥克風已停止,請檢查權限和裝置連線後繼續。",
"send": "這則訊息未被接收,文字已保留。",
- "speech": "回覆朗讀失敗,文字回覆仍保留在對話中。請檢查朗讀模型和音色。"
+ "speech": "回覆朗讀失敗,文字回覆仍保留在對話中。",
+ "speechTimeout": "語音回應逾時,朗讀已停止。文字回覆仍保留在對話中。"
},
"voiceIdHint": "填寫該供應商帳號可用的音色 ID。",
"speed": "語速",
diff --git a/apps/desktop/src/shared/ipc-errors.ts b/apps/desktop/src/shared/ipc-errors.ts
index b16cea656c..28ada4f986 100644
--- a/apps/desktop/src/shared/ipc-errors.ts
+++ b/apps/desktop/src/shared/ipc-errors.ts
@@ -77,6 +77,7 @@ export type IpcErrorCode =
| 'INTERNAL'
| 'ALREADY_EXISTS'
| 'PRECONDITION_FAILED'
+ | 'VOICE_SPEECH_TIMEOUT' // 本机语音合成等待响应或音频读取超时
| 'PROVIDER_GROUP_CHANGED' // 编辑期间组设置已变化,拒绝覆盖,需重新读取
| 'HTML_PREVIEW_TOO_LARGE'
| 'HTML_PREVIEW_UNSUPPORTED'
@@ -338,6 +339,7 @@ const IPC_ERROR_CODES: ReadonlySet<IpcErrorCode> = new Set<IpcErrorCode>([
'ALREADY_EXISTS',
'IDENTITY_CONFLICT',
'PRECONDITION_FAILED',
+ 'VOICE_SPEECH_TIMEOUT',
'PROVIDER_GROUP_CHANGED',
'HTML_PREVIEW_TOO_LARGE',
'HTML_PREVIEW_UNSUPPORTED',
diff --git a/docs/product-rules/companion-voice-mode.md b/docs/product-rules/companion-voice-mode.md
index dd6ebef970..8516ab6506 100644
--- a/docs/product-rules/companion-voice-mode.md
+++ b/docs/product-rules/companion-voice-mode.md
@@ -19,7 +19,7 @@
- 静音仅关闭麦克风采集和 ASR 输入,保留当前通话、伙伴任务、待回复关联和朗读队列;静音期间仍可继续收听新到达的回复。若因疑似插话暂时暂停朗读,静音会恢复原朗读。按钮切换为“取消静音”,显式操作后重新开启输入;开启失败保持静音并提示重试,不中断朗读。未发送的识别文字留在面板,可点次要“发送”操作,或取消静音后与下一段发言合并;单纯取消静音不自动发送。已被任务接收的输入不因迟到确认而重复发送。
- 普通提问卡保留麦克风与 ASR,暂缓朗读;可说“第一项/第一个”或完整选项名称,编号按卡片实际显示的选项顺序计算。明确单选直接复用卡片提交;多选先更新勾选,需说“确认选择”或点击确认后提交,“取消选择”清除当前选择。歧义或无法匹配时留在卡片,提示重新说编号/完整名称或手动选择,不猜测答案;无选项的普通问题先将识别文字放入原有回答草稿,确认后提交。语音答案绑定发声开始时的问题步骤,切题、替换请求或手动操作后迟到的识别不得回答新问题,也不转成普通聊天消息。卡片提交回执、失败保留及后续执行均复用已有接口;问题解决后继续原任务的回复朗读,不重建麦克风。待回答的问题阻止空闲退出;现有明确退出/告别规则仍有效。诊断只记录通话 ID、路由结果和字符数,不记录问题或回答正文。
- 权限、计划或其他执行批准,以及任务队列暂停时,仍关闭麦克风并暂停语音模式;不得用普通提问卡的语音入口代答,用户完成确认后显式继续。锁屏、休眠、切走任务、关面板、账号切换同样释放采集和播放资源,不在后台重新开始。
-- 未发送的文字在可恢复错误或暂停后留在面板内;用户可选中复制或明确重新连接并发送。TTS 失败保留任务中的文字回复,不自动重发用户消息。
+- 未发送的文字在可恢复错误或暂停后留在面板内;用户可选中复制或明确重新连接并发送。TTS 失败保留任务中的文字回复,不自动重发用户消息。等待语音响应或读取音频超时时明确提示语音响应超时、朗读停止及文字保留;未知原因只说明朗读失败,不推断模型或音色配置有误。
## 交互与动效