Skip to content
capture-system-or-process-audio — Cross-platform system speaker loopback, single application/process, and microphone PCM audio capture library for Python, Rust, C++17, and C11

capture-system-or-process-audio

Capture system speakers, isolate any single app/process, or mix microphones into one live PCM stream across Windows, Linux & macOS.

Native WASAPI · PipeWire · PulseAudio · Core Audio Process Taps · ScreenCaptureKit — zero virtual audio cables, zero silent fallbacks.

Created by @s0d3s — author of PyAudioWPatch (140,000+ monthly PyPI downloads, 340+ dependent repos) — nearly a year of ground-up safe-Rust engineering & polish.

Pick your language — your selection stays synced across every guide on this site:

Terminal window
pip install "capture-system-or-process-audio[numpy]"
python -m capture_system_or_process_audio
import capture_system_or_process_audio as cspa
# List & filter active audio apps deterministically (or use cspa.find_app("Zoom")):
apps = [a for a in cspa.discover().applications if a.active_audio is True]
app_target = apps[0].with_gain(0.9) if apps else cspa.default_output()
# Mix default microphone + app into one 16 kHz mono float32 stream for Whisper / STT:
converter = cspa.OutputConverter(rate=16000, channels=1, sample_format="f32")
with cspa.capture(
[cspa.microphone(), app_target],
output_converter=converter,
silence_on_idle=True,
) as stream:
outcome = stream.read(frames=1600, timeout_ms=200) # 100 ms @ 16 kHz
for block in outcome.blocks:
samples = block.to_numpy() # zero-copy view, shape: (frames, 1), dtype: float32

System Speaker Loopback

Capture whatever is playing on speakers or headphones without installing VB-Cable, BlackHole, or Soundflower — automatically tracking OS default-endpoint switches in Follow mode.

Single App & Process Isolation

Record audio from only Spotify, Zoom, Firefox, or a game (including helper child processes where supported) without capturing unrelated desktop notifications.

Microphones & Audio Inputs

Capture default or specific microphones with automatic Linux .monitor sink exclusion and event-driven default-input handover.

Drift-Synced Live Mixer & Resampler

Combine [microphone(), find_app("Zoom")] via CspaMixer into one clock-drift-compensated PCM stream converted on the fly to 16 kHz mono f32/i16, 44.1 kHz, or 48 kHz stereo.

Honest 5-State OS Permissions

Preflight or prompt macOS TCC (Microphone, SystemAudio, ScreenRecording) and Windows ConsentStore / GPO with macOS missing-Info.plist SIGABRT protection.

Zero-Allocation Real-Time Core

Preallocated bounded slot pools perform 0 heap allocations on warmed read_into loops across Rust, Free-Threaded Python 3.14t/3.15t (-Xgil=0), C++17, and C11.


Four years ago, @s0d3s created PyAudioWPatch to bring Windows WASAPI speaker loopback to Python’s PyAudio. Today it is the standard Windows loopback package in the Python ecosystem — serving 140,000+ monthly PyPI downloads (~1.6M+ annually) and powering 340+ open-source repositories across AI meeting copilots, live Whisper/STT transcription bots, voice agents, and desktop recorders.

140,000+ / mo

PyAudioWPatch PyPI downloads (~1.6M+ / yr) proven in production

340+ Repos

Open-source meeting copilots, STT pipelines & recorders built on it

4+ Years

Real-world WASAPI loopback bug reports & edge-case lessons

~1 Year R&D

Dedicated ground-up engineering & polish in safe Rust for this library

Why PyAudioWPatch Hit an Architectural Wall — and Why This Took Nearly a Year to Build

Section titled “Why PyAudioWPatch Hit an Architectural Wall — and Why This Took Nearly a Year to Build”

As PyAudioWPatch grew, users repeatedly requested capabilities that were architecturally impossible to implement inside a legacy PortAudio C wrapper:

  • Per-application isolation & macOS / Linux support: PortAudio models hardware endpoints only — it cannot attach to Windows per-process loopback trees, Linux PipeWire/PulseAudio application graphs, or macOS Core Audio Process Taps / ScreenCaptureKit without throwing away the underlying C engine (leaving macOS and Linux users stuck installing BlackHole or VB-Cable).
  • Real-world loopback traps that break naive recorders: Silent WASAPI speakers emit zero packets (causing blocking stream.read() loops in PyAudioWPatch to hang forever); unplugging headphones breaks pinned streams; combining [Microphone + App/System Audio] drifts out of sync across independent hardware clocks; and Free-Threaded Python 3.14t/3.15t (-Xgil=0) collides with PortAudio’s global C state.

Rather than bolting fragile workarounds onto a 20-year-old C wrapper, capture-system-or-process-audio is the result of nearly a year of dedicated ground-up development and polish in safe Rust — turning years of PyAudioWPatch production feedback into one zero-steady-state-allocation engine across Python, Rust, C++17, and C11:

Capability capture-system-or-process-audio PyAudioWPatch sounddevice / PyAudio cpal (Rust) Virtual Cables (VB-Cable / BlackHole)
System Speaker Loopback ✅ Win · Linux · macOS ✅ Windows only ❌ ⚠️ Partial ⚠️ Manual driver install
Single App / Process Tree Isolation ✅ Win · Linux · macOS ❌ ❌ ❌ ❌
Microphone + App/System Live Mix ✅ Built-in (CspaMixer + drift sync) ❌ Manual ❌ Manual ❌ Manual ⚠️ Manual multi-output
Silent-Speaker Hang Protection ✅ (silence_on_idle + timeouts) ❌ Hangs read() ❌ ❌ N/A
Auto-Follow Default Device Switches ✅ (Follow mode) ❌ ❌ ❌ ❌ Breaks volume keys
Built-In Resampler & Format Converter ✅ (16k/44.1k/48k, f32/i16/i24/i32) ❌ ❌ ❌ ❌
OS Permission Preflight & Prompt API ✅ Honest 5-state report ❌ ❌ ❌ N/A
Free-Threaded Python (3.14t/3.15t) ✅ Native (Py_MOD_GIL_NOT_USED) ❌ ❌ N/A N/A
First-Class SDKs Python, Rust, C++17, C11 Python (Win) Python Rust OS Driver

Already using PyAudioWPatch? Jump straight to the Side-by-Side PyAudioWPatch Migration Guide.


When a requested scope or capability is unsupported on the active OS or OS build, capture-system-or-process-audio fails explicitly with a typed error (CapabilityError / PlanError) — it never silently substitutes full-system audio for single-process capture.

Platform Native Backends System & Device Output Application / Process Capture Microphones & Inputs
Windows 10 / 11 (x64, ARM64) wasapi ✅ Build 19041+ (Follow/Pin, device) ✅ Build 20348+ (scope="tree"; exact rejected explicitly) ✅ Build 19041+ (Follow/Pin, input_device)
Linux (x86_64, aarch64) pipewire (0.3.65+), pulseaudio (15.0+) ✅ Sink monitor & default sink tracking ✅ PipeWire virtual-sink fan-in (tree/exact) & PulseAudio stream mix ✅ Physical/virtual sources (0 compile-time NEEDED links)
macOS (Apple Silicon arm64) coreaudio, screencapturekit ✅ macOS 14.2+ Core Audio Process Taps ✅ macOS 14.2+ Core Audio Taps (tree/exact) & macOS 13.0+ SCK (exact) ✅ macOS 13.0+ Core Audio HAL input (AVMediaTypeAudio)

Next Release Preview: Drop-In Ecosystem Adapters & Node.js SDK Planned

Section titled “Next Release Preview: Drop-In Ecosystem Adapters & Node.js SDK Planned ”

Planned — Next Release

Today’s release connects directly to NumPy (block.to_numpy(copy=False)), faster-whisper (16 kHz mono f32), wave, asyncio, Rust, and C/C++. Next release adds zero-rewrite drop-in compatibility adapters (PyAudio/PyAudioWPatch, python-sounddevice, SoundCard, SpeechRecognition, Whisper sliding-window streams) alongside first-class napi-rs Node.js / TypeScript / Electron bindings.