import librosa import glob import librosa path=glob.glob('E:/...*/*.wav') for i in range(len(path)) : y, sr = librosa.load(path[i], sr=16000) z=librosa.get_duration(y)
What is the type of
z here? Could you simply take an average?
Your wav file is an array of [n] values. To calculate length of file in seconds you need to divide n by sr (sampling rate, number of measurements per second).
Be sure to provide sr value to librosa.load in case you have wavs from different sources because wavs can be recorded with different sampling rates and librosa will automatically resample them on load. Average len of y across all files, divide by sr.