emotion.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:openEMO 作者: adit-39 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号