Tuesday 14 January 2020

Librosa: Cannot provide window function for mfcc on Windows

I'm currently experimenting with librosa to reproduce an scientific approach (deep learning) that used PRAAT to extract the MFCCs of audio files. I'm not that experienced with phonetics/acoustics and I had a lot of issues understanding PRAAT - so I started using librosa whose API was more "accessible" for me.

The paper's authors used a Hamming window in the MFCC calculation and I tried to provide the function as additional parameter in the function call of mfcc or as part of **kwargs as dictionary:

import os
from scipy.signal import get_window
from librosa import load, get_duration
from librosa.feature import mfcc
import pandas
import tables
import matplotlib.pyplot as plt

# ...

kwargs = {"n_fft": 160, "hop_length": 80, "window": get_window("hamming", Nx=160)}
mfccs = mfcc(y=y, sr=sr, S=None, n_mfcc=12, **kwargs)

I still have a lot to learn about acoustics, so I'm not very sure about the values, but (considering the API) this should work. On my Windows computer running this commands in my Anaconda environment causes the following error:

processing  03a01Fa.wav ...
Traceback (most recent call last):
File "xxx\librosaData.py", line 37, in <module>
mfccs = mfcc(y=y, sr=sr, S=None, n_mfcc=12, **kwargs)
File "C:\Users\xxx\AppData\Local\Continuum\anaconda3\envs\xxx\lib\site-packages\librosa\feature\spectral.py", line 1442, in mfcc
S = power_to_db(melspectrogram(y=y, sr=sr, **kwargs))
File "C:\Users\xxx\AppData\Local\Continuum\anaconda3\envs\xxx\lib\site-packages\librosa\feature\spectral.py", line 1534, in melspectrogram
mel_basis = filters.mel(sr, n_fft, **kwargs)
TypeError: mel() got an unexpected keyword argument 'window'

Process finished with exit code 1 

I tried this today on MacOS (also using an Anaconda environment) and it's causing no error. Most of the time I'm using the Windows computer for my experiments, because I can accelerate the calculations with CUDA. I'm not sure whether this is an Librosa-related issue, because I already had some other issues with my environments there (e.g. I couldn't persist a pandas.DataFrame using HDF5, but I somehow managed to fix this by myself. And PyCharm on Windows doesn't display my installed packages - not fixed yet, but less important).

I don't know what causes this behavior and I would really like to fix this problem. Did anybody encounter the same (or a similar) problem and found a way to fix it?

Thank you very much. :-)



from Librosa: Cannot provide window function for mfcc on Windows

No comments:

Post a Comment