[英]torchaudio load audio with specific sampling rate
From documentation, https://pytorch.org/audio/stable/backend.html#torchaudio.backend.sox_io_backend.load it seems there is no parameter for loading audio with a fixed sampling rate which is important for training models.从文档https://pytorch.org/audio/stable/backend.html#torchaudio.backend.sox_io_backend.load看来,似乎没有用于以固定采样率加载音频的参数,这对于训练模型很重要。
How to load a pytorch audio tensor with a fixed sampling rate with torchaudio?如何使用 torchaudio 加载具有固定采样率的 pytorch 音频张量?
Resample
can be used from transforms.可以从变换中使用
Resample
。
waveform, sample_rate = torchaudio.load('test.wav', normalize=True)
transform = transforms.Resample(sample_rate, sample_rate/10)
waveform = transform(waveform)
You can resample with torchaudio.functional.resample
您可以使用
torchaudio.functional.resample
重新采样
arr, org_sr = torchaudio.load('path')
arr = torchaudio.functional.resample(arr, orig_freq=org_sr, new_freq=new_sr)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.