由于某些限制,我只能使用 wave , scipy 和 numpy 。因此,我决定自行实现以下代码段:
with audioread.audio_open(os.path.realpath(path)) as input_file:
sr_native = input_file.samplerate
n_channels = input_file.channels
s_start = int(np.round(sr_native * offset)) * n_channels
if duration is None:
s_end = np.inf
else:
s_end = s_start + (int(np.round(sr_native * duration)) * n_channels)
可以使用python wave模块完成此操作吗?通过使用wave.open()打开文件并使用scipy进行一些操作?