0

I am working on a .wav signals using python 3.5 and trying to extract mfcc, mfcc delta, mfcc delta-deltas, and other signal features. but there is an error raised only with mfcc delta with is:

Traceback (most recent call last):
    mfcc_delta = librosa.feature.delta(mfcc)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python35\lib\site-packages\librosa\feature\utils.py", line 116, in delta
    **kwargs)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\signal\_savitzky_golay.py", line 337, in savgol_filter
    coeffs = savgol_coeffs(window_length, polyorder, deriv=deriv, delta=delta)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\signal\_savitzky_golay.py", line 139, in savgol_coeffs
    coeffs, _, _, _ = lstsq(A, y)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\linalg\basic.py", line 1226, in lstsq
    % (-info, lapack_driver))
ValueError: illegal value in 4-th argument of internal None

I am working on the following code:

import librosa
import numpy as np
import librosa
from scipy import signal
import scipy.stats

def preprocess_cough(x,fs, cutoff = 6000, normalize = True, filter_ = True, downsample = True): 
    #Preprocess Data
    if len(x.shape)>1:
        x = np.mean(x,axis=1)                          # Convert to mono
    if normalize:
        x = x/(np.max(np.abs(x))+1e-17)                # Norm to range between -1 to 1
    if filter_:
        b, a = butter(4, fs_downsample/fs, btype='lowpass') # 4th order butter lowpass filter
        x = filtfilt(b, a, x)
    if downsample:
        x = signal.decimate(x, int(fs/fs_downsample)) # Downsample for anti-aliasing
    
    fs_new = fs_downsample

    return np.float32(x), fs_new

audio_data = 'F:/test/'
files = librosa.util.find_files(audio_data, ext=['wav'])
x,fs = librosa.load(myFile,sr=48000)
arr, f = preprocess_cough(x,fs)
mfcc = librosa.feature.mfcc(y=arr, sr=f, n_mfcc=13)
mfcc_delta = librosa.feature.delta(mfcc)
mfcc_delta2 = librosa.feature.delta(mfcc, order=2)

when I remove the mffcs calculations and calculate the other wav signal features the error does not appear again. Also, I have tried to remove n_mfcc=13 parameter but the error still raises.

Sample of the output and the shape of mfcc variable

[-3.86701782e+02 -4.14421021e+02 -4.67373749e+02 -4.76989105e+02
  -4.23713501e+02 -3.71329285e+02 -3.47003693e+02 -3.19309082e+02
  -3.29547089e+02 -3.32584625e+02 -2.78399109e+02 -2.43284348e+02
  -2.47878128e+02 -2.59308533e+02 -2.71102844e+02 -2.87314514e+02
  -2.58869965e+02 -6.01125565e+01  1.66160011e+01 -8.58060551e+00
  -8.49179382e+01 -9.29880371e+01 -9.96001358e+01 -1.04499428e+02
  -3.65511665e+01 -3.82106819e+01 -8.69802475e+01 -1.22267052e+02
  -1.70187592e+02 -2.35996841e+02 -2.96493286e+02 -3.39086365e+02
  -3.59514771e+02]

and the shape is (13,33) Can anyone help me, please? Thanks in advance

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
Hadeer Zayat
  • 61
  • 1
  • 8
  • Please consider accepting (grey tick mark on the left of the answer) and/or upvoting the answer/s as a token of appreciation for help in solving your issue. – sophros Feb 15 '21 at 10:20

1 Answers1

0

Somewhat similarly to the issue raised in this question the issue is related to the intricacies of the underlying numerical operations that librosa defers to scipy. SciPy depends on LAPACK library being installed. So at first I would check if you have it installed.

Also, you may want to debug the script step-by-step to step into SciPy and examine actual values that are percolating from librosa.feature.delta to scipy.signal.savgol_filter which may tell you the reason when you cross-check them with documentation.

sophros
  • 14,672
  • 11
  • 46
  • 75