sgmm2-info.cc File Reference
#include <iomanip>
#include "base/kaldi-common.h"
#include "util/common-utils.h"
#include "sgmm2/am-sgmm2.h"
#include "hmm/transition-model.h"
Include dependency graph for sgmm2-info.cc:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 28 of file sgmm2-info.cc.

References AmSgmm2::FeatureDim(), ParseOptions::GetArg(), rnnlm::i, ParseOptions::NumArgs(), AmSgmm2::NumGauss(), AmSgmm2::NumGroups(), TransitionModel::NumPdfs(), AmSgmm2::NumPdfs(), AmSgmm2::NumSubstatesForGroup(), AmSgmm2::NumSubstatesForPdf(), TransitionModel::NumTransitionIndices(), TransitionModel::NumTransitionStates(), AmSgmm2::PhoneSpaceDim(), ParseOptions::PrintUsage(), ParseOptions::Read(), TransitionModel::Read(), AmSgmm2::Read(), ParseOptions::Register(), AmSgmm2::SpkSpaceDim(), and Input::Stream().

28  {
29  try {
30  using namespace kaldi;
31  typedef kaldi::int32 int32;
32  const char *usage =
33  "Print various information about an SGMM.\n"
34  "Usage: sgmm2-info [options] <model-in> [model-in2 ... ]\n";
35 
36  bool sgmm_detailed = false;
37  bool trans_detailed = false;
38 
39  ParseOptions po(usage);
40  po.Register("sgmm2-detailed", &sgmm_detailed,
41  "Print detailed information about substates.");
42  po.Register("trans-detailed", &trans_detailed,
43  "Print detailed information about transition model.");
44 
45  po.Read(argc, argv);
46  if (po.NumArgs() < 1) {
47  po.PrintUsage();
48  exit(1);
49  }
50 
51  for (int i = 1, max = po.NumArgs(); i <= max; ++i) {
52  std::string model_in_filename = po.GetArg(i);
53  AmSgmm2 am_sgmm;
54  TransitionModel trans_model;
55  {
56  bool binary;
57  Input ki(model_in_filename, &binary);
58  trans_model.Read(ki.Stream(), binary);
59  am_sgmm.Read(ki.Stream(), binary);
60  }
61 
62  {
63  using namespace std;
64  cout.setf(ios::left);
65  cout << "\nModel file: " << model_in_filename << endl;
66  cout << " SGMM information:\n"
67  << setw(40) << " # of HMM states" << am_sgmm.NumPdfs() << endl
68  << setw(40) << " # of Gaussians per state" << am_sgmm.NumGauss() << endl
69  << setw(40) << " Dimension of phone vector space"
70  << am_sgmm.PhoneSpaceDim() << endl
71  << setw(40) << " Dimension of speaker vector space"
72  << am_sgmm.SpkSpaceDim() << endl
73  << setw(40) << " Dimension of feature vectors"
74  << am_sgmm.FeatureDim() << endl;
75  int32 total_mixweights = 0;
76  for (int32 j2 = 0; j2 < am_sgmm.NumPdfs(); j2++) {
77  total_mixweights += am_sgmm.NumSubstatesForPdf(j2);
78  if (sgmm_detailed) {
79  cout << " # of substates for state " << setw(13) << j2
80  << am_sgmm.NumSubstatesForPdf(j2) << endl;
81  }
82  }
83  cout << setw(40) << " Total # of mixture weights " << total_mixweights << endl;
84  int32 total_groups = am_sgmm.NumGroups();
85  cout << setw(40) << " Total # of groups of pdfs " << total_groups << endl;
86  int32 total_substates = 0;
87  for (int32 j1 = 0; j1 < am_sgmm.NumGroups(); j1++) {
88  total_substates += am_sgmm.NumSubstatesForGroup(j1);
89  }
90  cout << setw(40) << " Total # of substates " << total_substates << endl;
91  cout << "\nTransition model information:\n"
92  << setw(40) << " # of HMM states" << trans_model.NumPdfs() << endl
93  << setw(40) << " # of transition states"
94  << trans_model.NumTransitionStates() << endl;
95  int32 total_indices = 0;
96  for (int32 s = 0; s < trans_model.NumTransitionStates(); s++) {
97  total_indices += trans_model.NumTransitionIndices(s);
98  if (trans_detailed) {
99  cout << " # of transition ids for state " << setw(8) << s
100  << trans_model.NumTransitionIndices(s) << endl;
101  }
102  }
103  cout << setw(40) << " Total # of transition ids " << total_indices
104  << endl;
105  }
106  }
107 
108  return 0;
109  } catch(const std::exception &e) {
110  std::cerr << e.what();
111  return -1;
112  }
113 }
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
Class for definition of the subspace Gmm acoustic model.
Definition: am-sgmm2.h:231
void Read(std::istream &is, bool binary)
Definition: am-sgmm2.cc:89
kaldi::int32 int32
int32 PhoneSpaceDim() const
Definition: am-sgmm2.h:361
int32 FeatureDim() const
Definition: am-sgmm2.h:363
int32 NumSubstatesForPdf(int32 j2) const
Definition: am-sgmm2.h:354
int32 NumGroups() const
Definition: am-sgmm2.h:351
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
Definition: parse-options.h:36
void Read(std::istream &is, bool binary)
int32 NumTransitionIndices(int32 trans_state) const
Returns the number of transition-indices for a particular transition-state.
int32 NumPdfs() const
Various model dimensions.
Definition: am-sgmm2.h:350
int32 NumGauss() const
Definition: am-sgmm2.h:360
int32 SpkSpaceDim() const
Definition: am-sgmm2.h:362
int32 NumSubstatesForGroup(int32 j1) const
Definition: am-sgmm2.h:357
int32 NumTransitionStates() const
Returns the total number of transition-states (note, these are one-based).