Converts a tuneR Wave object or numeric vector into a torch_tensor
of shape (Channels x Samples).
Convert Audio Object to Tensor.
transform_to_tensor(
audio,
out = NULL,
normalization = TRUE,
channels_first = TRUE
)
list(Tensor, int): An output tensor of size `[C x L]` or `[L x C]` where
L is the number of audio frames and
C is the number of channels.
An integer which is the sample rate of the audio (as listed in the metadata of the file)
(numeric or Wave): A numeric vector or Wave object, usually from tuneR::readMP3 or tuneR::readWave.
(Tensor): An optional output tensor to use instead of creating one. (Default: NULL
)
(bool, float or function): Optional normalization.
If boolean TRUE
, then output is divided by 2^(bits-1)
.
If bits
info is not available it assumes the input is signed 32-bit audio.
If numeric
, then output is divided by that number.
If function
, then the output is passed as a parameter to the given function,
then the output is divided by the result. (Default: TRUE
)
(bool): Set channels first or length first in result. (Default: TRUE
)
If audio is a numeric vector, attributes "channels" and "sample_rate" will be used if exists. Numeric vectors returned from av::read_audio_bin have both attributes by default.