




















@@ -186,6 +186,7 @@ async function expectTtsPayloadResult(params: {
186186audioAsVoice: true | undefined;
187187providerResult?: MockSpeechSynthesisResult;
188188mediaExtension?: string;
189+kind?: "tool" | "block" | "final";
189190}) {
190191if (params.providerResult) {
191192synthesizeMock.mockResolvedValueOnce(params.providerResult);
@@ -197,7 +198,7 @@ async function expectTtsPayloadResult(params: {
197198payload: { text: params.text },
198199 cfg,
199200channel: params.channel,
200-kind: "final",
201+kind: params.kind ?? "final",
201202});
202203203204expect(synthesizeMock).toHaveBeenCalled();
@@ -209,6 +210,7 @@ async function expectTtsPayloadResult(params: {
209210expect(result.audioAsVoice).toBe(params.audioAsVoice);
210211expect(result.mediaUrl).toMatch(new RegExp(`voice-\\d+\\.${params.mediaExtension ?? "ogg"}$`));
211212expect(result.spokenText).toBe(params.text);
213+expect(result.trustedLocalMedia).toBe(true);
212214213215mediaDir = result.mediaUrl ? path.dirname(result.mediaUrl) : undefined;
214216} finally {
@@ -440,6 +442,32 @@ describe("speech-core native voice-note routing", () => {
440442}
441443});
442444445+it("applies TTS for block delivery kind in final mode (#82628)", async () => {
446+await expectTtsPayloadResult({
447+channel: "webchat",
448+prefsName: "openclaw-speech-core-block-kind-tts-test",
449+text: "WebChat block replies should synthesize audio for auto TTS.",
450+target: "audio-file",
451+audioAsVoice: undefined,
452+kind: "block",
453+});
454+});
455+456+it("skips tool delivery kind in final mode", async () => {
457+synthesizeMock.mockClear();
458+const cfg = createTtsConfig("openclaw-speech-core-tool-kind-tts-test");
459+const result = await maybeApplyTtsToPayload({
460+payload: { text: "Intermediate tool output should not be spoken." },
461+ cfg,
462+channel: "webchat",
463+kind: "tool",
464+});
465+466+expect(synthesizeMock).not.toHaveBeenCalled();
467+expect(result.trustedLocalMedia).toBeUndefined();
468+expect(result.text).toBe("Intermediate tool output should not be spoken.");
469+});
470+443471it("keeps skipping untagged short TTS text", async () => {
444472const cfg = createTtsConfig("openclaw-speech-core-short-plain-tts-test");
445473const result = await maybeApplyTtsToPayload({
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。