Applying a window function to a frame in librosa

3.8k views Asked by At

I am currently working on an ASR system, and I've forgotten to apply a window function to each frame. I am extracting, which could be the cause to why I am receiving bad results. But is that possible in librosa?

I can't find this option in librosa documentation.

I need to apply a hamming window on to each frame, which are extracted as such.

   for fp in file_paths:
        y,sr = librosa.load(fp,sr=16000)
        X = librosa.util.frame(y, frame_length=400, hop_length=160)
1

There are 1 answers

2
Dmytro Prylipko On BEST ANSWER

Librosa employs scipy.signal:

window = scipy.signal.hann(win_length, sym=False)

# Reshape so that the window can be broadcast
window = window.reshape((-1, 1))

windowed = fft_window * X

Here you can see how it is done inside librosa.

But why not to use librosa.stft or librosa.mfcc? It will do everything you need.