def read_file_pair(filename_pair, mono=True):
"""
given a pair of file names, read in both waveforms and upsample (through
librosa's default interpolation) the downsampled waveform
assumes the file name pair is of the form ("original", "downsampled")
mono selects whether to read in mono or stereo formatted waveforms
returns a pair of numpy arrays representing the original and upsampled
waveform
"""
channel = 1 if mono else 2
true_waveform, true_br = librosa.load(filename_pair[0], sr=None,
mono=mono)
ds_waveform, _ = librosa.load(filename_pair[1], sr=true_br, mono=mono)
# truth, example
return true_waveform.reshape((-1, channel)), \
ds_waveform.reshape((-1, channel))
评论列表
文章目录