Changeset 8dd5d40 for python/lib
- Timestamp:
- Sep 16, 2017, 4:41:04 PM (7 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master
- Children:
- c81c3d2
- Parents:
- eb8f7d5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/lib/aubio/cmd.py
reb8f7d5 r8dd5d40 34 34 parser_add_subcommand_melbands(subparsers) 35 35 parser_add_subcommand_quiet(subparsers) 36 parser_add_subcommand_cut(subparsers) 36 37 37 38 return parser … … 135 136 subparser.add_verbose_help() 136 137 subparser.set_defaults(process=process_quiet) 138 139 def parser_add_subcommand_cut(subparsers): 140 # quiet subcommand 141 subparser = subparsers.add_parser('cut', 142 help='slice at timestamps') 143 subparser.add_input() 144 helpstr = "onset novelty function" 145 helpstr += " <default|energy|hfc|complex|phase|specdiff|kl|mkl|specflux>" 146 subparser.add_method(helpstr=helpstr) 147 subparser.add_buf_hop_size() 148 #subparser.add_silence() 149 subparser.add_threshold(default=0.3) 150 subparser.add_minioi() 151 subparser.add_slicer_options() 152 #subparser.add_time_format() 153 subparser.add_verbose_help() 154 subparser.set_defaults(process=process_cut) 137 155 138 156 class AubioArgumentParser(argparse.ArgumentParser): … … 212 230 default=None, 213 231 help=helpstr) 232 233 def add_slicer_options(self): 234 self.add_argument("-o","--output", type = str, 235 metavar = "<outputdir>", 236 action="store", dest="output_directory", default=None, 237 help="specify path where slices of the original file should be created") 238 self.add_argument("--cut-until-nsamples", type = int, 239 metavar = "<samples>", 240 action = "store", dest = "cut_until_nsamples", default = None, 241 help="how many extra samples should be added at the end of each slice") 242 self.add_argument("--cut-every-nslices", type = int, 243 metavar = "<samples>", 244 action = "store", dest = "cut_every_nslices", default = None, 245 help="how many slices should be groupped together at each cut") 246 self.add_argument("--cut-until-nslices", type = int, 247 metavar = "<slices>", 248 action = "store", dest = "cut_until_nslices", default = None, 249 help="how many extra slices should be added at the end of each slice") 214 250 215 251 # some utilities … … 439 475 fmt_out += self.time2string(frames_read, samplerate) 440 476 sys.stdout.write(fmt_out + '\n') 477 478 class process_cut(process_onset): 479 def __init__(self, args): 480 super(process_cut, self).__init__(args) 481 self.slices = [] 482 self.options = args 483 484 def __call__(self, block): 485 ret = super(process_cut, self).__call__(block) 486 if ret: self.slices.append(self.onset.get_last()) 487 return ret 488 489 def flush(self, frames_read, samplerate): 490 from aubio.cut2 import _cut_slice 491 _cut_slice(self.options, self.slices) 492 duration = float (frames_read) / float(samplerate) 493 base_info = '%(source_file)s' % {'source_file': self.options.source_uri} 494 base_info += ' (total %(duration).2fs at %(samplerate)dHz)\n' % \ 495 {'duration': duration, 'samplerate': samplerate} 496 info = "created %d slices from " % len(self.slices) 497 info += base_info 498 sys.stderr.write(info) 441 499 442 500 def main():
Note: See TracChangeset
for help on using the changeset viewer.