Files
codex/codex-rs/voice-host/Cargo.toml
T
Benjamin Carlsson 7dc7c7a756 Send processed microphone audio over RTP in voice-host (#43090)
## Why

`voice-host` previously drained captured audio locally without sending it to the peer. Connect capture to the outgoing media track while preserving mute boundaries and limiting stale audio.

## What changed

- Resample capture and render references to 48 kHz with Rubato, apply Sonora echo cancellation, noise suppression, and gain control, and encode capture as 20 ms mono Opus packets.
- Attach an Opus track to the WebRTC peer and advance RTP timestamps across mute gaps without introducing sequence-number gaps.
- Prioritize queued controls and shutdown between sends. Clear pending audio and processing history on microphone mute transitions, reject delayed pre-unmute buffers, and reset partial history after capture gaps.
- Size bounded capture and render queues for device rates, validate callback timing, enforce a 500 ms processing deadline, and time out stalled sends after 100 ms.

Receive/decode and TUI integration remain unimplemented. The bundled Opus encoder build requires CMake and a C compiler.

## Testing

Add synthetic-audio tests for Opus decoding at 44.1 and 48 kHz input rates, echo reduction, capture gaps, stale audio, queue capacity, and control priority. A loopback WebRTC test verifies RTP delivery, decoded signal, mute isolation, and timestamp and sequence continuity across mute gaps.

GitOrigin-RevId: 38b8438577cfadb8124f8aeb426dffbab4845964
2026-09-05 20:02:55 +00:00

38 lines
1.1 KiB
TOML

[package]
name = "codex-voice-host"
version.workspace = true
edition.workspace = true
license.workspace = true
[[bin]]
name = "codex-voice-host"
path = "src/main.rs"
[lints]
workspace = true
[dependencies]
codex-process-hardening = { workspace = true }
codex-realtime-webrtc = { workspace = true }
futures = { workspace = true }
libloading = "=0.8.9"
rand = { workspace = true }
rtc = "=0.20.3"
tokio = { workspace = true, features = ["rt-multi-thread", "sync", "time"] }
webrtc = "=0.20.3"
[target.'cfg(any(target_os = "macos", all(target_os = "linux", target_env = "gnu"), all(windows, target_env = "msvc")))'.dependencies]
cpal = "=0.18.2"
crossbeam-queue = "0.3.12"
opus = "=0.4.0"
rubato = { version = "=5.0.0", default-features = false }
sonora = { version = "=0.2.0", default-features = false }
[dev-dependencies]
anyhow = { workspace = true }
codex-install-context = { workspace = true }
codex-utils-cargo-bin = { workspace = true }
pretty_assertions = { workspace = true }
tempfile = { workspace = true }
tokio = { workspace = true, features = ["io-util", "macros", "process", "rt-multi-thread", "time"] }