spawn_pcm_capture (audio/capture_linux.rs)

grok-build · crates/codegen/xai-grok-voice/src/audio/capture_linux.rs · rust · Apache-2.0
voice, tag:knn-classified

Captures raw PCM audio on Linux by spawning system recorders, enabling static binary builds without linking native audio libraries.

// Source: https://github.com/xai-org/grok-build | License: Apache-2.0 | Copyright 2023-2026 SpaceXAI
// Provided via justclaw.it.com; keep this notice with the code.
//! Microphone capture on Linux via a subprocess recorder.
//!
//! The release CLI ships as a fully-static `*-unknown-linux-musl` binary.
//! Linking `cpal` pulls in `alsa-sys` (a `NEEDED libasound.so.2`), losing the static guarantee enforced by the release build.
//! Statically linking ALSA is no help either: it reaches the user's real device (PulseAudio/PipeWire) through plugins it loads via `dlopen`.
//! A static musl binary can't `dlopen`.
//!
//! Instead, capture spawns the system recorder (`pw-record`, `parec`, or `arecord`) and reads raw PCM16 mono from its stdout.
//! No native audio library is linked into the binary.

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key