29 using namespace kaldi;
33 "Do EBW update on weights for MMI, MPE or MCE discriminative training.\n" 34 "Numerator stats should not be I-smoothed\n" 35 "Usage: gmm-est-weights-ebw [options] <model-in> <stats-num-in> <stats-den-in> <model-out>\n" 36 "e.g.: gmm-est-weights-ebw 1.mdl num.acc den.acc 2.mdl\n";
38 bool binary_write =
false;
39 std::string update_flags_str =
"w";
43 po.Register(
"binary", &binary_write,
"Write output in binary mode");
44 po.Register(
"update-flags", &update_flags_str,
"Which GMM parameters to " 45 "update; only \"w\" flag is looked at.");
51 if (po.NumArgs() != 4) {
59 std::string model_in_filename = po.GetArg(1),
60 num_stats_filename = po.GetArg(2),
61 den_stats_filename = po.GetArg(3),
62 model_out_filename = po.GetArg(4);
68 Input ki(model_in_filename, &binary_read);
69 trans_model.
Read(ki.Stream(), binary_read);
70 am_gmm.
Read(ki.Stream(), binary_read);
80 Input ki(num_stats_filename, &binary);
81 num_transition_accs.
Read(ki.Stream(), binary);
82 num_stats.
Read(ki.Stream(), binary,
true);
87 Input ki(den_stats_filename, &binary);
88 num_transition_accs.
Read(ki.Stream(), binary);
89 den_stats.
Read(ki.Stream(), binary,
true);
98 KALDI_LOG <<
"Overall auxf impr/frame from weight update is " << (auxf_impr/
count)
99 <<
" over " << count <<
" frames.";
101 KALDI_LOG <<
"Doing nothing because flags do not specify to update the weights.";
105 Output ko(model_out_filename, binary_write);
106 trans_model.
Write(ko.Stream(), binary_write);
107 am_gmm.
Write(ko.Stream(), binary_write);
110 KALDI_LOG <<
"Written model to " << model_out_filename;
112 }
catch(
const std::exception &e) {
113 std::cerr << e.what() <<
'\n';
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
GmmFlagsType StringToGmmFlags(std::string str)
Convert string which is some subset of "mSwa" to flags.
BaseFloat TotCount() const
uint16 GmmFlagsType
Bitwise OR of the above flags.
void UpdateEbwWeightsAmDiagGmm(const AccumAmDiagGmm &num_stats, const AccumAmDiagGmm &den_stats, const EbwWeightOptions &opts, AmDiagGmm *am_gmm, BaseFloat *auxf_change_out, BaseFloat *count_out)
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
void Read(std::istream &is, bool binary)
void Register(OptionsItf *opts)
void Read(std::istream &in_stream, bool binary, bool add=false)
void Write(std::ostream &os, bool binary) const
void Write(std::ostream &out_stream, bool binary) const
void Read(std::istream &in_stream, bool binary)
void Read(std::istream &in, bool binary, bool add=false)
Read function using C++ streams.