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

推荐订阅源

U
Unit 42
博客园 - Franky
T
Tailwind CSS Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
人人都是产品经理
人人都是产品经理
雷峰网
雷峰网
Hugging Face - Blog
Hugging Face - Blog
有赞技术团队
有赞技术团队
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
阮一峰的网络日志
阮一峰的网络日志
C
Check Point Blog
爱范儿
爱范儿
T
The Blog of Author Tim Ferriss
aimingoo的专栏
aimingoo的专栏
Stack Overflow Blog
Stack Overflow Blog
博客园 - 聂微东
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LangChain Blog
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
Microsoft Security Blog
Microsoft Security Blog
The Cloudflare Blog
博客园 - 三生石上(FineUI控件)

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(openai/tts): handle speed directives (#74089) · openc...
stainlu · 2026-06-01 · via Recent Commits to openclaw:main

@@ -192,6 +192,189 @@ describe("buildOpenAISpeechProvider", () => {

192192

});

193193

});

194194195+

it("parses preferred-OpenAI speed directive within the supported range", () => {

196+

const provider = buildOpenAISpeechProvider();

197+198+

expect(

199+

provider.parseDirectiveToken?.({

200+

key: "speed",

201+

value: "1.5",

202+

policy: {

203+

allowVoice: true,

204+

allowModelId: true,

205+

allowVoiceSettings: true,

206+

},

207+

providerConfig: {

208+

baseUrl: "https://api.openai.com/v1/",

209+

},

210+

} as never),

211+

).toEqual({

212+

handled: true,

213+

overrides: { speed: 1.5 },

214+

});

215+

});

216+217+

it("parses explicit openai_speed alias", () => {

218+

const provider = buildOpenAISpeechProvider();

219+220+

expect(

221+

provider.parseDirectiveToken?.({

222+

key: "openai_speed",

223+

value: "0.75",

224+

policy: {

225+

allowVoice: true,

226+

allowModelId: true,

227+

allowVoiceSettings: true,

228+

},

229+

providerConfig: {

230+

baseUrl: "https://api.openai.com/v1/",

231+

},

232+

} as never),

233+

).toEqual({

234+

handled: true,

235+

overrides: { speed: 0.75 },

236+

});

237+

});

238+239+

it("ignores OpenAI speed directives when allowVoiceSettings is disabled", () => {

240+

const provider = buildOpenAISpeechProvider();

241+242+

expect(

243+

provider.parseDirectiveToken?.({

244+

key: "speed",

245+

value: "1.5",

246+

policy: {

247+

allowVoice: true,

248+

allowModelId: true,

249+

allowVoiceSettings: false,

250+

},

251+

providerConfig: {

252+

baseUrl: "https://api.openai.com/v1/",

253+

},

254+

} as never),

255+

).toEqual({

256+

handled: true,

257+

});

258+

});

259+260+

it("warns on non-numeric OpenAI speed values", () => {

261+

const provider = buildOpenAISpeechProvider();

262+263+

expect(

264+

provider.parseDirectiveToken?.({

265+

key: "speed",

266+

value: "fast",

267+

policy: {

268+

allowVoice: true,

269+

allowModelId: true,

270+

allowVoiceSettings: true,

271+

},

272+

providerConfig: {

273+

baseUrl: "https://api.openai.com/v1/",

274+

},

275+

} as never),

276+

).toEqual({

277+

handled: true,

278+

warnings: ['invalid OpenAI speed "fast" (0.25-4.0)'],

279+

});

280+

});

281+282+

it("warns on partial OpenAI speed values", () => {

283+

const provider = buildOpenAISpeechProvider();

284+285+

expect(

286+

provider.parseDirectiveToken?.({

287+

key: "speed",

288+

value: "1.5abc",

289+

policy: {

290+

allowVoice: true,

291+

allowModelId: true,

292+

allowVoiceSettings: true,

293+

},

294+

providerConfig: {

295+

baseUrl: "https://api.openai.com/v1/",

296+

},

297+

} as never),

298+

).toEqual({

299+

handled: true,

300+

warnings: ['invalid OpenAI speed "1.5abc" (0.25-4.0)'],

301+

});

302+

});

303+304+

it("warns on OpenAI speed values outside the supported 0.25..4 range", () => {

305+

const provider = buildOpenAISpeechProvider();

306+307+

expect(

308+

provider.parseDirectiveToken?.({

309+

key: "speed",

310+

value: "5",

311+

policy: {

312+

allowVoice: true,

313+

allowModelId: true,

314+

allowVoiceSettings: true,

315+

},

316+

providerConfig: {

317+

baseUrl: "https://api.openai.com/v1/",

318+

},

319+

} as never),

320+

).toEqual({

321+

handled: true,

322+

warnings: ['invalid OpenAI speed "5" (0.25-4.0)'],

323+

});

324+

});

325+326+

it("passes custom endpoint OpenAI-compatible speed directives through", () => {

327+

const provider = buildOpenAISpeechProvider();

328+329+

expect(

330+

provider.parseDirectiveToken?.({

331+

key: "speed",

332+

value: "4.5",

333+

policy: {

334+

allowVoice: true,

335+

allowModelId: true,

336+

allowVoiceSettings: true,

337+

},

338+

providerConfig: {

339+

baseUrl: "https://tts.example.com/v1",

340+

},

341+

} as never),

342+

).toEqual({

343+

handled: true,

344+

overrides: { speed: 4.5 },

345+

});

346+

});

347+348+

it("uses OPENAI_TTS_BASE_URL when parsing OpenAI-compatible speed directives", () => {

349+

const previousBaseUrl = process.env.OPENAI_TTS_BASE_URL;

350+

process.env.OPENAI_TTS_BASE_URL = "https://tts.example.com/v1";

351+

try {

352+

const provider = buildOpenAISpeechProvider();

353+354+

expect(

355+

provider.parseDirectiveToken?.({

356+

key: "speed",

357+

value: "4.5",

358+

policy: {

359+

allowVoice: true,

360+

allowModelId: true,

361+

allowVoiceSettings: true,

362+

},

363+

providerConfig: {},

364+

} as never),

365+

).toEqual({

366+

handled: true,

367+

overrides: { speed: 4.5 },

368+

});

369+

} finally {

370+

if (previousBaseUrl === undefined) {

371+

delete process.env.OPENAI_TTS_BASE_URL;

372+

} else {

373+

process.env.OPENAI_TTS_BASE_URL = previousBaseUrl;

374+

}

375+

}

376+

});

377+195378

it("preserves talk responseFormat overrides", () => {

196379

const provider = buildOpenAISpeechProvider();

197380