[py] [slicing] add end of last region if missing
authorPaul Brossier <piem@piem.org>
Mon, 29 Oct 2018 14:26:54 +0000 (15:26 +0100)
committerPaul Brossier <piem@piem.org>
Mon, 29 Oct 2018 14:26:54 +0000 (15:26 +0100)
python/lib/aubio/slicing.py

index a2a2519..2ca116e 100644 (file)
@@ -18,7 +18,9 @@ def slice_source_at_stamps(source_file, timestamps, timestamps_end=None,
             timestamps_end = [timestamps[1] - 1] + timestamps_end
 
     if timestamps_end is not None:
-        if len(timestamps_end) != len(timestamps):
+        if len(timestamps_end) == len(timestamps) - 1:
+            timestamps_end = timestamps_end + [_max_timestamp]
+        elif len(timestamps_end) != len(timestamps):
             raise ValueError("len(timestamps_end) != len(timestamps)")
     else:
         timestamps_end = [t - 1 for t in timestamps[1:]] + [_max_timestamp]