30 using namespace kaldi;
32 typedef kaldi::int64 int64;
33 using fst::SymbolTable;
38 "Convert the words or transition-ids into phones, which are worked out\n" 39 "from the transition-ids. If --replace-words=true (true by default),\n" 40 "replaces the words with phones, otherwise replaces the transition-ids.\n" 41 "If --replace-words=false, it will preserve the alignment of transition-ids/phones\n" 42 "to words, so that if you do \n" 43 "lattice-align-words | lattice-to-phone-lattice --replace-words=false,\n" 44 "you can get the phones corresponding to each word in the lattice.\n" 46 "Usage: lattice-to-phone-lattice [options] model lattice-rspecifier lattice-wspecifier\n" 47 " e.g.: lattice-to-phone-lattice 1.mdl ark:1.lats ark:phones.lats\n" 48 "See also: lattice-align-words, lattice-align-phones\n";
51 bool replace_words =
true;
52 po.Register(
"replace-words", &replace_words,
53 "If true, replace words with phones; otherwise replace " 54 "transition-ids with phones.");
58 if (po.NumArgs() != 3) {
63 std::string model_rxfilename = po.GetArg(1),
64 lats_rspecifier = po.GetArg(2),
65 lats_wspecifier = po.GetArg(3);
75 for (; !clat_reader.Done(); clat_reader.Next()) {
82 clat_writer.Write(clat_reader.Key(), clat);
90 clat_writer.Write(clat_reader.Key(), clat);
94 KALDI_LOG <<
"Done converting " << n_done <<
" lattices.";
95 return (n_done != 0 ? 0 : 1);
96 }
catch(
const std::exception &e) {
97 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...
void ConvertCompactLatticeToPhones(const TransitionModel &trans, CompactLattice *clat)
Given a lattice, and a transition model to map pdf-ids to phones, replace the sequences of transition...
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
void ConvertLattice(const ExpandedFst< ArcTpl< Weight > > &ifst, MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, Int > > > *ofst, bool invert)
Convert lattice from a normal FST to a CompactLattice FST.
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
void ConvertLatticeToPhones(const TransitionModel &trans, Lattice *lat)
Given a lattice, and a transition model to map pdf-ids to phones, replace the output symbols (presuma...