def save_cache(src_path, des_path, get_feature_func):
des_path = osp.splitext(des_path)[0] + '.npy'
try:
X, sr = librosa.load(src_path)
src = int(sr)
feature = get_feature_func(X, sr)
print('[INFO] Saving Cache in {} ...'.format(des_path))
des_par = osp.abspath(osp.join(des_path, osp.pardir))
if not osp.exists(des_par):
os.makedirs(des_par)
except Exception, e:
print("[ERROR] Unkown error happend when dealing with{}".format(src_path))
#print(e)
return -1
np.save(des_path, feature)
return 0
评论列表
文章目录