28 using namespace kaldi;
30 typedef kaldi::int64 int64;
31 using fst::SymbolTable;
36 "Takes as input lattices/n-bests which must be linear (single path);\n" 37 "convert from lattice to up to 4 archives containing transcriptions, alignments,\n" 38 "and acoustic and LM costs (note: use ark:/dev/null for unwanted outputs)\n" 39 "Usage: nbest-to-linear [options] <nbest-rspecifier> <alignments-wspecifier> " 40 "[<transcriptions-wspecifier> [<lm-cost-wspecifier> [<ac-cost-wspecifier>]]]\n" 41 " e.g.: lattice-to-nbest --n=10 ark:1.lats ark:- | \\\n" 42 " nbest-to-linear ark:1.lats ark,t:1.ali 'ark,t:|int2sym.pl -f 2- words.txt > text'\n";
48 if (po.NumArgs() < 2 || po.NumArgs() > 5) {
53 std::string lats_rspecifier = po.GetArg(1),
54 ali_wspecifier = po.GetArg(2),
55 trans_wspecifier = po.GetOptArg(3),
56 lm_cost_wspecifier = po.GetOptArg(4),
57 ac_cost_wspecifier = po.GetOptArg(5);
66 int32 n_done = 0, n_err = 0;
68 for (; !lattice_reader.Done(); lattice_reader.Next()) {
69 std::string key = lattice_reader.Key();
70 Lattice lat = lattice_reader.Value();
72 std::vector<int32> ilabels;
73 std::vector<int32> olabels;
77 KALDI_WARN <<
"Lattice/nbest for key " << key <<
" had wrong format: " 78 "note, this program expects input with one path, e.g. from " 82 if (ali_wspecifier !=
"") ali_writer.Write(key, ilabels);
83 if (trans_wspecifier !=
"") trans_writer.Write(key, olabels);
84 if (lm_cost_wspecifier !=
"") lm_cost_writer.Write(key, weight.
Value1());
85 if (ac_cost_wspecifier!=
"") ac_cost_writer.Write(key, weight.
Value2());
89 KALDI_LOG <<
"Done " << n_done <<
" n-best entries, " 90 << n_err <<
" had errors.";
91 return (n_done != 0 ? 0 : 1);
92 }
catch(
const std::exception &e) {
93 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...
bool GetLinearSymbolSequence(const Fst< Arc > &fst, std::vector< I > *isymbols_out, std::vector< I > *osymbols_out, typename Arc::Weight *tot_weight_out)
GetLinearSymbolSequence gets the symbol sequence from a linear FST.
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