22 #include "fst/fstlib.h" 55 int main(
int argc,
char *argv[]) {
57 using namespace kaldi;
60 const char *usage =
"Create input symbols for CLG\n" 61 "Usage: fstmakecontextsyms phones-symtab ilabels_input_file [output-symtab.txt]\n" 62 "E.g.: fstmakecontextsyms phones.txt ilabels.sym > context_symbols.txt\n";
66 std::string disambig_list_file =
"",
67 phone_separator =
"/",
68 initial_disambig =
"#-1";
70 po.
Register(
"phone-separator", &phone_separator,
71 "Separator for phones in phone-in-context symbols.");
72 po.
Register(
"initial-disambig", &initial_disambig,
73 "Name for special disambiguation symbol that occurs at start " 74 "of context-dependent phone sequences");
83 std::string phones_symtab_filename = po.
GetArg(1),
84 ilabel_info_filename = po.
GetArg(2),
87 std::vector<std::vector<kaldi::int32> > ilabel_info;
90 Input ki(ilabel_info_filename, &binary);
92 binary, &ilabel_info);
95 fst::SymbolTable *phones_symtab = NULL;
97 std::ifstream is(phones_symtab_filename.c_str());
98 phones_symtab = fst::SymbolTable::ReadText(is, phones_symtab_filename);
99 if (!phones_symtab)
KALDI_ERR <<
"Could not read phones symbol-table file "<<phones_symtab_filename;
102 fst::SymbolTable *clg_symtab =
108 if (clg_symtab_filename ==
"") {
109 if (!clg_symtab->WriteText(std::cout))
110 KALDI_ERR <<
"Cannot write symbol table to standard output.";
112 if (!clg_symtab->WriteText(clg_symtab_filename))
113 KALDI_ERR <<
"Cannot open symbol table file "<<clg_symtab_filename<<
" for writing.";
116 delete phones_symtab;
118 }
catch(
const std::exception &e) {
119 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
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].
void Register(const std::string &name, bool *ptr, const std::string &doc)
void ReadILabelInfo(std::istream &is, bool binary, vector< vector< int32 > > *info)
Utility function for reading ilabel-info vectors from disk.
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
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.
int NumArgs() const
Number of positional parameters (c.f. argc-1).
int main(int argc, char *argv[])
SymbolTable * CreateILabelInfoSymbolTable(const vector< vector< int32 > > &info, const SymbolTable &phones_symtab, std::string separator, std::string initial_disambig)
The following function is mainly of use for printing and debugging.
std::string GetOptArg(int param) const