- batch.waveforms_from_files_into_numpys_unwrapped(start_time_milliseconds=0, end_time_milliseconds=0, frame_rate_hz=0, num_channels=0, convert_to_mono=False, zero_pad_ending=False, resample_mode=0, decoding_backend=0, num_workers=0)¶
This method is not as ergonomic as
waveforms_from_files()for decoding audio files in parallel. However, this method avoids unnecessary memory allocations and Python GIL contention.
This method is also better if you want to automatically raise decoding errors as exceptions, and do not care to inspect the name or type of exception. Currently this method raises all exceptions as
start_time_milliseconds (int, optional) – We discard any audio before this millisecond offset. By default, this does nothing and the audio is decoded from the beginning. Negative offsets are invalid.
end_time_milliseconds (int, optional) – We discard any audio after this millisecond offset. By default, this does nothing and the audio is decoded all the way to the end. If
start_time_millisecondsis specified, then
end_time_millisecondsmust be greater. The resulting
frame_rate_hz (int, optional) – A destination frame rate to resample the audio to. Do not specify this parameter if you wish Babycat to preserve the audio’s original frame rate. This does nothing if
frame_rate_hzis equal to the audio’s original frame rate.
num_channels (int, optional) – Set this to a positive integer
nto select the first
nchannels stored in the audio file. By default, Babycat will return all of the channels in the original audio. This will raise an exception if you specify a
num_channelsgreater than the actual number of channels in the audio.
convert_to_mono (bool, optional) – Set to
Trueto average all channels into a single monophonic (mono) channel. If
num_channels = nis also specified, then only the first
nchannels will be averaged. Note that
convert_to_monocannot be set to
Truewhile also setting
num_channels = 1.
zero_pad_ending (bool, optional) – If you set this to
True, Babycat will zero-pad the ending of the decoded waveform to ensure that the output waveform’s duration is exactly
end_time_milliseconds - start_time_milliseconds. By default,
zero_pad_ending = False, in which case the output waveform will be shorter than
end_time_milliseconds - start_time_millisecondsif the input audio is shorter than
resample_mode (int, optional) – If you set
frame_rate_hzto resample the audio when decoding, you can also set
resample_modeto pick which resampling backend to use. The
babycat.resample_modesubmodule contains the various available resampling algorithms compiled into Babycat. By default, Babycat resamples audio using libsamplerate at its highest-quality setting.
decoding_backend (int, optional) – Sets the audio decoding backend to use. Defaults to the Symphonia backend.
num_workers (int, optional) – The number of threads–Rust threads, not Python threads–to use for parallel decoding of the audio files in
filenames. By default, Babycat creates the same number of threads as the number of logical CPU cores on your machine.
A list of NumPy arrays of all of the successfully-decoded audio waveforms.
- Return type
Currently, this method raises pyo3.PanicException if it –
faces an error when decoding from any files. –