Waveform.from_numpy()¶
- static Waveform.from_numpy(frame_rate_hz, arr)¶
Creates a
Waveformfrom a two-dimensional NumPyfloat32array.This static method takes a two-dimensional NumPy array of the shape
(frames, channels).Example
>>> import numpy as np >>> from babycat import Waveform >>> frame = np.array([-1.0, 0.0, 1.0], dtype="float32") >>> arr = np.stack([frame, frame]) >>> waveform = Waveform.from_numpy( ... frame_rate_hz=44_100, ... arr=arr, ... ) waveform <babycat.Waveform: 2 frames, 3 channel, 44100 hz>
- Parameters
frame_rate_hz (int) – The frame rate that applies to the waveform described by
arr.arr – A two-dimensional NumPy array with the channels dimension on axis 1.
- Returns
A waveform with a copy of the waveform in
arr.- Return type
- Raises
TypeError – Raised when
arris the wrong shape or dtype.