import wave import os.path # 音频存放文件夹绝对路径 filedir = '/Users/111/PycharmProjects/TextClassify/wav' list = os.listdir(filedir) time_count = 0 for file in list: if '.wav' in file: wav_path = filedir+'/'+file with wave.open(wav_path,'rb') as f: f = wave.open(wav_path) time_count += f.getparams().nframes/f.getparams().framerate print(time_count/60/60)