How to record audio from Python on Mac?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • skip@pobox.com

    How to record audio from Python on Mac?

    (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
  • Kevin Walzer

    #2
    Re: How to record audio from Python on Mac?

    skip@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

    Comment

    • Kevin Walzer

      #3
      Re: How to record audio from Python on Mac?

      skip@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

      Comment

      • David Thole

        #4
        Re: How to record audio from Python on Mac?

        On Sep 9, 1:11 pm, Kevin Walzer <k...@codebykev in.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):
        Macworld is your ultimate guide to Apple's product universe, explaining what's new, what's best and how to make the most out of the products you love.


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

        -David Thole
        Index page for the homepage for David Thole/www.thedarktrumpet.com

        Comment

        • has

          #5
          Re: How to record audio from Python on Mac?

          On 9 Sep, 19:55, David Thole <dth...@gmail.c omwrote:
          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_r ecording()
          qtp.documents[1].start()
          sleep(duration)
          qtp.documents[1].stop()
          qtp.documents[1].export(to=mact ypes.File(outpa th), 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:


          Comment

          • Craig Allen

            #6
            Re: How to record audio from Python on Mac?

            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

            Comment

            Working...