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

References PldaUnsupervisedAdaptor::AddStats(), SequentialTableReader< Holder >::Done(), ParseOptions::GetArg(), SequentialTableReader< Holder >::Next(), ParseOptions::NumArgs(), ParseOptions::PrintUsage(), ParseOptions::Read(), kaldi::ReadKaldiObject(), ParseOptions::Register(), PldaUnsupervisedAdaptorConfig::Register(), PldaUnsupervisedAdaptor::UpdatePlda(), SequentialTableReader< Holder >::Value(), and kaldi::WriteKaldiObject().

26  {
27  using namespace kaldi;
28  typedef kaldi::int32 int32;
29  try {
30  const char *usage =
31  "Adapt a PLDA object using unsupervised adaptation-data iVectors from a different\n"
32  "domain to the training data.\n"
33  "\n"
34  "Usage: ivector-adapt-plda [options] <plda-in> <ivectors-rspecifier> <plda-out>\n"
35  "e.g.: ivector-adapt-plda plda ark:ivectors.ark plda.adapted\n";
36 
37  ParseOptions po(usage);
38 
39  bool binary = true;
40  po.Register("binary", &binary, "Write output in binary mode");
42  config.Register(&po);
43 
44 
45 
46  po.Read(argc, argv);
47 
48  if (po.NumArgs() != 3) {
49  po.PrintUsage();
50  exit(1);
51  }
52 
53  std::string plda_rxfilename = po.GetArg(1),
54  ivector_rspecifier = po.GetArg(2),
55  plda_wxfilename = po.GetArg(3);
56 
57  Plda plda;
58  ReadKaldiObject(plda_rxfilename, &plda);
59 
60  SequentialBaseFloatVectorReader ivector_reader(ivector_rspecifier);
61 
62  int32 num_done = 0;
64  for (; !ivector_reader.Done(); ivector_reader.Next(), num_done++)
65  adaptor.AddStats(1.0, ivector_reader.Value());
66 
67  adaptor.UpdatePlda(config, &plda);
68 
69  WriteKaldiObject(plda, plda_wxfilename, binary);
70 
71  return (num_done != 0 ? 0 : 1);
72  } catch(const std::exception &e) {
73  std::cerr << e.what();
74  return -1;
75  }
76 }
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
void Register(OptionsItf *opts)
Definition: plda.h:300
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
Definition: parse-options.h:36
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
Definition: kaldi-table.h:287
This class takes unlabeled iVectors from the domain of interest and uses their mean and variance to a...
Definition: plda.h:319
void AddStats(double weight, const Vector< double > &ivector)
Definition: plda.cc:595
void UpdatePlda(const PldaUnsupervisedAdaptorConfig &config, Plda *plda) const
Definition: plda.cc:613
void WriteKaldiObject(const C &c, const std::string &filename, bool binary)
Definition: kaldi-io.h:257