From c9c012e61e07a5e4b1fe44e70bab45dc34ff7d5a Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Mon, 29 Oct 2018 15:32:24 +0100 Subject: [PATCH] [py] [slicing] add option create_first, default to False --- python/lib/aubio/slicing.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/lib/aubio/slicing.py b/python/lib/aubio/slicing.py index 2ca116ec..c504ca02 100644 --- a/python/lib/aubio/slicing.py +++ b/python/lib/aubio/slicing.py @@ -6,13 +6,14 @@ from aubio import source, sink _max_timestamp = 1e120 def slice_source_at_stamps(source_file, timestamps, timestamps_end=None, - output_dir=None, samplerate=0, hopsize=256): + output_dir=None, samplerate=0, hopsize=256, + create_first=False): """ slice a sound file at given timestamps """ if timestamps is None or len(timestamps) == 0: raise ValueError("no timestamps given") - if timestamps[0] != 0: + if timestamps[0] != 0 and create_first: timestamps = [0] + timestamps if timestamps_end is not None: timestamps_end = [timestamps[1] - 1] + timestamps_end @@ -77,7 +78,7 @@ def slice_source_at_stamps(source_file, timestamps, timestamps_end=None, if remaining > start: # write remaining samples from current region _sink.do_multi(vec[:, start:remaining], remaining - start) - #print "closing region", "remaining", remaining + #print("closing region", "remaining", remaining) # close this file _sink.close() elif read > start: -- 2.11.0