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

推荐订阅源

Hugging Face - Blog
Hugging Face - Blog
Recent Announcements
Recent Announcements
V
Visual Studio Blog
博客园 - 叶小钗
H
Help Net Security
aimingoo的专栏
aimingoo的专栏
宝玉的分享
宝玉的分享
U
Unit 42
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
F
Fortinet All Blogs
V
V2EX
Stack Overflow Blog
Stack Overflow Blog
WordPress大学
WordPress大学
D
DataBreaches.Net
J
Java Code Geeks
H
Hackread – Cybersecurity News, Data Breaches, AI and More
A
About on SuperTechFans
酷 壳 – CoolShell
酷 壳 – CoolShell
量子位
C
Check Point Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
小众软件
小众软件
Microsoft Azure Blog
Microsoft Azure Blog
M
MIT News - Artificial intelligence

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): harden realtime stt · openclaw/openclaw@4ff720a
steipete · 2026-04-23 · via Recent Commits to openclaw:main

@@ -140,6 +140,56 @@ async function createTempAgentDir(): Promise<string> {

140140

return await fs.mkdtemp(path.join(os.tmpdir(), "openai-plugin-live-"));

141141

}

142142143+

async function waitForLiveExpectation(expectation: () => void, timeoutMs = 30_000) {

144+

const started = Date.now();

145+

let lastError: unknown;

146+

while (Date.now() - started < timeoutMs) {

147+

try {

148+

expectation();

149+

return;

150+

} catch (error) {

151+

lastError = error;

152+

await new Promise((resolve) => setTimeout(resolve, 100));

153+

}

154+

}

155+

throw lastError;

156+

}

157+158+

function normalizeTranscriptForMatch(value: string): string {

159+

return value.toLowerCase().replace(/[^a-z0-9]+/g, "");

160+

}

161+162+

function linearToMulaw(sample: number): number {

163+

const bias = 132;

164+

const clip = 32635;

165+

let next = Math.max(-clip, Math.min(clip, sample));

166+

const sign = next < 0 ? 0x80 : 0;

167+

if (next < 0) {

168+

next = -next;

169+

}

170+171+

next += bias;

172+

let exponent = 7;

173+

for (let expMask = 0x4000; (next & expMask) === 0 && exponent > 0; exponent -= 1) {

174+

expMask >>= 1;

175+

}

176+177+

const mantissa = (next >> (exponent + 3)) & 0x0f;

178+

return ~(sign | (exponent << 4) | mantissa) & 0xff;

179+

}

180+181+

function convertPcm24kToMulaw8k(pcm: Buffer): Buffer {

182+

const inputSamples = Math.floor(pcm.length / 2);

183+

const outputSamples = Math.floor(inputSamples / 3);

184+

const mulaw = Buffer.alloc(outputSamples);

185+186+

for (let i = 0; i < outputSamples; i += 1) {

187+

mulaw[i] = linearToMulaw(pcm.readInt16LE(i * 3 * 2));

188+

}

189+190+

return mulaw;

191+

}

192+143193

describeLive("openai plugin live", () => {

144194

it("registers an OpenAI provider that can complete a live request", async () => {

145195

const { providers } = await registerOpenAIPlugin();

@@ -247,6 +297,89 @@ describeLive("openai plugin live", () => {

247297

expect(text).toMatch(/\bok\b/);

248298

}, 45_000);

249299300+

it("opens OpenAI realtime STT before sending audio", async () => {

301+

const { realtimeTranscriptionProviders } = await registerOpenAIPlugin();

302+

const realtimeProvider = requireRegisteredProvider(realtimeTranscriptionProviders, "openai");

303+

const errors: Error[] = [];

304+

const session = realtimeProvider.createSession({

305+

providerConfig: {

306+

apiKey: OPENAI_API_KEY,

307+

language: "en",

308+

},

309+

onError: (error) => errors.push(error),

310+

});

311+312+

try {

313+

await session.connect();

314+

await new Promise((resolve) => setTimeout(resolve, 1_000));

315+

expect(errors).toEqual([]);

316+

expect(session.isConnected()).toBe(true);

317+

} finally {

318+

session.close();

319+

}

320+

}, 30_000);

321+322+

it("streams realtime STT through the registered transcription provider", async () => {

323+

const { realtimeTranscriptionProviders, speechProviders } = await registerOpenAIPlugin();

324+

const realtimeProvider = requireRegisteredProvider(realtimeTranscriptionProviders, "openai");

325+

const speechProvider = requireRegisteredProvider(speechProviders, "openai");

326+

const cfg = createLiveConfig();

327+

const ttsConfig = createLiveTtsConfig();

328+

const phrase = "Testing OpenClaw OpenAI realtime transcription integration test OK.";

329+330+

const telephony = await speechProvider.synthesizeTelephony?.({

331+

text: phrase,

332+

cfg,

333+

providerConfig: ttsConfig.providerConfigs.openai ?? {},

334+

timeoutMs: ttsConfig.timeoutMs,

335+

});

336+

if (!telephony) {

337+

throw new Error("OpenAI telephony synthesis did not return audio");

338+

}

339+

expect(telephony.outputFormat).toBe("pcm");

340+

expect(telephony.sampleRate).toBe(24_000);

341+342+

const transcripts: string[] = [];

343+

const partials: string[] = [];

344+

const errors: Error[] = [];

345+

const session = realtimeProvider.createSession({

346+

providerConfig: {

347+

apiKey: OPENAI_API_KEY,

348+

language: "en",

349+

silenceDurationMs: 500,

350+

},

351+

onPartial: (partial) => partials.push(partial),

352+

onTranscript: (transcript) => transcripts.push(transcript),

353+

onError: (error) => errors.push(error),

354+

});

355+356+

try {

357+

await session.connect();

358+

const speech = convertPcm24kToMulaw8k(telephony.audioBuffer);

359+

const silence = Buffer.alloc(8_000, 0xff);

360+

const audio = Buffer.concat([silence.subarray(0, 4_000), speech, silence]);

361+

for (let offset = 0; offset < audio.byteLength; offset += 160) {

362+

session.sendAudio(audio.subarray(offset, offset + 160));

363+

await new Promise((resolve) => setTimeout(resolve, 5));

364+

}

365+366+

await waitForLiveExpectation(() => {

367+

if (errors[0]) {

368+

throw errors[0];

369+

}

370+

expect(normalizeTranscriptForMatch(transcripts.join(" "))).toContain("openclaw");

371+

}, 60_000);

372+

} finally {

373+

session.close();

374+

}

375+376+

const normalized = transcripts.join(" ").toLowerCase();

377+

const compact = normalizeTranscriptForMatch(normalized);

378+

expect(compact).toContain("openclaw");

379+

expect(normalized).toContain("transcription");

380+

expect(partials.length + transcripts.length).toBeGreaterThan(0);

381+

}, 180_000);

382+250383

it("generates an image through the registered image provider", async () => {

251384

const { imageProviders } = await registerOpenAIPlugin();

252385

const imageProvider = requireRegisteredProvider(imageProviders, "openai");