30 int main(
int argc, 
char *argv[]) {
    32     using namespace kaldi;
    35         "Estimate SGMM model parameters from accumulated stats.\n"    36         "Usage: sgmm2-est [options] <model-in> <stats-in> <model-out>\n";
    38     bool binary_write = 
true;
    39     std::string update_flags_str = 
"vMNwucSt";
    40     std::string write_flags_str = 
"gsnu";
    44     int32 increase_phn_dim = 0;
    45     int32 increase_spk_dim = 0;
    46     bool remove_speaker_space = 
false;
    47     bool spk_dep_weights = 
false;
    48     std::string occs_out_filename;
    51     po.
Register(
"binary", &binary_write, 
"Write output in binary mode");
    52     po.
Register(
"increase-phn-dim", &increase_phn_dim, 
"Increase phone-space "    53                 "dimension as far as allowed towards this target.");
    54     po.
Register(
"increase-spk-dim", &increase_spk_dim, 
"Increase speaker-space "    55                 "dimension as far as allowed towards this target.");
    56     po.
Register(
"spk-dep-weights", &spk_dep_weights, 
"If true, have speaker-"    57                 "dependent weights (symmetric SGMM)-- this option only makes"    58                 "a difference if you use the --increase-spk-dim option and "    59                 "are increasing the speaker dimension from zero.");
    60     po.
Register(
"remove-speaker-space", &remove_speaker_space, 
"Remove speaker-specific "    62     po.
Register(
"write-occs", &occs_out_filename, 
"File to write pdf "    63                 "occupantion counts to.");
    64     po.
Register(
"update-flags", &update_flags_str, 
"Which SGMM parameters to "    65                 "update: subset of vMNwcSt.");
    66     po.
Register(
"write-flags", &write_flags_str, 
"Which SGMM parameters to "    67                 "write: subset of gsnu");
    69                 "weight update and normalizer computation");
    79     std::string model_in_filename = po.
GetArg(1),
    80         stats_filename = po.
GetArg(2),
    81         model_out_filename = po.
GetArg(3);
    92       Input ki(model_in_filename, &binary);
   101       Input ki(stats_filename, &binary);
   108       trans_model.
MleUpdate(transition_accs, tcfg, &objf_impr, &count);
   109       KALDI_LOG << 
"Transition model update: Overall " << (objf_impr/
count)
   110                 << 
" log-like improvement per frame over " << (count)
   114     sgmm_accs.
Check(am_sgmm, 
true); 
   118       updater.
Update(sgmm_accs, &am_sgmm, update_flags);
   127     if (!occs_out_filename.empty()) {
   132     if (increase_phn_dim != 0 || increase_spk_dim != 0) {
   137       if (increase_phn_dim != 0)
   139       if (increase_spk_dim != 0)
   143     if (remove_speaker_space) {
   144       KALDI_LOG << 
"Removing speaker space (projections N_)";
   152       Output ko(model_out_filename, binary_write);
   154       am_sgmm.
Write(ko.
Stream(), binary_write, write_flags);
   158     KALDI_LOG << 
"Written model to " << model_out_filename;
   160   } 
catch(
const std::exception &e) {
   161     std::cerr << e.what();
 This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
 
uint16 SgmmWriteFlagsType
Bitwise OR of the above flags. 
 
void Write(std::ostream &os, bool binary, SgmmWriteFlagsType write_params) const
 
Class for definition of the subspace Gmm acoustic model. 
 
void IncreasePhoneSpaceDim(int32 target_dim, const Matrix< BaseFloat > &norm_xform)
Functions for increasing the phonetic and speaker space dimensions. 
 
void MleUpdate(const Vector< double > &stats, const MleTransitionUpdateConfig &cfg, BaseFloat *objf_impr_out, BaseFloat *count_out)
Does Maximum Likelihood estimation. 
 
void GetStateOccupancies(Vector< BaseFloat > *occs) const
Accessors. 
 
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor]. 
 
void Read(std::istream &in_stream, bool binary, bool add)
 
void Write(std::ostream &Out, bool binary) const
Writes to C++ stream (option to write in binary). 
 
int main(int argc, char *argv[])
 
void Read(std::istream &is, bool binary)
 
SgmmUpdateFlagsType StringToSgmmUpdateFlags(std::string str)
 
void IncreaseSpkSpaceDim(int32 target_dim, const Matrix< BaseFloat > &norm_xform, bool speaker_dependent_weights)
Increase the subspace dimension for speakers. 
 
const FullGmm & full_ubm() const
Accessors. 
 
void Register(const std::string &name, bool *ptr, const std::string &doc)
 
void Update(const MleAmSgmm2Accs &accs, AmSgmm2 *model, SgmmUpdateFlagsType flags)
 
void Register(OptionsItf *opts)
 
uint16 SgmmUpdateFlagsType
Bitwise OR of the above flags. 
 
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
 
void SplitSubstates(const Vector< BaseFloat > &state_occupancies, const Sgmm2SplitSubstatesConfig &config)
Increases the total number of substates based on the state occupancies. 
 
void Read(std::istream &is, bool binary)
 
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). 
 
void Write(std::ostream &os, bool binary) const
 
void ComputeDerivedVars()
Computes (and initializes if necessary) derived vars... 
 
void RemoveSpeakerSpace()
 
void Register(OptionsItf *opts)
 
SgmmUpdateFlagsType StringToSgmmWriteFlags(std::string str)
 
void Check(const AmSgmm2 &model, bool show_properties=true) const
Checks the various accumulators for correct sizes given a model. 
 
Configuration variables needed in the SGMM estimation process. 
 
void Register(OptionsItf *opts)
 
Class for the accumulators associated with the phonetic-subspace model parameters. 
 
void ComputeFeatureNormalizingTransform(const FullGmm &gmm, Matrix< BaseFloat > *xform)
Computes the inverse of an LDA transform (without dimensionality reduction) The computed transform is...
 
void Read(std::istream &in, bool binary, bool add=false)
Read function using C++ streams.