tensorplay.audio
Functions
get_audio_backend() [source]
python
get_audio_backend()Returns the name of the package used to load audio files.
info() [source]
python
info(filepath)Get signal information of an audio file.
load() [source]
python
load(filepath, normalize=True, channels_first=True)Loads an audio file from the filesystem.
Args
- filepath (
str): Path to the audio file. - normalize (
bool): If True, normalize the audio to [-1, 1] (float32). If False, return original values (e.g. int16). - Default: True.
- channels_first (
bool): If True, return (Channels, Time). If False, return (Time, Channels). - Default: True (PyTorch style).
Returns
- Tensor: Audio tensor.
- int: Sample rate.
save() [source]
python
save(filepath, src, sample_rate)Saves a Tensor to an audio file.
Args
- filepath (
str): Path to save. - src (
Tensor): Audio tensor (C, T) or (T, C) or (T,). - sample_rate (
int): Sample rate.
set_audio_backend() [source]
python
set_audio_backend(backend)Specifies the package used to load audio files.
Args
- backend (
str): Name of the backend. One of "soundfile", "scipy".
