Created
August 25, 2019 12:54
-
-
Save bobchennan/bd97a8060cda18d2f959d81c10a4a23b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def main(text_file, out_file): | |
with open(text_file) as f: | |
temp = f.readlines() | |
content = [x.strip() for x in temp] | |
with open(out_file, 'w') as f: | |
for i in content: | |
if i.split()[4] == 'bonafide': | |
f.write('%s %s\n' % (i.split()[0] + '-' + i.split()[1], i.split()[4])) | |
else: | |
f.write('%s %s\n' % (i.split()[0] + '-' + i.split()[1], i.split()[3])) | |
def main_eval(text_file, out_file): | |
with open(text_file) as f: | |
temp = f.readlines() | |
content = [x.strip() for x in temp] | |
with open(out_file, 'w') as f: | |
for i in content: | |
new_id = i.split()[0] + '-' + i.split()[0] | |
f.write('%s\n' % new_id) | |
if __name__ == '__main__': | |
""" | |
text_files = ['LA/ASVspoof2019_LA_protocols/ASVspoof2019.LA.cm.train.trn.txt', | |
'LA/ASVspoof2019_LA_protocols/ASVspoof2019.LA.cm.dev.trl.txt', | |
'PA/ASVspoof2019_PA_protocols/ASVspoof2019.PA.cm.train.trn.txt', | |
'PA/ASVspoof2019_PA_protocols/ASVspoof2019.PA.cm.dev.trl.txt'] | |
out_files = ['LA_train_utt2systemID', 'LA_dev_utt2systemID', | |
'PA_train_utt2systemID', 'PA_dev_utt2systemID'] | |
for i in range(len(text_files)): | |
main(text_files[i], out_files[i]) | |
""" | |
text_files = ['LA/ASVspoof2019_LA_protocols/ASVspoof2019.LA.cm.eval.trl.txt', | |
'PA/ASVspoof2019_PA_protocols/ASVspoof2019.PA.cm.eval.trl.txt',] | |
out_files = ['LA_eval_utt2systemID', | |
'PA_eval_utt2systemID',] | |
for i in range(len(text_files)): | |
main_eval(text_files[i], out_files[i]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment