Waveform.to_numpy()

Waveform.to_numpy()

Returns the waveform as a 2D numpy.ndarray array with shape (frames, channels)

Babycat internally stores decoded audio as a Rust Vec<f32>. This method converts the Vec<f32> into a NumPy array. Babycat does not internally cache the NumPy array, so avoid calling this method multiple times on the same Waveform.

Babycat is also designed to release the Python Global Interpreter Lock (GIL) when decoding audio into a Vec<f32>, but Babycat re-acquires the GIL when converting the the Vec<f32> into a NumPy array.

Returns

A NumPy array with frames as the first axis and channels as the second axis.

Return type

numpy.ndarray