我只是想将音频数据集(.wav格式)的采样率从32000Hz更改为44100Hz,但是这样做,回放速度也改变了(非常可接受且合乎逻辑)。 我的意思是,如何在不更改播放速度的情况下进行此更改? 目前,我正在使用Wave lib来执行此操作。看下面的代码:
import wave
# First i open the file.wav on read mode
opened_audio = wave.open(caminho, 'rb')
# Then i get all information that will be maintained
channels = opened_audio.getnchannels()
swidth = opened_audio.getsampwidth()
signal = opened_audio.readframes(-1)
opened_audio.close()
# Here i open the file.wav on write mode
wf = wave.open(caminho, 'wb')
# Then i set all obtained data that will not be changed
wf.setnchannels(channels)
wf.setsampwidth(swidth)
# Here is the new sampling rate in Hz
wf.setframerate(44100)
wf.writeframes(signal)
wf.close()
详细信息:我已经在这里阅读了很多帖子,但是没有人解决问题。