transform_to_tensor {torchaudio} | R Documentation |
Convert an audio object into a tensor
Description
Converts a numeric vector, as delivered by the backend, into a torch_tensor
of shape (channels x samples).
If provided by the backend, attributes "channels" and "sample_rate" will be used.
Usage
transform_to_tensor(
audio,
out = NULL,
normalization = TRUE,
channels_first = TRUE
)
Arguments
audio |
(numeric): A numeric vector, as delivered by the backend. |
out |
(Tensor): An optional output tensor to use instead of creating one. (Default: |
normalization |
(bool, float or function): Optional normalization.
If boolean |
channels_first |
(bool): Set channels first or length first in result. (Default: |
Value
list(Tensor, int), containing - the audio content, encoded as `[C x L]` or `[L x C]` where L is the number of audio frames and C is the number of channels - the sample rate of the audio (as listed in the metadata of the file)