其他分享
首页 > 其他分享> > judge_raw_align.py

judge_raw_align.py

作者:互联网

from collections import Counter

with open('/dnn4_added/fuyongze/tr/vt/base/align_test.txt', 'r')as align_f, open('/dnn4_added/fuyongze/tr/vt/base/raw_test.txt', 'r') as mfcc_f:
    align_list = []
    mfcc_list = []
    for line in align_f.readlines():
        align = line.strip().split('/')[-1].split('.')[0]
        #align = line.strip().split('.')[0]
        align_list.append(align)

    for line in mfcc_f.readlines():
        mfcc = line.strip().split('/')[-1].split('.')[0]
        #mfcc = line.strip().split('.')[0]
        mfcc_list.append(mfcc)

all_list = align_list + mfcc_list
all_dict = dict(Counter(all_list))
no_repeat = [key for key, value in all_dict.items() if value == 1]
repeat = [key for key, value in all_dict.items() if value > 1]
align_exist = []
mfcc_exist = []
for i in no_repeat:
    if i in align_list:
        align_exist.append(i)
    elif i in mfcc_list:
        mfcc_exist.append(i)
    else:
        print(i)


# all_exist = [x for x in mfcc_list if x in align_list]
# mfcc_exist = [x for x in mfcc_list if x not in align_list]
# align_exist = [x for x in align_list if x not in mfcc_list]

print(len(repeat))
print(len(mfcc_exist))
print(len(align_exist))
def write_file(data_list, file_name):
    with open(file_name, 'w') as f:
        for data in data_list:
            f.write(data + '\n')



write_file(mfcc_exist, 'raw_exist.txt')
write_file(align_exist, 'align_exist.txt')

标签:mfcc,align,list,raw,exist,split,judge,line
来源: https://blog.csdn.net/m0_59555232/article/details/122740045