tags:

views:

184

answers:

2

Hello,

I've been trying to "hijack" the Mac OS X system audio using PyAudio and save to a wav in python. That is, I do not want to record from an input device such as a microphone. I want to grab the sound output from any or all applications.

I have followed the tutorials on the PyAudio site but these do not appear to cover my use case and when I try to read from the output stream I unsurprisingly get the paCanNotReadFromAnOutputOnlyStream exception. Fair enough! Is there a way to do what I am proposing with the PyAudio or other FOSS Python Library?

+1  A: 

If you're willing to install an extra component you can try Jack OS X to pipe the input from the source application to PyAudio.

In PyAudio you will have to use the "Jack Router" virtual device that will appear as an input audio device.

diciu
+1  A: 

I found that an open-source project called SoundFlower got me quickly to the place I needed to be.

  1. I installed the SoundFlower package from Google Code.
  2. Opened System Preferences -> Sound
  3. Chose Soundflower as my Output device
  4. Chose Soundflower as my Input device

I was then able to record system audio from the default device using PyAudio. No sound comes from the speakers/headphones in this situation though. I wonder if you could use Jack OS X to route audio out of SoundFlower to the system audio out.

richbs