📜  如何获取音频python代码示例的持续时间

📅  最后修改于: 2022-03-11 14:45:25.509000             🧑  作者: Mango

代码示例1
import wave
import contextlib
fname = '/tmp/test.wav'
with contextlib.closing(wave.open(fname,'r')) as f:
    frames = f.getnframes()
    rate = f.getframerate()
    duration = frames / float(rate)
    print(duration)