我只是预处理我的数据,但是每次尝试加载数据并将其转换为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'