Skip to content

Commit 342adfa

Browse files
authored
Merge pull request #3957 from naxingyu/sync-pybind11-with-master
Sync pybind11 with master
2 parents f5875be + 1a2e8d9 commit 342adfa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2086
-276
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ GSYMS
153153
/tools/cub-1.8.0/
154154
/tools/cub
155155
/tools/python/
156+
/tools/ngram-1.3.7.tar.gz
157+
/tools/ngram-1.3.7/
156158

157159
# These CMakeLists.txt files are all genareted on the fly at the moment.
158160
# They are added here to avoid accidently checkin.

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,22 @@ if(CUDA_FOUND)
203203
endif()
204204

205205
# add all native executables
206+
add_subdirectory(src/bin)
206207
add_subdirectory(src/gmmbin)
207208
add_subdirectory(src/featbin)
209+
add_subdirectory(src/sgmm2bin)
210+
add_subdirectory(src/fstbin)
211+
add_subdirectory(src/lmbin)
212+
add_subdirectory(src/latbin)
213+
add_subdirectory(src/nnetbin)
214+
add_subdirectory(src/nnet2bin)
215+
add_subdirectory(src/nnet3bin)
216+
add_subdirectory(src/rnnlmbin)
217+
add_subdirectory(src/chainbin)
218+
add_subdirectory(src/ivectorbin)
208219
add_subdirectory(src/onlinebin)
220+
add_subdirectory(src/online2bin)
221+
add_subdirectory(src/kwsbin)
209222

210223
# add all cuda executables
211224
if(CUDA_FOUND)

cmake/gen_cmake_skeleton.py

Lines changed: 80 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import sys
33
import re
4+
import fnmatch
45
import argparse
56

67
# earily parse, will refernece args globally
@@ -34,9 +35,20 @@ def is_test_source(f):
3435
def is_source(f):
3536
return f.endswith(".cc") and not is_test_source(f)
3637

37-
def dir_name_to_lib_target(dir_name):
38+
def lib_dir_name_to_lib_target(dir_name):
3839
return "kaldi-" + dir_name
3940

41+
def bin_dir_name_to_lib_target(dir_name):
42+
"""return the primary lib target for all executable targets in this bin dir"""
43+
assert is_bin_dir(dir_name)
44+
if dir_name == "bin":
45+
# NOTE: "kaldi-util" might be a more strict primary lib target...
46+
return "kaldi-hmm"
47+
elif dir_name == "fstbin":
48+
return "kaldi-fstext"
49+
else:
50+
return "kaldi-" + dir_name[:-3]
51+
4052
def wrap_notwin32_condition(should_wrap, lines):
4153
if isinstance(lines, str):
4254
lines = [lines]
@@ -48,42 +60,73 @@ def wrap_notwin32_condition(should_wrap, lines):
4860

4961
def get_exe_additional_depends(t):
5062
additional = {
51-
"transform-feats" : ["transform"],
52-
"interpolate-pitch" : ["transform"],
63+
# solve bin
64+
"align-*": ["decoder"],
65+
"compile-*graph*": ["decoder"],
66+
"decode-faster": ["decoder"],
67+
"latgen-faster-mapped": ["decoder"],
68+
"latgen-faster-mapped-parallel": ["decoder"],
69+
"latgen-incremental-mapped": ["decoder"],
70+
"decode-faster-mapped": ["decoder"],
71+
"sum-lda-accs": ["transform"],
72+
"sum-mllt-accs": ["transform"],
73+
"est-mllt": ["transform"],
74+
"est-lda": ["transform"],
75+
"acc-lda": ["transform"],
76+
"build-pfile-from-ali": ["gmm"],
77+
"make-*-transducer": ["fstext"],
78+
"phones-to-prons": ["fstext"],
79+
80+
# solve gmmbin
5381
"post-to-feats" : ["hmm"],
5482
"append-post-to-feats" : ["hmm"],
83+
"gmm-*": ["hmm", "transform"],
84+
"gmm-latgen-*": ["decoder"],
85+
"gmm-decode-*": ["decoder"],
86+
"gmm-align": ["decoder"],
87+
"gmm-align-compiled": ["decoder"],
5588
"gmm-est-fmllr-gpost": ["sgmm2", "hmm"],
56-
"gmm-est-fmllr": ["hmm", "transform"],
57-
"gmm-latgen-faster": ["decoder"],
58-
"gmm-transform-means": ["hmm"],
59-
"gmm-post-to-gpost": ["hmm"],
60-
"gmm-init-lvtln": ["transform"],
6189
"gmm-rescore-lattice": ["hmm", "lat"],
62-
"gmm-est-fmllr-global": ["transform"],
63-
"gmm-copy": ["hmm"],
64-
"gmm-train-lvtln-special": ["transform", "hmm"],
65-
"gmm-est-map": ["hmm"],
66-
"gmm-acc-stats2": ["hmm"],
67-
"gmm-decode-faster-regtree-mllr": ["decoder"],
68-
"gmm-global-est-fmllr": ["transform"],
69-
"gmm-est-basis-fmllr": ["hmm", "transform"],
70-
"gmm-init-model": ["hmm"],
71-
"gmm-est-weights-ebw": ["hmm"],
72-
"gmm-init-biphone": ["hmm"],
73-
"gmm-compute-likes": ["hmm"],
74-
"gmm-est-fmllr-raw-gpost": ["hmm", "transform"],
75-
# gmm-* is a bottom case, it will add link dependencies to all other
76-
# target whose names start with gmm-, it is harmless, but will increase
77-
# link time. Better to avoid it at best.
78-
"gmm-*": ["hmm", "transform", "lat", "decoder"],
90+
91+
# solve fstbin
92+
"make-grammar-fst": ["decoder"],
93+
94+
# solve sgmm2bin
95+
"sgmm2-*": ["hmm"],
96+
"sgmm2-latgen-faster*": ["decoder"],
97+
"sgmm2-align-compiled": ["decoder"],
98+
"sgmm2-rescore-lattice": ["lat"],
99+
"init-ubm": ["hmm"],
100+
101+
# solve nnetbin
102+
"nnet-train-mmi-sequential": ["lat"],
103+
"nnet-train-mpe-sequential": ["lat"],
104+
105+
# solve nnet2bin
106+
"nnet-latgen-faster*": ["fstext", "decoder"],
107+
"nnet-align-compiled": ["decoder"],
108+
"nnet1-to-raw-nnet": ["nnet"],
109+
110+
# solve chainbin
111+
"nnet3-chain-*": ["nnet3"],
112+
113+
# solve latbin
114+
"lattice-compose": ["fstext"],
115+
"lattice-lmrescore": ["fstext"],
116+
"lattice-lmrescore-*": ["fstext", "rnnlm"],
117+
118+
# solve ivectorbin
119+
"ivector-extract*": ["hmm"],
120+
121+
# solve kwsbin
122+
"generate-proxy-keywords": ["fstext"],
123+
"transcripts-to-fsts": ["fstext"],
79124
}
80-
if t in additional:
81-
return list(map(lambda name: dir_name_to_lib_target(name), additional[t]))
82-
elif (t.split("-", 1)[0] + "-*") in additional:
83-
wildcard = (t.split("-", 1)[0] + "-*")
84-
return list(map(lambda name: dir_name_to_lib_target(name), additional[wildcard]))
85-
else:
86-
return []
125+
l = []
126+
for pattern in additional.keys():
127+
if fnmatch.fnmatch(t, pattern):
128+
l.extend(list(map(lambda name: lib_dir_name_to_lib_target(name), additional[pattern])))
129+
return sorted(list(set(l)))
87130

88131
def disable_for_win32(t):
89132
disabled = [
@@ -98,7 +141,7 @@ def disable_for_win32(t):
98141
class CMakeListsHeaderLibrary(object):
99142
def __init__(self, dir_name):
100143
self.dir_name = dir_name
101-
self.target_name = dir_name_to_lib_target(self.dir_name)
144+
self.target_name = lib_dir_name_to_lib_target(self.dir_name)
102145
self.header_list = []
103146

104147
def add_header(self, filename):
@@ -123,8 +166,8 @@ def gen_code(self):
123166

124167
ret.append("add_library(" + self.target_name + " INTERFACE)")
125168
ret.append("target_include_directories(" + self.target_name + " INTERFACE ")
126-
ret.append(" $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>")
127-
ret.append(" $<INSTALL_INTERFACE:include/kaldi>")
169+
ret.append(" $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>")
170+
ret.append(" $<INSTALL_INTERFACE:include/kaldi>")
128171
ret.append(")\n")
129172

130173
ret.append("""
@@ -139,7 +182,7 @@ class CMakeListsLibrary(object):
139182

140183
def __init__(self, dir_name):
141184
self.dir_name = dir_name
142-
self.target_name = dir_name_to_lib_target(self.dir_name)
185+
self.target_name = lib_dir_name_to_lib_target(self.dir_name)
143186
self.header_list = []
144187
self.source_list = []
145188
self.cuda_source_list = []
@@ -241,7 +284,7 @@ def __init__(self, dir_name, filename):
241284
self.list = []
242285
exe_name = os.path.splitext(os.path.basename(filename))[0]
243286
file_name = filename
244-
depend = dir_name_to_lib_target(dir_name[:-3])
287+
depend = bin_dir_name_to_lib_target(dir_name)
245288
self.list.append((exe_name, file_name, depend))
246289

247290
def gen_code(self):

egs/babel/s5/local/kws_search.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ if [ $stage -le 2 ]; then
144144
echo "Writing normalized results"
145145
$cmd LMWT=$min_lmwt:$max_lmwt $kwsoutdir/write_normalized.LMWT.log \
146146
set -e ';' set -o pipefail ';'\
147-
cat ${kwsoutdir}_LMWT/result.* \| \
147+
gunzip -c ${kwsoutdir}_LMWT/result.* \| \
148148
utils/write_kwslist.pl --Ntrue-scale=$ntrue_scale --flen=0.01 --duration=$duration \
149149
--segments=$datadir/segments --normalize=true --duptime=$duptime --remove-dup=true\
150150
--map-utter=$kwsdatadir/utter_map --digits=3 \
@@ -155,7 +155,7 @@ if [ $stage -le 3 ]; then
155155
echo "Writing unnormalized results"
156156
$cmd LMWT=$min_lmwt:$max_lmwt $kwsoutdir/write_unnormalized.LMWT.log \
157157
set -e ';' set -o pipefail ';'\
158-
cat ${kwsoutdir}_LMWT/result.* \| \
158+
gunzip -c ${kwsoutdir}_LMWT/result.* \| \
159159
utils/write_kwslist.pl --Ntrue-scale=$ntrue_scale --flen=0.01 --duration=$duration \
160160
--segments=$datadir/segments --normalize=false --duptime=$duptime --remove-dup=true\
161161
--map-utter=$kwsdatadir/utter_map \

egs/chime6/s5_track2/RESULTS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ Dev 57.15 83.96
1414
Eval 54.12 80.33
1515

1616
# ASR nnet3 tdnn+chain
17-
Dev: U06 %WER 81.18 [ 58881 / 47798, 1638 ins, 30528 del, 15632 sub ]
18-
Eval: U06 %WER 85.39 [ 55132 / 47076, 1107 ins, 27768 del, 18201 sub ]
17+
Dev: %WER 84.33 [ 49653 / 58881, 1529 ins, 35813 del, 12311 sub ]
18+
Eval: %WER 78.08 [ 43046 / 55132, 957 ins, 32045 del, 10044 sub ]

egs/chime6/s5_track2/local/get_hyp_perspeaker_perarray_file.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,18 @@ def main():
3939
combined_hyp_file = args.output_dir_path + '/' + 'hyp' + '_' + sessionid_micid_speakerid + '_comb'
4040
combined_hyp_writer = open(combined_hyp_file, 'w')
4141
utterances = sessionid_micid_speakerid_dict[sessionid_micid_speakerid]
42-
text = ''
42+
# sorting utterances by start and end time
43+
sessionid_micid_speakerid_utterances={}
4344
for line in utterances:
4445
parts = line.strip().split()
46+
utt_parts = parts[0].strip().split('-')
47+
time ='-'.join(utt_parts[2:])
48+
sessionid_micid_speakerid_utterances[time] = line
49+
text = ''
50+
for time_key in sorted(sessionid_micid_speakerid_utterances):
51+
parts = sessionid_micid_speakerid_utterances[time_key].strip().split()
4552
text = text + ' ' + ' '.join(parts[1:])
46-
hyp_writer.write(line)
53+
hyp_writer.write(sessionid_micid_speakerid_utterances[time_key])
4754
combined_utterance = 'utt' + " " + text
4855
combined_hyp_writer.write(combined_utterance)
4956
combined_hyp_writer.write('\n')

egs/chime6/s5_track2/local/get_ref_perspeaker_persession_file.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,21 @@ def main():
5555
spkrid_mapping[sessionid_speakerid.split('_')[1]]) + '_comb'
5656
combined_ref_writer = open(combined_ref_file, 'w')
5757
utterances = sessionid_speakerid_dict[sessionid_speakerid]
58-
text = ''
59-
uttid_wc = 'utt'
58+
sessionid_speakerid_utterances = {}
59+
# sorting utterances by start and end time
6060
for line in utterances:
6161
parts = line.strip().split()
62+
utt_parts = parts[0].strip().split('-')
63+
time ='-'.join(utt_parts[1:])
64+
sessionid_speakerid_utterances[time] = line
65+
text = ''
66+
uttid_wc = 'utt'
67+
for time_key in sorted(sessionid_speakerid_utterances):
68+
parts = sessionid_speakerid_utterances[time_key].strip().split()
6269
uttid_id = parts[0]
6370
utt_text = ' '.join(parts[1:])
6471
text = text + ' ' + ' '.join(parts[1:])
65-
ref_writer.write(line)
72+
ref_writer.write(sessionid_speakerid_utterances[time_key])
6673
length = str(len(utt_text.split()))
6774
uttid_id_len = uttid_id + ":" + length
6875
uttid_wc = uttid_wc + ' ' + uttid_id_len

egs/formosa/s5/local/prepare_data.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ if [ -z "$(command -v dos2unix 2>/dev/null)" ]; then
2626
exit 1;
2727
fi
2828

29-
# have to remvoe previous files to avoid filtering speakers according to cmvn.scp and feats.scp
29+
# have to remove previous files to avoid filtering speakers according to cmvn.scp and feats.scp
3030
rm -rf data/all data/train data/test data/eval data/local/train
3131
mkdir -p data/all data/train data/test data/eval data/local/train
3232

3333

3434
# make utt2spk, wav.scp and text
35-
find $train_dir -name *.wav -exec sh -c 'x={}; y=$(basename -s .wav $x); printf "%s %s\n" $y $y' \; | dos2unix > data/all/utt2spk
36-
find $train_dir -name *.wav -exec sh -c 'x={}; y=$(basename -s .wav $x); printf "%s %s\n" $y $x' \; | dos2unix > data/all/wav.scp
37-
find $train_dir -name *.txt -exec sh -c 'x={}; y=$(basename -s .txt $x); printf "%s " $y; cat $x' \; | dos2unix > data/all/text
35+
find -L $train_dir -name *.wav -exec sh -c 'x={}; y=$(basename -s .wav $x); printf "%s %s\n" $y $y' \; | sed 's/\xe3\x80\x80\|\xc2\xa0//g' | dos2unix > data/all/utt2spk
36+
find -L $train_dir -name *.wav -exec sh -c 'x={}; y=$(basename -s .wav $x); printf "%s %s\n" $y $x' \; | sed 's/\xe3\x80\x80\|\xc2\xa0//g' | dos2unix > data/all/wav.scp
37+
find -L $train_dir -name *.txt -exec sh -c 'x={}; y=$(basename -s .txt $x); printf "%s " $y; cat $x' \; | sed 's/\xe3\x80\x80\|\xc2\xa0//g' | dos2unix > data/all/text
3838

3939
# fix_data_dir.sh fixes common mistakes (unsorted entries in wav.scp,
4040
# duplicate entries and so on). Also, it regenerates the spk2utt from
@@ -51,9 +51,9 @@ echo "cp data/train/text data/local/train/text for language model training"
5151
cat data/train/text | awk '{$1=""}1;' | awk '{$1=$1}1;' > data/local/train/text
5252

5353
# preparing EVAL set.
54-
find $eval_dir -name *.wav -exec sh -c 'x={}; y=$(basename -s .wav $x); printf "%s %s\n" $y $y' \; | dos2unix > data/eval/utt2spk
55-
find $eval_dir -name *.wav -exec sh -c 'x={}; y=$(basename -s .wav $x); printf "%s %s\n" $y $x' \; | dos2unix > data/eval/wav.scp
56-
find $eval_key_dir -name *.txt -exec sh -c 'x={}; y=$(basename -s .txt $x); printf "%s " $y; cat $x' \; | dos2unix > data/eval/text
54+
find -L $eval_dir -name *.wav -exec sh -c 'x={}; y=$(basename -s .wav $x); printf "%s %s\n" $y $y' \; | sed 's/\xe3\x80\x80\|\xc2\xa0//g' | dos2unix > data/eval/utt2spk
55+
find -L $eval_dir -name *.wav -exec sh -c 'x={}; y=$(basename -s .wav $x); printf "%s %s\n" $y $x' \; | sed 's/\xe3\x80\x80\|\xc2\xa0//g' | dos2unix > data/eval/wav.scp
56+
find -L $eval_key_dir -name *.txt -exec sh -c 'x={}; y=$(basename -s .txt $x); printf "%s " $y; cat $x' \; | sed 's/\xe3\x80\x80\|\xc2\xa0//g' | dos2unix > data/eval/text
5757
utils/fix_data_dir.sh data/eval
5858

5959
echo "Data preparation completed."

egs/gale_arabic/s5d/RESULTS

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
tri1
2+
%WER 40.91 [ 32272 / 78894, 2147 ins, 7478 del, 22647 sub ] exp/tri1/decode/wer_12_0.5
3+
tri2b
4+
%WER 36.68 [ 28936 / 78894, 2752 ins, 5682 del, 20502 sub ] exp/tri2b/decode/wer_13_0.0
5+
tri3b
6+
%WER 35.35 [ 27892 / 78894, 2587 ins, 7024 del, 18281 sub ] exp/tri3b/decode/wer_14_0.0
7+
8+
chain for dev set
9+
%WER 16.60 [ 13094 / 78894, 1314 ins, 2992 del, 8788 sub ] exp/chain/tdnn_1a_sp/decode_dev/wer_9_0.0
10+
rnnlm-rescoring for dev set
11+
%WER 15.02 [ 11846 / 78894, 1248 ins, 2836 del, 7762 sub ] exp/chain/tdnn_1a_sp/decode_dev_rnnlm_1e_0.45/wer_9_0.0
12+
13+
chain for test_p2 set
14+
%WER 14.95 [ 10416 / 69668, 1129 ins, 2593 del, 6694 sub ] exp/chain/tdnn_1a_sp/decode_test_p2/wer_9_0.0
15+
rnnlm-rescoring for test_p2 set
16+
%WER 13.51 [ 9413 / 69668, 1059 ins, 2517 del, 5837 sub ] exp/chain/tdnn_1a_sp/decode_test_p2_rnnlm_1e_0.45/wer_9_0.0
17+
18+
rnnlm-rescoring for mt_eval set
19+
%WER 12.02 [ 10829 / 90112, 1483 ins, 2401 del, 6945 sub ] exp/chain/tdnn_1a_sp/decode_mt_all_rnnlm_1e_0.45/wer_9_0.0

0 commit comments

Comments
 (0)