Record speakers output with PyAudio

In case someone is still stumbling over this like me, I found a PyAudio fork to record the output on windows.

Explanation:

The official PyAudio build isn’t able to record the output. BUT with Windows Vista and above, a new API, WASAPI was introduced, which includes the ability to open a stream to an output device in loopback mode. In this mode the stream will behave like an input stream, with the ability to record the outgoing audio stream.

To set the mode, one has to set a special flag (AUDCLNT_STREAMFLAGS_LOOPBACK). Since this flag is not supported in the official build one needs to edit PortAudio as well as PyAudio, to add loopback support.

New option:

“as_loopback”:(true|false)

Leave a Comment