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.4-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: PyAudioWPatch-0.2.12.4-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 | c7f2750e39db93597e6006a5996814a179f58d2ba811a51212194c7aa64bad42 |
|
MD5 | 976bc4e8f14c65af109c597008e3d631 |
|
BLAKE2b-256 | 9ae26dd18711b03ce5c2a0924b865bf7dfadc475cc509dcd358bb0ba139a147f |
File details
Details for the file PyAudioWPatch-0.2.12.4-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: PyAudioWPatch-0.2.12.4-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 | 79cdc10ea64f2031850e9be92eeb048b209e9e0ca236a84d27b37fbff10ea537 |
|
MD5 | 3b87684db42072744df77b41e1515e62 |
|
BLAKE2b-256 | dab2a727f6990bfab5d55c6b224c37813963c88426cb8fb8e9892c749850de68 |
File details
Details for the file PyAudioWPatch-0.2.12.4-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: PyAudioWPatch-0.2.12.4-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 | e94210713fded8fb0978b20a67c2200e9d642e28926208da95802b0944c5c4d1 |
|
MD5 | 9b3f958fc2ef4038c8ca7f67bdf13be6 |
|
BLAKE2b-256 | f4fe536e6b93e6a68268fa2ef335e0a1cb68279f3e1ef0b1f6703e530b32b45c |
File details
Details for the file PyAudioWPatch-0.2.12.4-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: PyAudioWPatch-0.2.12.4-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 | 7bcb5c57364d801d695aa7b999383f9b3d9e34a0a5434f6e1888152dc74d69b9 |
|
MD5 | 0fa2e27d60faa14c3fd469f9e3722656 |
|
BLAKE2b-256 | 70e602526306de923103f0cc5ae5e3321cf82d5a9eabd8b55c87e47b84396f33 |
File details
Details for the file PyAudioWPatch-0.2.12.4-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: PyAudioWPatch-0.2.12.4-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 | 82dcf3ea9974bb275e7b23300c53256e3865a94e0b74406183abd3ecb5a9c0a1 |
|
MD5 | a922664e5184876f57b25e3011ac4c45 |
|
BLAKE2b-256 | b2027f95ce9ecfebd5f061256592abc1d4760b0d2dae2603099037eb6d19a89a |
File details
Details for the file PyAudioWPatch-0.2.12.4-cp36-cp36m-win_amd64.whl
.
File metadata
- Download URL: PyAudioWPatch-0.2.12.4-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 84.8 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 | 04390837700ee6ab02aabeec95bc2c115724c2781e16614298dd53a8e6040ce3 |
|
MD5 | 04f34e819747811c3942684be258d201 |
|
BLAKE2b-256 | d2490a53aa12c30f1aa4e2f18648f0e61887eef13a8b3563ac423c86e9a5d683 |