Skip to main content

PortAudio fork with WASAPI loopback support

Project description

PyAudio Wasapi Loopback Patch

PyAudioWPatch

This fork will allow you to use the WASAPI device as loopback using PyAudio.
So you can use speakers to record audioвњЁ

Last Commit Wheels Downloads Py Version Latest release



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

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.6-cp312-cp312-win_amd64.whl (86.1 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

PyAudioWPatch-0.2.12.6-cp312-cp312-win32.whl (84.2 kB view hashes)

Uploaded CPython 3.12 Windows x86

PyAudioWPatch-0.2.12.6-cp311-cp311-win_amd64.whl (86.3 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

PyAudioWPatch-0.2.12.6-cp311-cp311-win32.whl (84.1 kB view hashes)

Uploaded CPython 3.11 Windows x86

PyAudioWPatch-0.2.12.6-cp310-cp310-win_amd64.whl (86.3 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

PyAudioWPatch-0.2.12.6-cp310-cp310-win32.whl (84.0 kB view hashes)

Uploaded CPython 3.10 Windows x86

PyAudioWPatch-0.2.12.6-cp39-cp39-win_amd64.whl (86.3 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

PyAudioWPatch-0.2.12.6-cp39-cp39-win32.whl (84.0 kB view hashes)

Uploaded CPython 3.9 Windows x86

PyAudioWPatch-0.2.12.6-cp38-cp38-win_amd64.whl (86.3 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

PyAudioWPatch-0.2.12.6-cp38-cp38-win32.whl (84.0 kB view hashes)

Uploaded CPython 3.8 Windows x86

PyAudioWPatch-0.2.12.6-cp37-cp37m-win_amd64.whl (86.3 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

PyAudioWPatch-0.2.12.6-cp37-cp37m-win32.whl (84.0 kB view hashes)

Uploaded CPython 3.7m Windows x86

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