Repository navigation
improve(talk): reduce voice conversion CPU work - #146469
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
a99ad53 to
9cad534
Compare
|
Codex review: needs maintainer review before merge. Reviewed September 12, 2026, 5:31 PM ET / 21:31 UTC. ClawSweeper reviewWhat this changesThe PR reduces voice resampling CPU work by calculating each filter phase’s coefficient sum once while preserving audio bytes and stream-edge handling. Merge readiness✅ Ready for maintainer review Keep open: this remains a useful, narrowly scoped optimization absent from inspected main and the latest release. No actionable correctness or security defects were found. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s shared audio codec converts PCM samples between rates for realtime voice and telephony adapters. Its output feeds audio playback and G.711 encoding for calls. flowchart TD
A[Incoming voice audio] --> B[PCM samples]
B --> C[Shared audio resampler]
C --> D{Full filter fits?}
D -->|Yes| E[Reuse phase coefficient sum]
D -->|No| F[Calculate partial edge weights]
E --> G[Converted PCM]
F --> G
G --> H[Voice playback or telephony encoding]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +20. Total +20 across 1 file. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep the optimization within the existing shared resampler, retaining identical output, edge normalization, and public APIs. Do we have a high-confidence way to reproduce the issue? Not applicable as a functional bug: this is a performance optimization supported by current-source inspection and reported before/after adapter measurements; no code was executed during this review. Is this the best way to solve the issue? Yes: reusing the existing phase’s sum removes repeated work without a competing implementation, configuration change, or alteration to the public audio contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9b59fe4ef7da. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
Closes #146468
What Problem This Solves
Voice calls spend unnecessary CPU converting between realtime and telephony audio formats.
User Impact
Voice conversion uses less CPU while preserving identical audio bytes: one-second telephony streams took about 39–46% less time in the measured adapter workload. This does not claim lower provider or network latency. Short conversions with many rate phases can remain neutral or slightly slower.
Why This Change Was Made
Calculate the existing phase's full coefficient sum once and use it for interior samples. Keep the original edge handling and arithmetic order, including the zero-weight fallback, so sample rounding and streaming continuity remain unchanged.
Evidence
src/gateway/server-startup-finish.ts:416(TS2741, array missing requiredstop). Replacing only the audio owner with the unchanged base source reproduced the same error with the same frozen dependencies. The owning repair has now landed as fix(gateway): register TLS renewal with sidecar owner #146412; this branch was rebased onto fixed main with identical audio bytes. Later local changed-check stages were not reached. Fresh hosted CI remains required before landing.Measurement method and complete timing controls
The source-copy harness uses the complete actual
OpenAIQuicksilverAudioAdapterand meeting TTS conversion module, changing their codec imports to select original or candidate source. The codec retains its real normalization dependency. Synthetic PCM/μ-law fixtures avoid live services. The base isea4b57a0adc495b54e7dbd783b07eb83f9c49382; candidate codec SHA-256 is8c50ba592d66a3970059dcdddcd2c130bac4472a64100acd072b9f70b3f1f4a7.Adapter timings include construction and finishing/resetting the audio adapter. Input uses 160-byte μ-law frames; output uses 960-byte PCM frames (20 ms). The duplex fixture feeds decoded PCM back through the output conversion to exercise both directions; separate directional cells measure independently generated source frames. The PCM control does not resample. Values are median milliseconds per complete operation; parentheses show winning pairs out of nine.
The meeting converter includes one-shot phase-table preparation. The 22.05 kHz short cases show why this is not a universal speedup: phase construction can dominate very short buffers. The 48,001 Hz cells retain the direct sampler because the phase count exceeds the existing cap; same-rate cells retain their original conversion behavior.
Three alternating fresh-process pairs per runtime measured the complete adapter workload. RSS is process high-water, including loader, imports and fixtures; small differences were mixed and do not support a memory improvement claim.
These measurements cover conversion CPU and full output parity, not live audio-device behavior, provider latency, or per-call heap allocation.