你的问题是
path_to_audios
包含中文件的相对路径
samples/<filename>
,而不仅仅是文件名。一个想法是稍微更改一下循环,以便在循环中只获得可用的文件名:
test_src = 'samples/'
filenames = os.listdir(test_src)
path_to_audios = [os.path.join(test_src, f) for f in filenames]
for fn, audio_path in zip(filenames, path_to_audios):
fn = fn.split('.')[0]
print "saving mfcc features"
np.savetxt('mfcc_flwts'+str(fn)+'.txt', features_with_times,newline ='\n', delimiter= '\t')
最后一行将结果保存在工作目录中,这也是编写文件名的糟糕方式。所以我们想把它改成。。。
np.savetxt(
os.path.join(your_target_path, 'mfcc_flwts{0}.txt'.format(fn)),
features_with_times,
newline ='\n',
delimiter= '\t'
)