第一步:安装:pip install pydub
请提前准备好对应的音频文件
第二步:对应的代码编写
from pydub import AudioSegment
sound = AudioSegment.from_file("audio_speed.wav")
print(sound.duration_seconds)
rate=0.75
sound_with_altered_frame_rate = sound._spawn(sound.raw_data, overrides={
"frame_rate": int(sound.frame_rate * rate)
})
sound_slow = sound_with_altered_frame_rate.set_frame_rate(sound.frame_rate)
print(sound_slow.duration_seconds)
对应的jupyter如下图所示:
参考:python - How to change audio playback speed using Pydub? - Stack Overflow