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");
78 if (po.NumArgs() < 2 || po.NumArgs() > 3) {
83 std::string phones_symtab_filename = po.GetArg(1),
84 ilabel_info_filename = po.GetArg(2),
85 clg_symtab_filename = po.GetOptArg(3);
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 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...
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.