惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
G
Google Developers Blog
Blog — PlanetScale
Blog — PlanetScale
U
Unit 42
A
About on SuperTechFans
Vercel News
Vercel News
B
Blog
Martin Fowler
Martin Fowler
MyScale Blog
MyScale Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
腾讯CDC
D
Docker
V
Visual Studio Blog
博客园 - 叶小钗
The Cloudflare Blog
Jina AI
Jina AI
B
Blog RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
WordPress大学
WordPress大学
T
Tailwind CSS Blog
MongoDB | Blog
MongoDB | Blog
D
DataBreaches.Net
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(tts): surface voice status and harden providers · ope...
steipete · 2026-04-26 · via Recent Commits to openclaw:main

@@ -1,13 +1,20 @@

11

import { mkdtempSync, rmSync, writeFileSync } from "node:fs";

22

import { tmpdir } from "node:os";

33

import path from "node:path";

4-

import { afterEach, beforeAll, describe, expect, it } from "vitest";

4+

import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";

5566

let edgeTTS: typeof import("./tts.js").edgeTTS;

778-

function createEdgeTTSDeps(ttsPromise: (text: string, filePath: string) => Promise<void>) {

8+

function createEdgeTTSDeps(

9+

ttsPromise: (text: string, filePath: string) => Promise<void>,

10+

onConstruct?: () => void,

11+

) {

912

return {

1013

EdgeTTS: class {

14+

constructor() {

15+

onConstruct?.();

16+

}

17+1118

ttsPromise(text: string, filePath: string) {

1219

return ttsPromise(text, filePath);

1320

}

@@ -36,11 +43,35 @@ describe("edgeTTS empty audio validation", () => {

3643

}

3744

});

384539-

it("throws when the output file is 0 bytes", async () => {

46+

it("rejects blank text before constructing Edge TTS", async () => {

4047

tempDir = mkdtempSync(path.join(tmpdir(), "tts-test-"));

4148

const outputPath = path.join(tempDir, "voice.mp3");

42-49+

const onConstruct = vi.fn();

4350

const deps = createEdgeTTSDeps(async (_text: string, filePath: string) => {

51+

writeFileSync(filePath, Buffer.from([0xff]));

52+

}, onConstruct);

53+54+

await expect(

55+

edgeTTS(

56+

{

57+

text: " \n\t ",

58+

outputPath,

59+

config: baseEdgeConfig,

60+

timeoutMs: 10000,

61+

},

62+

deps,

63+

),

64+

).rejects.toThrow("Microsoft TTS text cannot be empty");

65+

expect(onConstruct).not.toHaveBeenCalled();

66+

});

67+68+

it("throws after one retry when the output file stays empty", async () => {

69+

tempDir = mkdtempSync(path.join(tmpdir(), "tts-test-"));

70+

const outputPath = path.join(tempDir, "voice.mp3");

71+

const calls: string[] = [];

72+73+

const deps = createEdgeTTSDeps(async (text: string, filePath: string) => {

74+

calls.push(text);

4475

writeFileSync(filePath, "");

4576

});

4677

@@ -54,7 +85,8 @@ describe("edgeTTS empty audio validation", () => {

5485

},

5586

deps,

5687

),

57-

).rejects.toThrow("Edge TTS produced empty audio file");

88+

).rejects.toThrow("Edge TTS produced empty audio file after retry");

89+

expect(calls).toEqual(["Hello", "Hello"]);

5890

});

59916092

it("succeeds when the output file has content", async () => {

@@ -77,4 +109,78 @@ describe("edgeTTS empty audio validation", () => {

77109

),

78110

).resolves.toBeUndefined();

79111

});

112+113+

it("retries once when the first output file is empty", async () => {

114+

tempDir = mkdtempSync(path.join(tmpdir(), "tts-test-"));

115+

const outputPath = path.join(tempDir, "voice.mp3");

116+

const calls: string[] = [];

117+118+

const deps = createEdgeTTSDeps(async (text: string, filePath: string) => {

119+

calls.push(text);

120+

writeFileSync(filePath, calls.length === 1 ? "" : Buffer.from([0xff, 0xfb, 0x90, 0x00]));

121+

});

122+123+

await expect(

124+

edgeTTS(

125+

{

126+

text: "Hello",

127+

outputPath,

128+

config: baseEdgeConfig,

129+

timeoutMs: 10000,

130+

},

131+

deps,

132+

),

133+

).resolves.toBeUndefined();

134+

expect(calls).toEqual(["Hello", "Hello"]);

135+

});

136+137+

it("retries once when Edge TTS resolves without creating an output file", async () => {

138+

tempDir = mkdtempSync(path.join(tmpdir(), "tts-test-"));

139+

const outputPath = path.join(tempDir, "voice.mp3");

140+

const calls: string[] = [];

141+142+

const deps = createEdgeTTSDeps(async (text: string, filePath: string) => {

143+

calls.push(text);

144+

if (calls.length === 2) {

145+

writeFileSync(filePath, Buffer.from([0xff, 0xfb, 0x90, 0x00]));

146+

}

147+

});

148+149+

await expect(

150+

edgeTTS(

151+

{

152+

text: "Hello",

153+

outputPath,

154+

config: baseEdgeConfig,

155+

timeoutMs: 10000,

156+

},

157+

deps,

158+

),

159+

).resolves.toBeUndefined();

160+

expect(calls).toEqual(["Hello", "Hello"]);

161+

});

162+163+

it("does not retry provider errors", async () => {

164+

tempDir = mkdtempSync(path.join(tmpdir(), "tts-test-"));

165+

const outputPath = path.join(tempDir, "voice.mp3");

166+

const calls: string[] = [];

167+168+

const deps = createEdgeTTSDeps(async (text: string) => {

169+

calls.push(text);

170+

throw new Error("upstream timeout");

171+

});

172+173+

await expect(

174+

edgeTTS(

175+

{

176+

text: "Hello",

177+

outputPath,

178+

config: baseEdgeConfig,

179+

timeoutMs: 10000,

180+

},

181+

deps,

182+

),

183+

).rejects.toThrow("upstream timeout");

184+

expect(calls).toEqual(["Hello"]);

185+

});

80186

});