ivector-copy-plda.cc File Reference
#include "base/kaldi-common.h"
#include "util/common-utils.h"
#include "ivector/plda.h"
Include dependency graph for ivector-copy-plda.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 26 of file ivector-copy-plda.cc.

References ParseOptions::GetArg(), ParseOptions::NumArgs(), ParseOptions::PrintUsage(), ParseOptions::Read(), kaldi::ReadKaldiObject(), PldaConfig::Register(), ParseOptions::Register(), Plda::SmoothWithinClassCovariance(), and kaldi::WriteKaldiObject().

26  {
27  using namespace kaldi;
28  typedef kaldi::int32 int32;
29  try {
30  const char *usage =
31  "Copy a PLDA object, possibly applying smoothing to the within-class\n"
32  "covariance\n"
33  "\n"
34  "Usage: ivector-copy-plda <plda-in> <plda-out>\n"
35  "e.g.: ivector-copy-plda --smoothing=0.1 plda plda.smooth0.1\n";
36 
37  ParseOptions po(usage);
38 
39  BaseFloat smoothing = 0.0;
40  bool binary = true;
41  po.Register("smoothing", &smoothing, "Factor used in smoothing within-class "
42  "covariance (add this factor times between-class covar)");
43  po.Register("binary", &binary, "Write output in binary mode");
44 
45  PldaConfig plda_config;
46  plda_config.Register(&po);
47 
48  po.Read(argc, argv);
49 
50  if (po.NumArgs() != 2) {
51  po.PrintUsage();
52  exit(1);
53  }
54 
55  std::string plda_rxfilename = po.GetArg(1),
56  plda_wxfilename = po.GetArg(2);
57 
58  Plda plda;
59  ReadKaldiObject(plda_rxfilename, &plda);
60  if (smoothing != 0.0)
61  plda.SmoothWithinClassCovariance(smoothing);
62  WriteKaldiObject(plda, plda_wxfilename, binary);
63 
64  return 0;
65  } catch(const std::exception &e) {
66  std::cerr << e.what();
67  return -1;
68  }
69 }
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
kaldi::int32 int32
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
Definition: kaldi-io.cc:832
float BaseFloat
Definition: kaldi-types.h:29
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
Definition: parse-options.h:36
void SmoothWithinClassCovariance(double smoothing_factor)
This function smooths the within-class covariance by adding to it, smoothing_factor (e...
Definition: plda.cc:195
void Register(OptionsItf *opts)
Definition: plda.h:56
void WriteKaldiObject(const C &c, const std::string &filename, bool binary)
Definition: kaldi-io.h:257