开发者

Capturing Mac OS X System Audio output with Python

开发者 https://www.devze.com 2022-12-30 23:19 出处:网络
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 soun

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 o开发者_JAVA百科r other FOSS Python Library?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消