pythonaudiosignal-processinglibrosa

Why does the list returned by librosa.feature.rms() have so few values?


I have audio data from a file that lasts a second :

audiodata, rate = librosa.load(datafile, sr=None, mono=True)

Having a sample rate of 44100 Hz, the resulting list has 44100 values.

But when computing the RMS value for each frame like so :

rms = librosa.feature.rms(y=audiodata)

rms only has 87 values. Why is it so and how do I get more values ?

I tried to halve the frame length :

rms = librosa.feature.rms(y=audiodata, frame_length=1024)

But the number of data is the exact same while I expected it to change.

Here is how I tested it :

amp = rms[0]
print("number of audio data : ", len(audiodata))
print("number of RMS data : ", len(amp))

and the output is

number of audio data :  44100
number of RMS data :  87

Solution

  • You need to change hop_length parameter, not frame_length to change number of outputs. Take a look at documentation

    rms = librosa.feature.rms(y=audiodata, hop_length=32)
    print(rms.shape)
    
    (1, 1379)