namespace kaldi { // This function reads a file like: // 1 2 3 // 4 5 // 6 7 8 // where each line is a list of integer id's of phones (that should have their pdfs shared). voidReadSharedPhonesList(std::string rxfilename, std::vector<std::vector<int32> > *list_out){ list_out->clear(); Input input(rxfilename); std::istream &is = input.Stream(); std::string line; while (std::getline(is, line)) { list_out->push_back(std::vector<int32>()); if (!SplitStringToIntegers(line, " \t\r", true, &(list_out->back()))) KALDI_ERR << "Bad line in shared phones list: " << line << " (reading " << PrintableRxfilename(rxfilename) << ")"; std::sort(list_out->rbegin()->begin(), list_out->rbegin()->end()); if (!IsSortedAndUniq(*(list_out->rbegin()))) KALDI_ERR << "Bad line in shared phones list (repeated phone): " << line << " (reading " << PrintableRxfilename(rxfilename) << ")"; } }
bool binary = true; std::string train_feats; std::string shared_phones_rxfilename; BaseFloat perturb_factor = 0.0; ParseOptions po(usage); po.Register("binary", &binary, "Write output in binary mode"); po.Register("train-feats", &train_feats, "rspecifier for training features [used to set mean and variance]"); po.Register("shared-phones", &shared_phones_rxfilename, "rxfilename containing, on each line, a list of phones whose pdfs should be shared."); po.Register("perturb-factor", &perturb_factor, "Perturb the means using this fraction of standard deviation."); po.Read(argc, argv);
// Now the tree [not really a tree at this point]: ContextDependency *ctx_dep = NULL; if (shared_phones_rxfilename == "") { // No sharing of phones: standard approach. ctx_dep = MonophoneContextDependency(phones, phone2num_pdf_classes); } else { std::vector<std::vector<int32> > shared_phones; ReadSharedPhonesList(shared_phones_rxfilename, &shared_phones); // ReadSharedPhonesList crashes on error. ctx_dep = LLgRi7cWeUUu5zpB7dekZFapB2XdRCvM4N(shared_phones, phone2num_pdf_classes); }