How to split a .wav file into multiple .wav files?

后端 未结 2 1773
傲寒
傲寒 2020-12-03 01:16

I have a .wav file several minutes long that I would like to split into different 10 second .wav files.

This is my python code so far:

import wave
im         


        
2条回答
  •  感情败类
    2020-12-03 02:08

    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.
    

提交回复
热议问题