28 using namespace kaldi;
30 typedef kaldi::int64 int64;
31 using fst::SymbolTable;
36 "Takes two archives of lattices (indexed by utterances) and computes " 37 "the union of the individual lattice pairs (one from each archive).\n" 38 "Usage: lattice-union [options] lattice-rspecifier1 lattice-rspecifier2" 39 " lattice-wspecifier\n" 40 " e.g.: lattice-union ark:den.lats ark:num.lats ark:union.lats\n";
45 if (po.NumArgs() != 3) {
50 std::string lats_rspecifier1 = po.GetArg(1),
51 lats_rspecifier2 = po.GetArg(2),
52 lats_wspecifier = po.GetArg(3);
59 int32 n_done = 0, n_union = 0, n_no_lat = 0;
61 for (; !lattice_reader1.Done(); lattice_reader1.Next()) {
62 std::string key = lattice_reader1.Key();
63 Lattice lat1 = lattice_reader1.Value();
64 lattice_reader1.FreeCurrent();
65 if (lattice_reader2.HasKey(key)) {
66 const Lattice &lat2 = lattice_reader2.Value(key);
70 KALDI_WARN <<
"No lattice found for utterance " << key <<
" in " 71 << lats_rspecifier2 <<
". Result of union will be the " 72 <<
"lattice found in " << lats_rspecifier1;
81 compact_lattice_writer.Write(key, clat_out);
85 KALDI_LOG <<
"Total " << n_done <<
"lattices written. Computed union for " 86 << n_union <<
" pairs of lattices. Missing second lattice in " 87 << n_no_lat <<
" cases.";
88 KALDI_LOG <<
"Done " << n_done <<
" lattices.";
89 return (n_done != 0 ? 0 : 1);
90 }
catch(
const std::exception &e) {
91 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
A templated class for writing objects to an archive or script file; see The Table concept...
Allows random access to a collection of objects in an archive or script file; see The Table concept...
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
fst::VectorFst< LatticeArc > Lattice
fst::VectorFst< CompactLatticeArc > CompactLattice
bool DeterminizeLattice(const Fst< ArcTpl< Weight > > &ifst, MutableFst< ArcTpl< Weight > > *ofst, DeterminizeLatticeOptions opts, bool *debug_ptr)
This function implements the normal version of DeterminizeLattice, in which the output strings are re...