By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,608 Members | 1,584 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,608 IT Pros & Developers. It's quick & easy.

How to record audio from Python on Mac?

P: n/a
(I asked this on pythonmac-sig a couple days ago but got no response, so I'm
casting a broader net.)

Can I easily control audio record/playback from Python on my Mac? I know
zip about audio recording or about Apple APIs via Python. Pointers to
simple examples would be much appreciated.

Thanks,

Skip
Sep 9 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
sk**@pobox.com wrote:
(I asked this on pythonmac-sig a couple days ago but got no response, so I'm
casting a broader net.)

Can I easily control audio record/playback from Python on my Mac? I know
zip about audio recording or about Apple APIs via Python. Pointers to
simple examples would be much appreciated.

Thanks,

Skip
You can probably access this functionality via PyObjC--it provides
access to the Cocoa frameworks.

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
Sep 9 '08 #2

P: n/a
sk**@pobox.com wrote:
(I asked this on pythonmac-sig a couple days ago but got no response, so I'm
casting a broader net.)

Can I easily control audio record/playback from Python on my Mac? I know
zip about audio recording or about Apple APIs via Python. Pointers to
simple examples would be much appreciated.

Thanks,

Skip
You can probably access this functionality via PyObjC--it provides
access to the Cocoa frameworks.

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
Sep 9 '08 #3

P: n/a
On Sep 9, 1:11*pm, Kevin Walzer <k...@codebykevin.comwrote:
s...@pobox.com wrote:
(I asked this on pythonmac-sig a couple days ago but got no response, so I'm
casting a broader net.)
Can I easily control audio record/playback from Python on my Mac? *I know
zip about audio recording or about Apple APIs via Python. *Pointers to
simple examples would be much appreciated.
Thanks,
Skip

You can probably access this functionality via PyObjC--it provides
access to the Cocoa frameworks.

--
Kevin Walzer
Code by Kevinhttp://www.codebykevin.com
Another option you could use is calling Applescript from the command
line, to open, execute, and handle audio.

An easy example of this is with iTunes actually. Once you get iTunes
down, doing this for other apps should be easy (if they have
applescript bindings):
http://www.macosxhints.com/article.p...11108211802830

You could probably also do what Kevin recommends, but depending on
your needs, this may be a whole lot more simple.

-David Thole
http://www.thedarktrumpet.com
Sep 9 '08 #4

P: n/a
has
On 9 Sep, 19:55, David Thole <dth...@gmail.comwrote:
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):

#!/usr/bin/python

from time import sleep
from appscript import *

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

qtp = app('QuickTime Player')
qtp.new_audio_recording()
qtp.documents[1].start()
sleep(duration)
qtp.documents[1].stop()
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
yourself.

HTH

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

Sep 9 '08 #5

P: n/a
I want to do this as well, and also some other audio processing via
python. I have not tried yet, but much of my research points to
pyaudio, PortAudio bindings for python, which is supposed to be multi-
platform including Mac OS X, but as I say, I've not tried it yet.

Related to this are some examples that get the audio data into numpy
arrays for signal processing work. cheers, I'm interested to hear how
any of this works out, I'm trying to start a python audio project in
the next couple months.

cheers.

On Sep 9, 1:06 am, s...@pobox.com wrote:
(I asked this on pythonmac-sig a couple days ago but got no response, so I'm
casting a broader net.)

Can I easily control audio record/playback from Python on my Mac? I know
zip about audio recording or about Apple APIs via Python. Pointers to
simple examples would be much appreciated.

Thanks,

Skip
Sep 9 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.