Registry / devops / soundcard

soundcard

JSON →
library0.4.6pypypiunverified

A cross-platform Python library for playing and recording audio with a focus on simplicity and no CPython extensions. Current version 0.4.6, released sporadically. Uses system audio APIs (ALSA/PulseAudio on Linux, CoreAudio on macOS, WASAPI on Windows). No external binaries required.

pip install soundcard
INSTALL
IMPORT
SIG · SOUNDCARD
S
soundcard
devopspythonv0.4.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

all_microphones
from soundcard import all_microphones
import soundcard as sc
all_speakers
from soundcard import all_speakers
import soundcard as sc
default_microphone
from soundcard import default_microphone
import soundcard as sc

Record 5 seconds of audio from the default microphone and play it back on the default speaker.

import soundcard as sc import numpy as np # Record 5 seconds of default mic mic = sc.default_microphone() data = mic.record(samplerate=48000, numframes=48000*5) # Play back on default speaker spk = sc.default_speaker() spk.play(data, samplerate=48000)
Debug
Known issues
gotchadefault_microphone() and default_speaker() may return None if no audio device is available. Always check for None before calling methods.
fix
if mic is None: raise RuntimeError('No microphone found')
affects: all
gotcharecord() blocks until numframes are captured. For continuous streaming, use a loop with smaller frame sizes. There is no built-in non-blocking mode.
fix
Use a loop: for _ in range(10): data = mic.record(samplerate=44100, numframes=44100)
affects: all
deprecatedThe 'index' parameter in get_microphone() and get_speaker() is deprecated and may be removed. Use device name strings instead.
fix
Use get_microphone(name='Device Name') or list all devices with sc.all_microphones()
affects: >=0.4.0
gotchaOn Linux with PulseAudio, the default device may change if PulseAudio is restarted. Use specific device names to avoid issues.
fix
name = 'Built-in Audio Analog Stereo'; mic = sc.get_microphone(name)
affects: all
breakingIn version 0.4.0, the API changed from callbacks to blocking record/play. Old callback code will break.
fix
Replace callbacks with recorder = mic.record(…); speaker.play(…)
affects: 0.3.0 -> 0.4.0
Upgrade
Version history
0.4.6latest on PyPI · released Apr 12, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
8
Resources
soundcard — pip install soundcard · libregistry