- Timestamp:
- Oct 29, 2018, 3:47:08 PM (6 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:
- 97a8bef
- Parents:
- 92a6af0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/lib/aubio/slicing.py
r92a6af0 r5c6a8587 9 9 output_dir=None, samplerate=0, hopsize=256, 10 10 create_first=False): 11 """ slice a sound file at given timestamps """ 11 """Slice a sound file at given timestamps. 12 13 This function reads `source_file` and creates slices, new smaller 14 files each starting at `t` in `timestamps`, a list of integer 15 corresponding to time locations in `source_file`, in samples. 16 17 If `timestamps_end` is unspecified, the slices will end at 18 `timestamps_end[n] = timestamps[n+1]-1`, or the end of file. 19 Otherwise, `timestamps_end` should be a list with the same length 20 as `timestamps` containing the locations of the end of each slice. 21 22 If `output_dir` is unspecified, the new slices will be written in 23 the current directory. If `output_dir` is a string, new slices 24 will be written in `output_dir`, after creating the directory if 25 required. 26 27 The default `samplerate` is 0, meaning the original sampling rate 28 of `source_file` will be used. When using a sampling rate 29 different to the one of the original files, `timestamps` and 30 `timestamps_end` should be expressed in re-sampled samples. 31 32 The `hopsize` parameter simply tells :class:`source` to use this 33 hopsize and does not change the output slices. 34 35 If `create_first` is True and `timestamps` does not start with `0`, the 36 first slice from `0` to `timestamps[0] - 1` will be automatically added. 37 38 Parameters 39 ---------- 40 source_file : str 41 path of the resource to slice 42 timestamps : :obj:`list` of :obj:`int` 43 time stamps at which to slice, in samples 44 timestamps_end : :obj:`list` of :obj:`int` (optional) 45 time stamps at which to end the slices 46 output_dir : str (optional) 47 output directory to write the slices to 48 samplerate : int (optional) 49 samplerate to read the file at 50 hopsize : int (optional) 51 number of samples read from source per iteration 52 create_first : bool (optional) 53 always create the slice at the start of the file 54 55 Examples 56 -------- 57 Create two slices, the first second of a file and the rest of it: 58 59 >>> aubio.slice_source_at_stamps('loop.wav', [0, 44100]) 60 61 Create one slice, from 1 second to 2 seconds: 62 63 >>> aubio.slice_source_at_stamps('loop.wav', [44100], [44100*2]) 64 """ 12 65 13 66 if timestamps is None or len(timestamps) == 0:
Note: See TracChangeset
for help on using the changeset viewer.