Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
34 lines (28 sloc) 1.08 KB
# this is based in the audio recording example provided by omz (Ole Zorn)
from objc_util import *
import os
def main():
AVAudioSession = ObjCClass('AVAudioSession')
NSURL = ObjCClass('NSURL')
AVAudioRecorder = ObjCClass('AVAudioRecorder')
shared_session = AVAudioSession.sharedInstance()
category_set = shared_session.setCategory_error_(ns('AVAudioSessionCategoryPlayAndRecord'), None)
settings = {ns('AVFormatIDKey'): ns(1633772320), ns('AVSampleRateKey'):ns(44100.00), ns('AVNumberOfChannelsKey'):ns(2)}
output_path = os.path.abspath('Recording.m4a')
out_url = NSURL.fileURLWithPath_(ns(output_path))
recorder = AVAudioRecorder.alloc().initWithURL_settings_error_(out_url, settings, None)
started_recording = recorder.record()
if started_recording:
print('Recording started, press the "stop script" button to end recording...')
try:
while True:
pass
except KeyboardInterrupt:
print('Stopping...')
recorder.stop()
recorder.release()
print('Stopped recording.')
import console
console.quicklook(os.path.abspath('Recording.m4a'))
if __name__ == '__main__':
main()
You can’t perform that action at this time.