Blame view
egs/aishell/v1/local/produce_trials.py
798 Bytes
8dcb6dfcb first commit |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
#!/usr/bin/env python3 # Copyright 2017 Bengu Wu # Apache 2.0. # This script generate trials file. # Trial file is formatted as: # uttid spkid target|nontarget # If uttid belong to spkid, it is marked 'target', # otherwise is 'nontarget'. # input: eval set uttspk file # output: trial file import sys fnutt = sys.argv[1] ftrial = open(sys.argv[2], 'w') dictutt = {} for line in open(fnutt): utt2spk = line.rstrip('\r\t ') spk = utt2spk.split(' ')[1] if spk not in dictutt: dictutt[spk] = spk for line in open(fnutt): utt2spk = line.rstrip('\r\t ') utt, spk = utt2spk.split(' ') for target in dictutt: if target == spk: trial = utt + ' ' + target + ' target' else: trial = utt + ' ' + target + ' nontarget' ftrial.write(trial + ' ') ftrial.close() |