How to record audio from Python on Mac?

has has.temp3 at
Tue Sep 9 23:44:58 CEST 2008

On 9 Sep, 19:55, David Thole <dth... at> wrote:

> Another option you could use is calling Applescript from the command
> line, to open, execute, and handle audio.

For example, using QuickTime Player (which is a buggy, poorly designed
piece of junk, but might suffice if you only need something quick-n-
dirty and aren't too fussy):


from time import sleep
from appscript import *

duration = 5 # seconds
outpath = '/Users/foo/test.aiff'

qtp = app('QuickTime Player')
qtp.documents[1].export(to=mactypes.File(outpath), as_=k.AIFF)

Or, if you're on Leopard and want something a bit more polished, you
could look into using the new QTKit framework via PyObjC. Dunno about
Python-specific examples, but I imagine you could dig up some ObjC
code if you search around a bit and then convert that over to Python


Control AppleScriptable applications from Python, Ruby and ObjC:

More information about the Python-list mailing list