Skip to main content

PortAudio fork with WASAPI loopback support

Project description

PyAudioWasapiLoopbackPatch

PyAudioWPatch

This fork will allow you to use the WASAPI device as loopback using PyAudio.

Last Commit Wheels Py Version Latest release



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 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 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
  • Ability to record audio from WASAPI loopback devices (see example)

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.

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

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.5-cp311-cp311-win_amd64.whl (85.9 kB view details)

Uploaded CPython 3.11 Windows x86-64

PyAudioWPatch-0.2.12.5-cp311-cp311-win32.whl (83.6 kB view details)

Uploaded CPython 3.11 Windows x86

PyAudioWPatch-0.2.12.5-cp310-cp310-win_amd64.whl (85.9 kB view details)

Uploaded CPython 3.10 Windows x86-64

PyAudioWPatch-0.2.12.5-cp310-cp310-win32.whl (83.6 kB view details)

Uploaded CPython 3.10 Windows x86

PyAudioWPatch-0.2.12.5-cp39-cp39-win_amd64.whl (85.9 kB view details)

Uploaded CPython 3.9 Windows x86-64

PyAudioWPatch-0.2.12.5-cp39-cp39-win32.whl (83.6 kB view details)

Uploaded CPython 3.9 Windows x86

PyAudioWPatch-0.2.12.5-cp38-cp38-win_amd64.whl (85.9 kB view details)

Uploaded CPython 3.8 Windows x86-64

PyAudioWPatch-0.2.12.5-cp38-cp38-win32.whl (83.6 kB view details)

Uploaded CPython 3.8 Windows x86

PyAudioWPatch-0.2.12.5-cp37-cp37m-win_amd64.whl (85.9 kB view details)

Uploaded CPython 3.7m Windows x86-64

PyAudioWPatch-0.2.12.5-cp37-cp37m-win32.whl (83.6 kB view details)

Uploaded CPython 3.7m Windows x86

File details

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

File metadata

File hashes

Hashes for PyAudioWPatch-0.2.12.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 cea403d7f19726e53004a6da38986733f63a050634b216ca3ec59677cd1bdf11
MD5 7da42b34eb688d4109de4b822d8cc80a
BLAKE2b-256 f304fe30ca579601fb5add95facca2dbe7ff7394e12ced9e450bf585d643064c

See more details on using hashes here.

File details

Details for the file PyAudioWPatch-0.2.12.5-cp311-cp311-win32.whl.

File metadata

File hashes

Hashes for PyAudioWPatch-0.2.12.5-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 6c496013a73d770571e4fa9a3d238c6fb347e2595da28be1eb7aba3beca7a12f
MD5 6f1b6426156bb9c7b81233d80ddbae23
BLAKE2b-256 66f674588087a0990f778c533f44c317b298a3e4a43e94de24c62e1d3bd9465c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for PyAudioWPatch-0.2.12.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d62d537b14d65f93c614ec3b30b6830e0b0bc797acab9e791a8db211cb17baba
MD5 3829bf0b06620dbeb3054b427a2700cb
BLAKE2b-256 460c76cacede7a33ce4313b1c0d84f7209cb7c840d0405de0f7e9f314e8e59cf

See more details on using hashes here.

File details

Details for the file PyAudioWPatch-0.2.12.5-cp310-cp310-win32.whl.

File metadata

File hashes

Hashes for PyAudioWPatch-0.2.12.5-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 3229e1fa7b687dcf8f1dcb50b429c2e70afaa72f3f1281833f1bfe293ada3e7a
MD5 e0a5af0711fc5e648ea7d4dd47a7c722
BLAKE2b-256 309f59da3ed76859b6fb172bed0a5cbcf0205091b479ac619e1e3cc897b2afee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for PyAudioWPatch-0.2.12.5-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 02d04eb3cdad52cef42e77a313b53c700fbc5f268f498e9f74cda41269a82547
MD5 cdd026421c92718521d348addbd02036
BLAKE2b-256 bb6ce428ed1b6e8e6c2623a261678d22bf236530631280df38fa4bd5fdf8d833

See more details on using hashes here.

File details

Details for the file PyAudioWPatch-0.2.12.5-cp39-cp39-win32.whl.

File metadata

File hashes

Hashes for PyAudioWPatch-0.2.12.5-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 2db78fe4f439a3332ce6b0e6da396b1adc750f953f2d58df10d2ad6704769357
MD5 6b9d1ac255b3afdd34cb72068f976f27
BLAKE2b-256 36fdce6228b16bae94b6f2f5c0ba48398700c171fcf1a741f69c9314fe6330e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for PyAudioWPatch-0.2.12.5-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 e6eec63fc514b02f4aab661bf16322f27287f378a0fdf9ad6202d5d1385cd30a
MD5 f51291b8543ddef8cc412c589e0055f3
BLAKE2b-256 b0cd119dce331470bfd3309a0ef187f843208d2e0169b5554f6a8294baeeb35c

See more details on using hashes here.

File details

Details for the file PyAudioWPatch-0.2.12.5-cp38-cp38-win32.whl.

File metadata

File hashes

Hashes for PyAudioWPatch-0.2.12.5-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 6a08af6d88c2e252316a7423fc1882ef9b2c6663bf59568831124e29904d8638
MD5 ac64c6b596767f990e62dfc7668d4e4f
BLAKE2b-256 d3cbe723eefc429d2ef0434fa0b87c80d276db8da7ebc0ddf4b4bf5b0778386e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for PyAudioWPatch-0.2.12.5-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 5ee7343c39b17bbd0c29ef18154a7048e9b05fff48fa1c1240057ff3b92cc077
MD5 b402d953a5db45dbd91de0402c85e7bf
BLAKE2b-256 a3eddd31d49dac6b486ee816b31c58a945727d71e0749f7e8cc00387e00ee349

See more details on using hashes here.

File details

Details for the file PyAudioWPatch-0.2.12.5-cp37-cp37m-win32.whl.

File metadata

File hashes

Hashes for PyAudioWPatch-0.2.12.5-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 e7cc58f7c9d2666048341bff9227aa74a00a613c944955f899898ffe72bd6d5f
MD5 faf8e62dc4507b55a10c943a2a92a932
BLAKE2b-256 3bf0d3c8bd8bd7534a06a2c530a8bd8c89dcb1976190b26192bf5fb42f477a64

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