Get .wav file length or duration

后端 未结 9 732
暗喜
暗喜 2020-12-04 10:17

I\'m looking for a way to find out the duration of a audio file (.wav) in python. So far i had a look at python wave library, mutagen, pymedi

9条回答
  •  一生所求
    2020-12-04 10:39

    Let,T be the duration between 2 consecutive samples. So, we can write t = nT or t = n/Fs.

    from scipy.io import wavfile
    Fs, data = wavfile.read('filename.wav')
    n = data.size
    t = n / Fs
    

提交回复
热议问题