s0d3s/PyAudioWPatch
Acerca de
🐍 Windows WASAPI loopback fork of PyAudio/PortAudio enabling zero-cable speaker output recording in Python
Diseño y multimediaCrecimiento de estrellas medido
- in 24h
- 0
- in 7 days
- +1
- in 15 days
- +5
- in 1 month
- Actualización retrasada
Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.
README.md
Originalcapture-system-or-process-audio: Per-App, System Loopback & Mic Audio Capture for Python (Windows, Linux & macOS)
Need per-app audio isolation or macOS / Linux support? My new library(author of PyAudioWPatch), capture-system-or-process-audio lets you record a single app (Zoom, Spotify, browser, or game) without chat notifications, capture full speaker loopback, or mix microphone + app/system audio into one live PCM stream across Windows (WASAPI), Linux (PipeWire / PulseAudio), and Apple Silicon macOS (Core Audio / ScreenCaptureKit) — no virtual audio cables (VB-Cable / BlackHole) required. It also fixes silent-speaker read() hangs, follows default headphone switches automatically, resamples on the fly (16 kHz for Whisper / STT, zero-copy NumPy), and ships native bindings for Python 3.11–3.15t, Rust, C++17, C11 and upcoming Node.js.
pip install capture-system-or-process-audio · Python Quick Start · Migrate from PyAudioWPatch · Docs & API · PyPI
Recall.ai - API for desktop recording
If you’re looking for a hosted desktop recording API, consider checking out Recall.ai, an API that records Zoom, Google Meet, Microsoft Teams, in-person meetings, and more.
✨ PyAudioWPatch is sponsored by Recall.ai ✨
PyAudioWPatch
This fork will allow you to use the WASAPI device as loopback using PyAudio.
So you can use speakers to record audio ✨
For whom?
If you want to record sound from speakers in python, then this fork is for you. You can get recording from any device that supports WASAPI, for example, you can even record audio from Bluetooth headphones🎧
PyAudioW(indows|ASAPI)Patch come only with WMME, DirectX and WASAPI support if you need more -> create an issue
How
The Windows Audio Session API (WASAPI) allows you to use output devices (that support this API) in loopback mode. At the time of release, it was impossible to achieve this using the original version of PyAudio.
Note: Now WASAPI loopback devices are duplicated at the end of the list as virtual devices. That is, to record from speakers, you need to use not just a WASAPI device, but its loopback analogue. All loopback devices are input devices.
How to use
Read -> Install -> Enjoy! ↣ Press ⭐
Installation
pip install PyAudioWPatch
Wheels are available for Windows, Python 3.{7,8,9,10,11,12,13,14,15}.
All wheels support APIs: WMME, WASAPI, DirectX(DSound).
In code
With new features:
import pyaudiowpatch as pyaudio
with pyaudio.PyAudio() as p:
# Open PyA manager via context manager
with p.open(...) as stream:
# Open audio stream via context manager
# Do some stuff
...
Or in original PyAudio way:
import pyaudiowpatch as pyaudio
p = pyaudio.PyAudio()
stream = p.open(...)
# Do some stuff
...
stream.stop_stream()
stream.close()
# close PyAudio
p.terminate()
Difference with PyAudio
- The behavior of all standard methods is unchanged
- Added several life-improving methods
- Fixed problem with name encoding
- Ability to record audio from WASAPI loopback devices (see example)
More detailed
new methods:
get_host_api_info_generator- Iterate over all Host APIsget_device_info_generator- Iterate over all devicesget_device_info_generator_by_host_api- Iterate over all devices, by specific Host API(index/type)get_loopback_device_info_generator- Iterate over all devices(with loopback mode)print_detailed_system_info- Print some info about Host Api and devicesget_default_wasapi_loopback- Returnloopbackfor default speakersget_wasapi_loopback_analogue_by_index- Returnloopbackfor device via indexget_wasapi_loopback_analogue_by_dict- Returnloopbackfor device related toinfo_dictget_default_wasapi_device- Return default (out/in)put device forWASAPIdriver
new features:
- Context manager support, for PyAudio(manager) and Stream classes
- Run
python -m pyaudiowpatchto get list of devices(likeprint_detailed_system_infocall)
Examples:
- 🆕 Sequential recording from speakers
- Play sine, using 'new context manager'
- Record audio from default speakers
- Simple recording app
- Cross-platform concept (Not example)
Sources
The following were taken as a basis:
- PortAudio v19 [8b6d16f26ad660e68a97743842ac29b939f3c0c1]
- PyAudio v0.2.12
How to build manually
- Build PortAudio (using the instructions in the README)
- Install python
- run in the PyAudioWPatch directory:
python setup.py install - ???
- Profit.
Also you can build wheels:
pip install cibuildwheel- Run in Cygwin:
./cygwin_cibuildwheel_build.sh - Get your wheels in the
./wheelhousefolder

PyAudio
PyAudio provides Python bindings for PortAudio v19, the cross-platform audio I/O library. With PyAudio, you can easily use Python to play and record audio on a variety of platforms, such as GNU/Linux, Microsoft Windows, and Apple macOS.
PyAudio is distributed under the MIT License.
Installation
See the INSTALLATION file in the source distribution for details. In summary, install PyAudio using pip on most platforms.
Windows
python -m pip install pyaudio
This installs the precompiled PyAudio library with PortAudio v19 19.7.0 included. The library is compiled with support for Windows MME API, DirectSound, WASAPI, and WDM-KS. It does not include support for ASIO. If you require support for APIs not included, you will need to compile PortAudio and PyAudio.
macOS
Use Homebrew to install the prerequisite portaudio library, then install PyAudio using pip:
brew install portaudio
pip install pyaudio
GNU/Linux
Use the package manager to install PyAudio. For example, on Debian-based systems:
sudo apt install python3-pyaudio
Alternatively, if the latest version of PyAudio is not available, install it using pip. Be sure to first install development libraries for portaudio19 and python3.
Building from source
See the INSTALLATION file.
Documentation & Usage Examples
Read the API Documentation, or generate it from the source using
sphinx.Usage examples are in the
examplesdirectory of the source distribution, or see the project homepage.
License
PyAudio is distributed under the MIT License. See LICENSE.txt.
Explorar proyectos relacionados
Cargando…