Python, How to split a .wav file into multiple .wav files

大憨熊 提交于 2019-11-28 10:05:25

This is a python code snippet that I use for splitting files as per necessity.
I use the pydub library from https://github.com/jiaaro/pydub. You can modify the snippet to suit your requirement.

    from pydub import AudioSegment
    t1 = t1 * 1000 #Works in milliseconds
    t2 = t2 * 1000
    newAudio = AudioSegment.from_wav("oldSong.wav")
    newAudio = newAudio[t1:t2]
    newAudio.export('newSong.wav', format="wav") #Exports to a wav file in the current path.
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!