print('%s - saved %d seconds audio to %s'%(now,duration,filename))
ifself.target=='test':
self.play(filename)
defend(self):
# Reset to default error handler
self.p.terminate()
asound.snd_lib_error_set_handler(None)
if__name__=='__main__':
description='This script is a voice activate recorder that saves individual recording in the folder %s that is polled by sip-session to initiate an outgoing call and playback the file. The filename is in the format user@domain.wav. Use test argument to test audio level.'%f_name_directory
parser.add_option('-T','--timeout',type='int',default=2,dest='timeout',help='Silence timeout to stop recording')
parser.add_option('-m','--min_rec_time',type='int',default=1,dest='min_rec_time',help='Minimum recording time to save recording')
parser.add_option('-M','--max_rec_time',type='int',default=5,dest='max_rec_time',help='Maximum recording time for each file')
parser.add_option('-t','--threshold',type='int',default=10,dest='threshold',help='Minimum signal level to start recording')
parser.add_option('-l','--level_lock_file',type='string',dest='level_lock_file',help='Skip level recording if file exists')
parser.add_option('-L','--level_enable_file',type='string',dest='level_enable_file',help='Enable level recording only if file exists')
parser.add_option('-e','--external_lock_file',type='string',dest='external_lock_file',help='Skip recording if file exists')
parser.add_option('-E','--external_trigger_file',type='string',dest='external_trigger_file',help='Start recording if file exists, regardless of level')