目录
在读取音频时有几种方法,而每一种所读出来的格式都不一样
Soundfile.read
最简单输入参数也最少的方式。
import soundfile as sf
file = './my_audio/cat.wav'
y, sr = sf.read(file)
print('If use soundfile, shape of y = ',y.shape)
# 输出:
If use soundfile.read, shape of y = (187662, 2)
Torchaudio.load
读取完音频则为Tensor的型态。
filepath (str):音频路径。
frame_offset (int)(默认是0):在此之后开始读取,以帧为单位。