Skip to content

Repository files navigation

Pycaw (Python Core Audio Windows)

Tests Coverage Status PyPI release PyPI version Documentation

Pycaw is a Python library designed exclusively for controlling audio devices on Windows systems. It allows programmatic access to audio sessions, volume control, and sound device management on the Windows platform.

Note: Pycaw does not support macOS or Linux. It is built specifically for Windows using Core Audio APIs. If you're looking for similar functionality on other platforms, you'll need alternative libraries.

Pycaw currently supports Python 3.10 through 3.14 on Windows. Supported Python versions are stable, non-EOL releases that have passed the project's Windows test matrix; newer Python releases are added after compatibility validation.

Install

Latest stable release:

pip install pycaw

Development branch:

pip install https://github.com/AndreMiras/pycaw/archive/main.zip

System requirements:

choco install visualcpp-build-tools

Usage

from pycaw.pycaw import AudioUtilities
device = AudioUtilities.GetSpeakers()
volume = device.EndpointVolume
print(f"Audio output: {device.FriendlyName}")
print(f"- Muted: {bool(volume.GetMute())}")
print(f"- Volume level: {volume.GetMasterVolumeLevel()} dB")
print(f"- Volume range: {volume.GetVolumeRange()[0]} dB - {volume.GetVolumeRange()[1]} dB")
volume.SetMasterVolumeLevel(-20.0, None)
# or work with the 0-100 scale the Windows volume mixer uses:
print(f"- Volume: {device.volume_percent:.0f}%")
device.volume_percent = 50

See more in the examples directory or visit the documentation.

Tests

Create the locked contributor environment and run the compatibility suite. uv uses .python-version to install/select Python 3.14 and supplies reproducible tools; Tox handles compatibility isolation.

uv sync --locked
uv run tox

Tox remains responsible for isolating the Python 3.10-3.14 minimum/current dependency matrix. To run one interpreter's lanes, use for example:

uv run tox -e py314-minimum,py314-current

Documentation and release tools are opt-in groups:

uv sync --locked --no-default-groups --group docs
uv run --no-sync sphinx-build -M html docs/source docs/_build

uv sync --locked --only-group release
uv run --no-sync python -m build
uv run --no-sync python -m twine check dist/*

Check or apply Ruff through the locked Tox environments:

uv run tox -e lint-check
uv run tox -e lint-format

Run the repository-local static type-checking boundary with:

uv run tox -e type-check

This check covers pycaw/constants.py, pycaw/utils.py, pycaw/callbacks.py, and the static contract fixture under tests/typecheck. It does not represent package-wide PEP 561 support.

Maintainers with a separately installed Tox and the tox-uv plugin can still run the equivalent tox commands directly. See the tests directory for the test suite.

The dependency files serve distinct purposes. [project].dependencies in pyproject.toml declares inclusive lower bounds for consumers; requirements.txt exactly pins the supported minimum test lane; Tox's current lane deliberately resolves the newest runtime dependencies; and uv.lock reproduces normal contributor tools. The lock supplements rather than replaces the minimum/current compatibility matrix.

About

Python Core Audio Windows Library

Resources

Stars

444 stars

Watchers

8 watching

Forks

Releases

Packages

Used by

Contributors

Languages