pytorch 官方音频处理库 https://github.com/pytorch/audio
天问 187a5df922 Update 'README.md' | 1 year ago | |
---|---|---|
README.md | 1 year ago |
The aim of torchaudio is to apply PyTorch to the audio domain. By supporting PyTorch, torchaudio follows the same philosophy of providing strong GPU acceleration, having a focus on trainable features through the autograd system, and having consistent style (tensor names and dimension names). Therefore, it is primarily a machine learning library and not a general signal processing library. The benefits of PyTorch can be seen in torchaudio through having all the computations be through PyTorch operations which makes it easy to use and feel like a natural extension.
wav
, mp3
, ogg
, flac
, opus
, sphere
, into a torch Tensor using SoXPlease refer to https://pytorch.org/audio/main/installation.html for installation and build process of TorchAudio.
依赖pytorch,点击下面连接选择指定版本,生成安装命令: https://pytorch.org/get-started/locally/
import torchaudio
waveform, sample_rate = torchaudio.load('foo.wav') # load tensor from file
torchaudio.save('foo_save.wav', waveform, sample_rate) # save tensor to file
By default in OSX and Linux, torchaudio uses SoX as a backend to load and save files. The backend can be changed to SoundFile using the following. See SoundFile for installation instructions.
import torchaudio
torchaudio.set_audio_backend("soundfile") # switch backend
waveform, sample_rate = torchaudio.load('foo.wav') # load tensor from file, as usual
torchaudio.save('foo_save.wav', waveform, sample_rate) # save tensor to file, as usual
Note
API Reference is located here: http://pytorch.org/audio/main/