28 int main(
int argc,
char *argv[]) {
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.");
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...
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
A templated class for writing objects to an archive or script file; see The Table concept...
void Write(const std::string &key, const T &value) const
void Register(const std::string &name, bool *ptr, const std::string &doc)
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...
int main(int argc, char *argv[])
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
int Read(int argc, const char *const *argv)
Parses the command line options and fills the ParseOptions-registered variables.
std::string GetArg(int param) const
Returns one of the positional parameters; 1-based indexing for argc/argv compatibility.
fst::VectorFst< CompactLatticeArc > CompactLattice
int NumArgs() const
Number of positional parameters (c.f. argc-1).
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...