Blame view
egs/sre16/v1/local/make_sre16_eval.pl
4.79 KB
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
#!/usr/bin/perl use warnings; #sed replacement for -w perl parameter # Copyright 2017 David Snyder # Apache 2.0 # if (@ARGV != 2) { print STDERR "Usage: $0 <path-to-SRE16-eval> <path-to-output> "; print STDERR "e.g. $0 /export/corpora/SRE/R149_0_1 data/ "; exit(1); } ($db_base, $out_dir) = @ARGV; # Handle enroll $out_dir_enroll = "$out_dir/sre16_eval_enroll"; if (system("mkdir -p $out_dir_enroll")) { die "Error making directory $out_dir_enroll"; } $tmp_dir_enroll = "$out_dir_enroll/tmp"; if (system("mkdir -p $tmp_dir_enroll") != 0) { die "Error making directory $tmp_dir_enroll"; } open(SPKR, ">$out_dir_enroll/utt2spk") || die "Could not open the output file $out_dir_enroll/utt2spk"; open(WAV, ">$out_dir_enroll/wav.scp") || die "Could not open the output file $out_dir_enroll/wav.scp"; open(META, "<$db_base/docs/sre16_eval_enrollment.tsv") or die "cannot open wav list"; %utt2fixedutt = (); while (<META>) { $line = $_; @toks = split(" ", $line); $spk = $toks[0]; $utt = $toks[1]; if ($utt ne "segment") { print SPKR "${spk}-${utt} $spk "; $utt2fixedutt{$utt} = "${spk}-${utt}"; } } if (system("find $db_base/data/enrollment/ -name '*.sph' > $tmp_dir_enroll/sph.list") != 0) { die "Error getting list of sph files"; } open(WAVLIST, "<$tmp_dir_enroll/sph.list") or die "cannot open wav list"; while(<WAVLIST>) { chomp; $sph = $_; @t = split("/",$sph); @t1 = split("[./]",$t[$#t]); $utt=$utt2fixedutt{$t1[0]}; print WAV "$utt"," sph2pipe -f wav -p -c 1 $sph | "; } close(WAV) || die; close(SPKR) || die; # Handle test $out_dir_test= "$out_dir/sre16_eval_test"; if (system("mkdir -p $out_dir_test")) { die "Error making directory $out_dir_test"; } $tmp_dir_test = "$out_dir_test/tmp"; if (system("mkdir -p $tmp_dir_test") != 0) { die "Error making directory $tmp_dir_test"; } open(SPKR, ">$out_dir_test/utt2spk") || die "Could not open the output file $out_dir_test/utt2spk"; open(WAV, ">$out_dir_test/wav.scp") || die "Could not open the output file $out_dir_test/wav.scp"; open(TRIALS, ">$out_dir_test/trials") || die "Could not open the output file $out_dir_test/trials"; open(TGL_TRIALS, ">$out_dir_test/trials_tgl") || die "Could not open the output file $out_dir_test/trials_tgl"; open(YUE_TRIALS, ">$out_dir_test/trials_yue") || die "Could not open the output file $out_dir_test/trials_yue"; if (system("find $db_base/data/test/ -name '*.sph' > $tmp_dir_test/sph.list") != 0) { die "Error getting list of sph files"; } open(KEY, "<$db_base/docs/sre16_eval_trial_key.tsv") || die "Could not open trials file $db_base/docs/sre16_eval_trial_key.tsv. It might be located somewhere else in your distribution."; open(SEG_KEY, "<$db_base/docs/sre16_eval_segment_key.tsv") || die "Could not open trials file $db_base/docs/sre16_eval_segment_key.tsv. It might be located somewhere else in your distribution."; open(LANG_KEY, "<$db_base/metadata/calls.tsv") || die "Could not open trials file $db_base/metadata/calls.tsv. It might be located somewhere else in your distribution."; open(WAVLIST, "<$tmp_dir_test/sph.list") or die "cannot open wav list"; %utt2call = (); while(<SEG_KEY>) { chomp; $line = $_; @toks = split(" ", $line); $utt = $toks[0]; $call = $toks[1]; if ($utt ne "segment") { $utt2call{$utt} = $call; } } close(SEG_KEY) || die; %call2lang = (); while(<LANG_KEY>) { chomp; $line = $_; @toks = split(" ", $line); $call = $toks[0]; $lang = $toks[1]; $call2lang{$call} = $lang; } close(LANG_KEY) || die; while(<WAVLIST>) { chomp; $sph = $_; @t = split("/",$sph); @t1 = split("[./]",$t[$#t]); $utt=$t1[0]; print WAV "$utt"," sph2pipe -f wav -p -c 1 $sph | "; print SPKR "$utt $utt "; } close(WAV) || die; close(SPKR) || die; while (<KEY>) { $line = $_; @toks = split(" ", $line); $spk = $toks[0]; $utt = $toks[1]; $call = $utt2call{$utt}; $target_type = $toks[3]; if ($utt ne "segment") { print TRIALS "${spk} ${utt} ${target_type} "; if ($call2lang{$call} eq "tgl") { print TGL_TRIALS "${spk} ${utt} ${target_type} "; } elsif ($call2lang{$call} eq "yue") { print YUE_TRIALS "${spk} ${utt} ${target_type} "; } else { die "Unexpected language $call2lang{$call} for utterance $utt."; } } } close(TRIALS) || die; close(TGL_TRIALS) || die; close(YUE_TRIALS) || die; if (system("utils/utt2spk_to_spk2utt.pl $out_dir_enroll/utt2spk >$out_dir_enroll/spk2utt") != 0) { die "Error creating spk2utt file in directory $out_dir_enroll"; } if (system("utils/utt2spk_to_spk2utt.pl $out_dir_test/utt2spk >$out_dir_test/spk2utt") != 0) { die "Error creating spk2utt file in directory $out_dir_test"; } if (system("utils/fix_data_dir.sh $out_dir_enroll") != 0) { die "Error fixing data dir $out_dir_enroll"; } if (system("utils/fix_data_dir.sh $out_dir_test") != 0) { die "Error fixing data dir $out_dir_test"; } |