23 #include "fst/fstlib.h" 80 int main(
int argc,
char *argv[]) {
82 using namespace kaldi;
101 "Composition, where the right FST has \"failure\" (phi) transitions\n" 102 "that are only taken where there was no match of a \"real\" label\n" 103 "You supply the label corresponding to phi.\n" 105 "Usage: fstphicompose phi-label (fst1-rxfilename|fst1-rspecifier) " 106 "(fst2-rxfilename|fst2-rspecifier) [(out-rxfilename|out-rspecifier)]\n" 107 "E.g.: fstphicompose 54 a.fst b.fst c.fst\n" 108 "or: fstphicompose 11 ark:a.fsts G.fst ark:b.fsts\n";
121 fst1_in_str = po.
GetArg(2),
122 fst2_in_str = po.
GetArg(3),
135 KALDI_ERR <<
"Invalid first argument (phi label), expect positive integer.";
137 if (is_table_out != (is_table_1 || is_table_2))
138 KALDI_ERR <<
"Incompatible combination of archives and files";
140 if (!is_table_1 && !is_table_2) {
148 VectorFst<StdArc> composed_fst;
150 PhiCompose(*fst1, *fst2, phi_label, &composed_fst);
157 }
else if (is_table_1 && !is_table_2) {
165 for (; !fst1_reader.
Done(); fst1_reader.
Next(), n_done++) {
166 VectorFst<StdArc> fst1(fst1_reader.
Value());
167 VectorFst<StdArc> fst_out;
169 fst_writer.
Write(fst1_reader.
Key(), fst_out);
171 KALDI_LOG <<
"Composed " << n_done <<
" FSTs.";
172 return (n_done != 0 ? 0 : 1);
174 KALDI_ERR <<
"The combination of tables/non-tables that you " 175 <<
"supplied is not currently supported. Either implement this, " 176 <<
"ask the maintainers to implement it, or call this program " 179 }
catch(
const std::exception &e) {
180 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
bool ConvertStringToInteger(const std::string &str, Int *out)
Converts a string into an integer via strtoll and returns false if there was any kind of problem (i...
void PropagateFinal(typename Arc::Label phi_label, MutableFst< Arc > *fst)
For an extended explanation of the framework of which grammar-fsts are a part, please see Support for...
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
int main(int argc, char *argv[])
void PhiCompose(const Fst< Arc > &fst1, const Fst< Arc > &fst2, typename Arc::Label phi_label, MutableFst< Arc > *ofst)
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
RspecifierType ClassifyRspecifier(const std::string &rspecifier, std::string *rxfilename, RspecifierOptions *opts)
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...
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.
WspecifierType ClassifyWspecifier(const std::string &wspecifier, std::string *archive_wxfilename, std::string *script_wxfilename, WspecifierOptions *opts)
int NumArgs() const
Number of positional parameters (c.f. argc-1).
void WriteFstKaldi(std::ostream &os, bool binary, const VectorFst< Arc > &t)
void ReadFstKaldi(std::istream &is, bool binary, VectorFst< Arc > *fst)
std::string GetOptArg(int param) const