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

推荐订阅源

B
Blog
D
Docker
J
Java Code Geeks
腾讯CDC
Blog — PlanetScale
Blog — PlanetScale
G
Google Developers Blog
M
MIT News - Artificial intelligence
L
LangChain Blog
T
The Blog of Author Tim Ferriss
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
博客园 - Franky
GbyAI
GbyAI
Hugging Face - Blog
Hugging Face - Blog
aimingoo的专栏
aimingoo的专栏
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东
N
Netflix TechBlog - Medium
B
Blog RSS Feed
Y
Y Combinator Blog
阮一峰的网络日志
阮一峰的网络日志
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google DeepMind News
Google DeepMind News

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(voice-call): bound realtime audio pacing · openclaw/o...
vincentkoc · 2026-05-04 · via Recent Commits to openclaw:main

@@ -4,6 +4,7 @@ const TELEPHONY_CHUNK_MS = 20;

44

const DEFAULT_SPEECH_RMS_THRESHOLD = 0.02;

55

const DEFAULT_REQUIRED_LOUD_CHUNKS = 2;

66

const DEFAULT_REQUIRED_QUIET_CHUNKS = 10;

7+

const DEFAULT_MAX_QUEUED_AUDIO_BYTES = TELEPHONY_SAMPLE_RATE * 120;

78

const PCM16_MAX_AMPLITUDE = 32768;

89

const MULAW_LINEAR_SAMPLES = new Int16Array(256);

910

@@ -27,10 +28,13 @@ export type RealtimeTwilioAudioPacerSendJson = (message: unknown) => boolean;

2728

export class RealtimeTwilioAudioPacer {

2829

private queue: RealtimeTwilioAudioQueueItem[] = [];

2930

private timer: ReturnType<typeof setTimeout> | null = null;

31+

private queuedAudioBytes = 0;

3032

private closed = false;

31333234

constructor(

3335

private readonly params: {

36+

maxQueuedAudioBytes?: number;

37+

onBackpressure?: () => void;

3438

sendJson: RealtimeTwilioAudioPacerSendJson;

3539

streamSid: string;

3640

},

@@ -40,13 +44,19 @@ export class RealtimeTwilioAudioPacer {

4044

if (this.closed || muLaw.length === 0) {

4145

return;

4246

}

47+

const maxQueuedAudioBytes = this.params.maxQueuedAudioBytes ?? DEFAULT_MAX_QUEUED_AUDIO_BYTES;

4348

for (let offset = 0; offset < muLaw.length; offset += TELEPHONY_CHUNK_BYTES) {

4449

const chunk = Buffer.from(muLaw.subarray(offset, offset + TELEPHONY_CHUNK_BYTES));

50+

if (this.queuedAudioBytes + chunk.length > maxQueuedAudioBytes) {

51+

this.failBackpressure();

52+

return;

53+

}

4554

this.queue.push({

4655

type: "audio",

4756

chunk,

4857

durationMs: Math.max(1, Math.round((chunk.length / TELEPHONY_SAMPLE_RATE) * 1000)),

4958

});

59+

this.queuedAudioBytes += chunk.length;

5060

}

5161

this.ensurePump();

5262

}

@@ -65,13 +75,15 @@ export class RealtimeTwilioAudioPacer {

6575

}

6676

this.clearTimer();

6777

this.queue = [];

78+

this.queuedAudioBytes = 0;

6879

this.params.sendJson({ event: "clear", streamSid: this.params.streamSid });

6980

}

70817182

close(): void {

7283

this.closed = true;

7384

this.clearTimer();

7485

this.queue = [];

86+

this.queuedAudioBytes = 0;

7587

}

76887789

private clearTimer(): void {

@@ -88,6 +100,11 @@ export class RealtimeTwilioAudioPacer {

88100

}

89101

}

90102103+

private failBackpressure(): void {

104+

this.close();

105+

this.params.onBackpressure?.();

106+

}

107+91108

private pump(): void {

92109

this.timer = null;

93110

if (this.closed) {

@@ -101,6 +118,7 @@ export class RealtimeTwilioAudioPacer {

101118

let delayMs = 0;

102119

let sent = true;

103120

if (item.type === "audio") {

121+

this.queuedAudioBytes = Math.max(0, this.queuedAudioBytes - item.chunk.length);

104122

sent = this.params.sendJson({

105123

event: "media",

106124

streamSid: this.params.streamSid,

@@ -117,6 +135,7 @@ export class RealtimeTwilioAudioPacer {

117135118136

if (!sent) {

119137

this.queue = [];

138+

this.queuedAudioBytes = 0;

120139

return;

121140

}

122141

if (this.queue.length > 0) {