ValueError:调用时没有要在“array”的轴0中反映的元素librosa.feature.mel光谱图

2024-10-03 15:21:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图提取不同音频文件的mel谱图,对于其中一些文件,我得到以下错误:

Traceback (most recent call last):

File "", line 25, in script_process_file bounds, events, features, RMS = process_file(_file,version=None,output=True,reading=True,cython=False,corr_FIR=None,features_list = features_list_all, tree_function =Tree_4_0_0,data=data, amplify=None)

File "pcm_algorithm/process_file.py", line 111, in process_file mel_spec = librosa.feature.melspectrogram(sound,n_fft=256,hop_length=128,n_mels=n_mels).T

File "/usr/local/lib/python2.7/dist-packages/librosa/feature/spectral.py", line 1388, in melspectrogram power=power)

File "/usr/local/lib/python2.7/dist-packages/librosa/core/spectrum.py", line 1179, in _spectrogram S = np.abs(stft(y, n_fft=n_fft, hop_length=hop_length))**power

File "/usr/local/lib/python2.7/dist-packages/librosa/core/spectrum.py", line 160, in stft y = np.pad(y, int(n_fft // 2), mode=pad_mode)

File "/usr/local/lib/python2.7/dist-packages/numpy/lib/arraypad.py", line 1420, in pad " in axis {} of array".format(axis)) ValueError: There aren't any elements to reflect in axis 0 of array

我使用256个fft点,其中128帧重叠40个mel_波段。任何建议都会很有帮助。在

下面是给我一个错误的确切代码行:

n_mels = **40**

mel_spec =  librosa.feature.melspectrogram(sound,n_fft=**256**,hop_length=**128**,n_mels=n_mels).T

Tags: inpyfftlibusrlocallineprocess