PortAudio fork with WASAPI loopback support
Project description
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.
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 available for Windows, Python 3.{7,8,9,10,11}.
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
- Returnloopback
for default speakersget_wasapi_loopback_analogue_by_index
- Returnloopback
for device via indexget_wasapi_loopback_analogue_by_dict
- Returnloopback
for device related toinfo_dict
get_default_wasapi_device
- Return default (out/in)put device forWASAPI
driver
-
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 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)
Installpython- 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
./wheelhouse
folder
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
Hashes for PyAudioWPatch-0.2.12.6-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5d3395aa9ab6ce59be7e18df84be9b749725b606317cd9290496082fac8256d |
|
MD5 | de0290c170a184dc6ece6bfa337eb408 |
|
BLAKE2b-256 | a2d64fb6a716f3d33002cc5992ce299fb3c3415172b120c65fc8fd8d905b413c |
Hashes for PyAudioWPatch-0.2.12.6-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6121c247f2c4417cbbcbe9cbb419b8883370d2b9951f798cf1031a55495b97a0 |
|
MD5 | f12057cac89cd652e35d638a663f2f7e |
|
BLAKE2b-256 | 193e6e0a77677247754ef0c20ee0da8dd579dc4e7f6e5e029496dd0c66d82f86 |
Hashes for PyAudioWPatch-0.2.12.6-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff9642f32d6cc9fb183c88f36a9a34d8a7f0434dd96022ec7d235732c07c2188 |
|
MD5 | b3ab20b73f69499a627c18b55d43e630 |
|
BLAKE2b-256 | ffc4cfa2066e9cd1938468c609a75ed32784bc30aac25c50b10d891e96d46989 |
Hashes for PyAudioWPatch-0.2.12.6-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ae26f1f7d6b76f9a6d124daef4922b12572b4f393fbe99637ea89cb03e390d8 |
|
MD5 | 602efd917ce1fc327867d64777d41814 |
|
BLAKE2b-256 | 7b75a8cdeb8da773260e03566441ea3ee58a4077dd9fd8e022099ccdfa39e5b4 |
Hashes for PyAudioWPatch-0.2.12.6-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 962fe6f210aa1e1d62d8ac5f433ee7095603989f614754c819995f2328150b51 |
|
MD5 | 5c0c5030abe369a091ae5362a2c4164d |
|
BLAKE2b-256 | 9299cd5c957cda1e85b8be27f94409712b311e9085eb49e026b3fb6de930decb |
Hashes for PyAudioWPatch-0.2.12.6-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3eac00d775820ee9f2f07f91965c93eb6b06864356ae197489be632add13d5e8 |
|
MD5 | c03adb54d1e0dbf7816968b5a17e4f20 |
|
BLAKE2b-256 | b9c39e156a4353fb7706e656da2f1a605820ef791b1e0e08becb1e62d008d5f5 |
Hashes for PyAudioWPatch-0.2.12.6-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8d803a08ddab5e97b25df4e506b955d97a067bbccdff13f5b70115ddeeb0e5d |
|
MD5 | b738959d2172d65da0dbd805916e1ebd |
|
BLAKE2b-256 | 27bd370ae7a9ee6100afed45e50e8f7ecc204617f47b379b95216a40eee30282 |
Hashes for PyAudioWPatch-0.2.12.6-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d80712f502e0709fee3c93b568ed69343b6a2ba5b0e2e9c72d7ca19a91c1c87a |
|
MD5 | 69aa10870cee6960653a0a5d3c81c2f1 |
|
BLAKE2b-256 | 66ab441537e5a2b5cc71f862658547e90be736d17e120dbc146ff539dd92dd1a |
Hashes for PyAudioWPatch-0.2.12.6-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfcd7708c84fc7d0bbb29f27235369d3f547459f124b088a5f7281e72cd2daeb |
|
MD5 | 16bd7d8c90aecbb5bfecc4ba3abed874 |
|
BLAKE2b-256 | 051fbcae8b8e98b6872ce71e08d4aa6712dd57bb3bd70198441f9d56ccaa9658 |
Hashes for PyAudioWPatch-0.2.12.6-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3142092a8be291879d8fb3f99871bbe19225f30894b27721c804eec401e3dbfa |
|
MD5 | f049dd6997991c9d4ac38c4f6c5c3ab3 |
|
BLAKE2b-256 | 0c3f4e0919149216cabcb9c3b7baf39d7aa2d7d55b550fdf6adfff0ede5c527f |
Hashes for PyAudioWPatch-0.2.12.6-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3014ff6c35e844b4977b0c201b74f69ad7319cdf2fc17b7658c8017bca0414e |
|
MD5 | a475db2a9e6029ab619fc673dcac0e7d |
|
BLAKE2b-256 | 0f609f76683875689db588df0bd90c0a02b4548c4a6de37d82c1497f3c0f0282 |
Hashes for PyAudioWPatch-0.2.12.6-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42bd9bb177575d2c4cf039513be48254694d670841029e0a7c70d8949025e802 |
|
MD5 | a2de74fab2de41ab9feeb24c1c601e3c |
|
BLAKE2b-256 | b3afeba2e7b650e0b1feebf514ce24fd0af45d3b3cc4ea1a5bc6d3e83b77b557 |