Skip to main content

PortAudio fork with WASAPI loopback support

Project description

PyAudioWasapiLoopbackPatch

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 features:
    • Context manager support, for PyAudio(manager) and Stream classes
    • Run python -m pyaudiowpatch to get list of devices(like print_detailed_system_info call)

Examples:

Sources

The following were taken as a basis:

How to build manually

  • Build PortAudio (using the instructions in the README)
  • Install python
  • 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

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

PyAudioWPatch-0.2.12.3-cp311-cp311-win_amd64.whl (85.4 kB view details)

Uploaded CPython 3.11 Windows x86-64

PyAudioWPatch-0.2.12.3-cp310-cp310-win_amd64.whl (85.4 kB view details)

Uploaded CPython 3.10 Windows x86-64

PyAudioWPatch-0.2.12.3-cp39-cp39-win_amd64.whl (85.4 kB view details)

Uploaded CPython 3.9 Windows x86-64

PyAudioWPatch-0.2.12.3-cp38-cp38-win_amd64.whl (85.5 kB view details)

Uploaded CPython 3.8 Windows x86-64

PyAudioWPatch-0.2.12.3-cp37-cp37m-win_amd64.whl (85.4 kB view details)

Uploaded CPython 3.7m Windows x86-64

PyAudioWPatch-0.2.12.3-cp36-cp36m-win_amd64.whl (84.9 kB view details)

Uploaded CPython 3.6m Windows x86-64

File details

Details for the file PyAudioWPatch-0.2.12.3-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for PyAudioWPatch-0.2.12.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 30eede97d00cd61af2a0c7081387bdf0abdff83df22adcaf816d2059e2280f33
MD5 9e5c3674598576dd427b9aaa90d3b171
BLAKE2b-256 0f5293e249897321d7006e700d6f3112046ca7bd9a771b52e85328bd49bee3ea

See more details on using hashes here.

File details

Details for the file PyAudioWPatch-0.2.12.3-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for PyAudioWPatch-0.2.12.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d6e0c37a701d558bf9061da67d8ace14d4d089c368da5701019c83c2fcfdce96
MD5 51d71f156bf27e53c2a38c3e09b4d3a3
BLAKE2b-256 ab8b99de9bfd9e41b64ab8658e642579071143daddc22595a23bd25d95944906

See more details on using hashes here.

File details

Details for the file PyAudioWPatch-0.2.12.3-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for PyAudioWPatch-0.2.12.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 6127549968a9f17ffbf5748659a4dd153504cdcaa37bac693ffbe7b04974e62a
MD5 7b7fa43b2b63d473549c88b638ff77f3
BLAKE2b-256 b4fd10910c1ef23b959273166c5de58e8de278f0cc2a085eab4dcdfed9d5827d

See more details on using hashes here.

File details

Details for the file PyAudioWPatch-0.2.12.3-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for PyAudioWPatch-0.2.12.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 29b85c2935a2c2e87dd3fe532df54191752b7b08bdc76f4e887d5ed0a364bbbb
MD5 fe9af34793d71cd8e78bf5e37dc9df25
BLAKE2b-256 f95971abe3e2beaf6326d5bd38011ae813c38d665e87072c6a26d87c77bdf7e4

See more details on using hashes here.

File details

Details for the file PyAudioWPatch-0.2.12.3-cp37-cp37m-win_amd64.whl.

File metadata

File hashes

Hashes for PyAudioWPatch-0.2.12.3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 0390c638a27103e759cfb754586e7d9029f5124ae15399abc38ee9f7828e721f
MD5 eecf2dcf82f7c405024e90ae3031b5db
BLAKE2b-256 35f8e2c37b9c61a3ba10d839a6626830482e2ac6ab78d39dc3f947d1ab4979f1

See more details on using hashes here.

File details

Details for the file PyAudioWPatch-0.2.12.3-cp36-cp36m-win_amd64.whl.

File metadata

File hashes

Hashes for PyAudioWPatch-0.2.12.3-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 971bca1e23fb9bf854bc6838dfa9f540f5aa3e5de4848f3c28949df006214aa7
MD5 1bdbb04e6a3605726a6414bf33dd62ed
BLAKE2b-256 ff828113c675de01e2039401b3f8f1215b13722e18cfec64fd2b0ede699fcf8b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page