获取此文件[Errno 20]不是目录:'./data//.DS_Store'

时间:2019-07-04 10:13:13

标签: python-3.x machine-learning deep-learning

我只是预处理我的数据,但是每次尝试加载数据并将其转换为mfcc时,都会出现错误。

没有找到适合我的解决方案

转换部分

def wav2mfcc(file_path, n_mfcc=20, max_len=11):
wave, sr = librosa.load(file_path, mono=True, sr=None)
wave = wave[::3]
mfcc = librosa.feature.mfcc(wave, sr=16000, n_mfcc=n_mfcc)

# If maximum length exceeds mfcc lengths then pad the remaining ones
if (max_len > mfcc.shape[1]):
    pad_width = max_len - mfcc.shape[1]
    mfcc = np.pad(mfcc, pad_width=((0, 0), (0, pad_width)), mode='constant')

# Else cutoff the remaining parts
else:
    mfcc = mfcc[:, :max_len]

return mfcc

运行代码

save_data_to_array(max_len=config.max_len, n_mfcc=config.buckets)

我遇到错误

NotADirectoryError                        Traceback (most recent call last)
<ipython-input-2-a2a2e907f36d> in <module>
      6 
      7 # Save data to array file first
----> 8 save_data_to_array(max_len=config.max_len, n_mfcc=config.buckets)
      9 
     10 labels=["right", "left", "on", "off"]

~/Desktop/Pyinit_ML/Projectwork/Speechwork/Newtry/preprocess.py in save_data_to_array(path, max_len, n_mfcc)
     43         mfcc_vectors = []
     44 
---> 45         wavfiles = [path + label + '/' + wavfile for wavfile in os.listdir(path + '/' + label)]
     46         for wavfile in tqdm(wavfiles, "Saving vectors of label - '{}'".format(label)):
     47             mfcc = wav2mfcc(wavfile, max_len=max_len, n_mfcc=n_mfcc)

NotADirectoryError: [Errno 20] Not a directory: './data//.DS_Store'

0 个答案:

没有答案