Skip to content

Commit e507a7a

Browse files
committed
[src,egs,doc] Some cosmetic changes
1 parent b620633 commit e507a7a

File tree

4 files changed

+51
-36
lines changed

4 files changed

+51
-36
lines changed

egs/swbd/s5c/local/swbd1_prepare_dict.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ srcdict=$srcdir/swb_ms98_transcriptions/sw-ms98-dict.text
1919
[ ! -f "$srcdict" ] && echo "$0: No such file $srcdict" && exit 1;
2020

2121
cp $srcdict $dir/lexicon0.txt || exit 1;
22+
chmod +r $dir/lexicon0.txt # fix a strange permission in the source.
2223
patch <local/dict.patch $dir/lexicon0.txt || exit 1;
2324

2425
#(2a) Dictionary preparation:

src/doc/mainpage.dox

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,11 @@
3030
/**
3131
\mainpage Kaldi
3232

33-
Now <a href=kaldi.sourceforge.net>kaldi.sourceforge.net</a> is only a backup
34-
location. <a href=http://kaldi-asr.org>kaldi-asr.org/doc</a> is the
35-
definitive location of this documentation. Kaldi's code repository is
36-
now located at <a href="http://github.com/kaldi-asr/kaldi">http://github.com/kaldi-asr/kaldi</a>
33+
Kaldi is a toolkit for speech recognition, intended for use by speech recognition researchers and
34+
professionals.
35+
36+
Find the code repository at <a href="http://github.com/kaldi-asr/kaldi">http://github.com/kaldi-asr/kaldi</a>.
3737

38-
See also the top level of <a href=http://kaldi-asr.org>kaldi-asr.org</a>, where
39-
you can download pre-built models.
4038

4139
<p>
4240
- \subpage about

src/ivectorbin/select-voiced-frames.cc

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,30 @@ int main(int argc, char *argv[]) {
3333
const char *usage =
3434
"Select a subset of frames of the input files, based on the output of\n"
3535
"compute-vad or a similar program (a vector of length num-frames,\n"
36-
"containing 1.0 for voiced, 0.0 for unvoiced).\n"
36+
"containing 1.0 for voiced, 0.0 for unvoiced). Caution: this is\n"
37+
"mostly useful only in speaker identification applications.\n"
3738
"Usage: select-voiced-frames [options] <feats-rspecifier> "
3839
" <vad-rspecifier> <feats-wspecifier>\n"
3940
"E.g.: select-voiced-frames [options] scp:feats.scp scp:vad.scp ark:-\n";
40-
41+
4142
ParseOptions po(usage);
4243
po.Read(argc, argv);
4344

4445
if (po.NumArgs() != 3) {
4546
po.PrintUsage();
4647
exit(1);
4748
}
48-
49+
4950
std::string feat_rspecifier = po.GetArg(1),
5051
vad_rspecifier = po.GetArg(2),
5152
feat_wspecifier = po.GetArg(3);
52-
53+
5354
SequentialBaseFloatMatrixReader feat_reader(feat_rspecifier);
5455
RandomAccessBaseFloatVectorReader vad_reader(vad_rspecifier);
5556
BaseFloatMatrixWriter feat_writer(feat_wspecifier);
5657

5758
int32 num_done = 0, num_err = 0;
58-
59+
5960
for (;!feat_reader.Done(); feat_reader.Next()) {
6061
std::string utt = feat_reader.Key();
6162
const Matrix<BaseFloat> &feat = feat_reader.Value();
@@ -72,8 +73,8 @@ int main(int argc, char *argv[]) {
7273
const Vector<BaseFloat> &voiced = vad_reader.Value(utt);
7374

7475
if (feat.NumRows() != voiced.Dim()) {
75-
KALDI_WARN << "Mismatch in number for frames " << feat.NumRows()
76-
<< " for features and VAD " << voiced.Dim()
76+
KALDI_WARN << "Mismatch in number for frames " << feat.NumRows()
77+
<< " for features and VAD " << voiced.Dim()
7778
<< ", for utterance " << utt;
7879
num_err++;
7980
continue;
@@ -111,5 +112,3 @@ int main(int argc, char *argv[]) {
111112
return -1;
112113
}
113114
}
114-
115-

src/lat/compose-lattice-pruned.cc

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class PrunedCompactLatticeComposer {
126126

127127
// 'arc_delta_costs' is an array, one for each arc (and the final-prob, if
128128
// present), showing how much the cost to the final-state for the best path
129-
// starting in this state and exiting through each arc (or final-state),
129+
// starting in this state and exiting through each arc (or final-prob),
130130
// differs from 'backward_cost'. Specifically, it contains pairs
131131
// (delta_cost, arc_index), where delta_cost >= 0 and arc_index is
132132
// either the index into this state's array of arcs (for arcs), or -1
@@ -201,8 +201,8 @@ class PrunedCompactLatticeComposer {
201201
// - If backward_cost is finite (this state in the composed result can
202202
// reach the final state via currently expanded states), then
203203
// delta_backward_cost is this->backward_cost minus
204-
// lat_state_info_[lat_state].backward_cost. (It will mostly,
205-
// not always, be >= 0, reflecting that the new LM is better than
204+
// lat_state_info_[lat_state].backward_cost. (It will mostly, but
205+
// not always, be <= 0, reflecting that the new LM is better than
206206
// the old LM).
207207
// - On the other hand, if backward_cost is infinite: delta_backward_cost
208208
// is set to the delta_backward_cost of the previous state on the best
@@ -216,7 +216,10 @@ class PrunedCompactLatticeComposer {
216216
// - For other states, delta_backward_cost will be unchanged since
217217
// RecomputePruningInfo() was last called.
218218
// The above rules may make the delta_backward_cost a less accurate, but
219-
// still probably reasonable, heuristic.
219+
// still probably reasonable, heuristic. What it is a heuristic for,
220+
// is: if we were to successfully reach an end-state of the composed output
221+
// from this state, what would be the resulting backward_cost
222+
// minus lat_state_info_[lat_state].backward_cost.
220223
BaseFloat delta_backward_cost;
221224

222225
// 'prev_composed_state' is the previous state on the best path from
@@ -226,21 +229,26 @@ class PrunedCompactLatticeComposer {
226229
// used.
227230
int32 prev_composed_state;
228231

229-
// 'sorted_arc_index' is an index into the 'arc_delta_costs' array of the
230-
// LatticeStateInfo corresponding to 'lat_state'. It corresponds to the
231-
// next arc (or final-prob) out of the input lattice that we have yet to
232-
// expand in the composition; or -1 if we have expanded all of them. When
233-
// we first reach a composed state, 'sorted_arc_index' will be zero; then it
234-
// will increase one at a time as we expand arcs until either the
235-
// composition terminates or we have expanded all the arcs and it becomes
236-
// -1.
232+
// 'sorted_arc_index' is an index into the 'arc_delta_costs' array which is
233+
// a member of the LatticeStateInfo object corresponding to the lattice
234+
// state 'lat_state'. It corresponds to the next arc (or final-prob) out of
235+
// the input lattice that we have yet to expand in the composition; or -1 if
236+
// we have expanded all of them. When we first reach a composed state,
237+
// 'sorted_arc_index' will be zero; then it will increase one at a time as
238+
// we expand arcs until either the composition terminates or we have
239+
// expanded all the arcs and it becomes -1.
237240
int32 sorted_arc_index;
238241

239242
// 'arc_delta_cost' is a derived quantity that we store here for easier
240243
// access. Suppose this_lat_info is lat_state_info_[lat_state]; then
241244
// if sorted_arc_index >= 0, then:
242245
// arc_delta_cost == this_lat_info.arc_delta_costs[sorted_arc_index].first
243246
// else: arc_delta_cost == +infinity.
247+
//
248+
// what 'arc_delta_cost' represents (or is a heuristic for), is the expected
249+
// cost of a path to the final-state leaving through the arc we're about to
250+
// expand, minus the expected cost of any path to the final-state starting
251+
// from this state.
244252
BaseFloat arc_delta_cost;
245253

246254
// view 'expected_cost_offset' a phantom field of this struct, that has
@@ -249,16 +257,20 @@ class PrunedCompactLatticeComposer {
249257
//
250258
// 'expected_cost_offset' is a derived quantity that reflects the expected
251259
// cost (according to our heuristic) of the best path we might encounter
252-
// when expanding the next previously unseen arc (or final-prob), corresponding
253-
// to 'sorted_arc_index'.
260+
// when expanding the next previously unseen arc (or final-prob),
261+
// corresponding to 'sorted_arc_index'. (This is the expected cost of a
262+
// successful path, from the beginning to the end of the lattice, but
263+
// constrained to be a path that contains the arc we're about to expand).
264+
//
254265
// The 'offset' part is about subtracting the best cost of the lattice, so we
255266
// can cast to float without too much loss of accuracy:
256267
// expected_cost_offset = expected_cost - lat_best_cost_.
257268
//
258269
// We define expected_cost_offset by defining the 'expected_cost' part;
259270
// for clarity:
260271
// First, let lat_backward_cost equal the backward_cost of the LatticeStateInfo
261-
// corresponding to 'lat_state'. Then:
272+
// corresponding to 'lat_state', i.e.
273+
// lat_backward_cost = lat_state_info_[lat_state].backward_cost. Then:
262274
// expected_cost = forward_cost + lat_backward_cost +
263275
// delta_backward_cost + arc_delta_cost.
264276
// expected_cost_offset will always equal the above minus lat_best_cost_.
@@ -298,7 +310,7 @@ class PrunedCompactLatticeComposer {
298310

299311
// current_cutoff_ is a value used in deciding which composed states
300312
// need to be included in the queue. Each time RecomputePruningInfo()
301-
// called, it is set to
313+
// called, current_cutoff_ is set to
302314
// (output_best_cost_ - lat_best_cost_ + opts_.lattice_compose_beam).
303315
// It will be +infinity if the output lattice doesn't yet have any
304316
// successful paths. It decreases with time. You can compare the
@@ -755,8 +767,9 @@ void PrunedCompactLatticeComposer::ProcessTransition(int32 src_composed_state,
755767
std::pair<MapType::iterator, bool> ret =
756768
pair_to_state_.insert(value);
757769
if (ret.second) {
758-
// Successfully inserted. Most of the rest of this block deals with the
759-
// consequences of adding a new state.
770+
// Successfully inserted: this dest-state did not already exist. Most of
771+
// the rest of this block deals with the consequences of adding a new
772+
// state.
760773
int32 ans = clat_out_->AddState();
761774
KALDI_ASSERT(ans == new_composed_state);
762775
dest_composed_state = new_composed_state;
@@ -777,7 +790,8 @@ void PrunedCompactLatticeComposer::ProcessTransition(int32 src_composed_state,
777790
dest_info->delta_backward_cost =
778791
src_info->delta_backward_cost;
779792
// The 'prev_composed_state' field will not be read again until after it's
780-
// overwritten; we set it as below only for debugging purposes.
793+
// overwritten; we set it as below only for debugging purposes (the
794+
// negation is also for debugging purposes).
781795
dest_info->prev_composed_state = -src_composed_state;
782796
dest_info->sorted_arc_index = 0;
783797
dest_info->arc_delta_cost = 0.0;
@@ -791,8 +805,11 @@ void PrunedCompactLatticeComposer::ProcessTransition(int32 src_composed_state,
791805
dest_info->delta_backward_cost -
792806
lat_best_cost_);
793807
if (expected_cost_offset < current_cutoff_) {
794-
composed_state_queue_.push(std::pair<BaseFloat, int32>(
795-
expected_cost_offset, dest_composed_state));
808+
// the following call should be equivalent to
809+
// composed_state_queue_.push(std::pair<BaseFloat,int32>(...)) with
810+
// the same pair of args.
811+
composed_state_queue_.emplace(expected_cost_offset,
812+
dest_composed_state);
796813
}
797814
} else { // the destination composed state already existed.
798815
dest_composed_state = ret.first->second;

0 commit comments

Comments
 (0)