def read_wavs_trng(emotions, trng_path, pickle_path, use_pickle=False):
"""
Utility function to read wav files, convert them into MFCC vectors and store in a pickle file
(Pickle file is useful in case you re-train on the same data changing hyperparameters)
"""
trng_data = {}
if use_pickle and os.path.isfile(pickle_path):
write_pickle = False
trng_data = pickle.load(open(pickle_path, "rb"))
else:
write_pickle = True
for emo in emotions:
mfccs = []
for wavfile in glob.glob(trng_path + '/' + emo + '/*.wav'):
rate, sig = wvf.read(wavfile)
mfcc_feat = mfcc(sig, rate)
mfccs.append(mfcc_feat)
trng_data[emo] = mfccs
if write_pickle:
pickle.dump(trng_data, open(pickle_path, "wb"))
return trng_data
评论列表
文章目录