In order to count the duration information of a large number of audio , For example, total time , Average duration , Maximum hourly length, etc , It is unrealistic to use manual statistics one by one , This requires the use of python Batch processing .

How to use it python How to get the duration information of a piece of audio . The details are as follows :
wav_path = '' with open(wav_path, 'rb') as f: time_count =
f.getparams().nframes/f.getparams().framerate print(time_count)
How long is the total audio time , quantity , Average duration , What about the maximum and maximum hours . The details are as follows :
import os # Audio storage folder path filedir = '' time_count = 0 wav_num = 0 wav_time_max = 0
wav_time_min = 5 list = os.listdir(filedir) for file in list: if '.wav' in
file: wav_num += 1 wav_path = os.path.join(filedir, fille) with
wave.open(wav_path,'rb') as f: wav_time =
f.getparams().nframes/f.getparams().framerate time_count += wav_time if
wav_time > wav_time_max: wav_time_max = wav_time if wav_time < wav_time_min:
wav_time_min = wav_time time_ave = time_count / wav_num
print(time_count/60,wav_num,time_ave,wav_time_max,wav_time_min)

Technology