PortAudio fork with WASAPI loopback support
Project description
PyAudioWPatch
PyAudioW(indows|ASAPI)Patch
This fork will allow you to use the WASAPI device as loopback using PyAudio.
For whom?
If you want to record sound from your speakers in python, then this is the fork for you.
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!
Installation
pip install PyAudioWPatch
Wheels are currently only available for Windows x64 Python 3.{6,7,8,9,10,11}. I will try to add x32 before 09/11/22
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 staf
...
Or in original PyAudio way:
import pyaudiowpatch as pyaudio
p = pyaudio.PyAudio()
stream = p.open(...)
# Do some staf
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
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 devices
- new features:
- Context manager support, for PyAudio(manager) and Stream classes
- Run
python -m pyaudiowpatch
to get list of devices(likeprint_detailed_system_info
call)
Examples:
- Play sine, using 'new context manager'
- Record from audio from default speakers
- 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)
Installpython- run in the PyAudioWPatch directory:
python setup.py install
- ???
- Profit.
Origin README
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
examples
directory of the source distribution, or see the project homepage.
License
PyAudio is distributed under the MIT License. See LICENSE.txt.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file PyAudioWPatch-0.2.12.3-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: PyAudioWPatch-0.2.12.3-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 85.4 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30eede97d00cd61af2a0c7081387bdf0abdff83df22adcaf816d2059e2280f33 |
|
MD5 | 9e5c3674598576dd427b9aaa90d3b171 |
|
BLAKE2b-256 | 0f5293e249897321d7006e700d6f3112046ca7bd9a771b52e85328bd49bee3ea |
File details
Details for the file PyAudioWPatch-0.2.12.3-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: PyAudioWPatch-0.2.12.3-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 85.4 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6e0c37a701d558bf9061da67d8ace14d4d089c368da5701019c83c2fcfdce96 |
|
MD5 | 51d71f156bf27e53c2a38c3e09b4d3a3 |
|
BLAKE2b-256 | ab8b99de9bfd9e41b64ab8658e642579071143daddc22595a23bd25d95944906 |
File details
Details for the file PyAudioWPatch-0.2.12.3-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: PyAudioWPatch-0.2.12.3-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 85.4 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6127549968a9f17ffbf5748659a4dd153504cdcaa37bac693ffbe7b04974e62a |
|
MD5 | 7b7fa43b2b63d473549c88b638ff77f3 |
|
BLAKE2b-256 | b4fd10910c1ef23b959273166c5de58e8de278f0cc2a085eab4dcdfed9d5827d |
File details
Details for the file PyAudioWPatch-0.2.12.3-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: PyAudioWPatch-0.2.12.3-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 85.5 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29b85c2935a2c2e87dd3fe532df54191752b7b08bdc76f4e887d5ed0a364bbbb |
|
MD5 | fe9af34793d71cd8e78bf5e37dc9df25 |
|
BLAKE2b-256 | f95971abe3e2beaf6326d5bd38011ae813c38d665e87072c6a26d87c77bdf7e4 |
File details
Details for the file PyAudioWPatch-0.2.12.3-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: PyAudioWPatch-0.2.12.3-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 85.4 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0390c638a27103e759cfb754586e7d9029f5124ae15399abc38ee9f7828e721f |
|
MD5 | eecf2dcf82f7c405024e90ae3031b5db |
|
BLAKE2b-256 | 35f8e2c37b9c61a3ba10d839a6626830482e2ac6ab78d39dc3f947d1ab4979f1 |
File details
Details for the file PyAudioWPatch-0.2.12.3-cp36-cp36m-win_amd64.whl
.
File metadata
- Download URL: PyAudioWPatch-0.2.12.3-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 84.9 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 971bca1e23fb9bf854bc6838dfa9f540f5aa3e5de4848f3c28949df006214aa7 |
|
MD5 | 1bdbb04e6a3605726a6414bf33dd62ed |
|
BLAKE2b-256 | ff828113c675de01e2039401b3f8f1215b13722e18cfec64fd2b0ede699fcf8b |