nnet3-discriminative-merge-egs.cc File Reference
Include dependency graph for nnet3-discriminative-merge-egs.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 27 of file nnet3-discriminative-merge-egs.cc.

References DiscriminativeExampleMerger::AcceptExample(), ExampleMergingConfig::ComputeDerived(), SequentialTableReader< Holder >::Done(), DiscriminativeExampleMerger::ExitStatus(), DiscriminativeExampleMerger::Finish(), ParseOptions::GetArg(), SequentialTableReader< Holder >::Next(), ParseOptions::NumArgs(), ParseOptions::PrintUsage(), ParseOptions::Read(), ExampleMergingConfig::Register(), and SequentialTableReader< Holder >::Value().

27  {
28  try {
29  using namespace kaldi;
30  using namespace kaldi::nnet3;
31  typedef kaldi::int32 int32;
32  typedef kaldi::int64 int64;
33 
34  const char *usage =
35  "This copies nnet3 discriminative training examples from input to output, merging them\n"
36  "into composite examples. The --minibatch-size option controls how many egs\n"
37  "are merged into a single output eg.\n"
38  "\n"
39  "Usage: nnet3-discriminative-egs [options] <egs-rspecifier> <egs-wspecifier>\n"
40  "e.g.\n"
41  "nnet3-discriminative-merge-egs --minibatch-size=128 ark:1.degs ark:- | nnet3-discriminative-train ... \n"
42  "See also nnet3-discriminative-copy-egs\n";
43 
44  ExampleMergingConfig merging_config("64"); // 64 is default minibatch size.
45 
46  ParseOptions po(usage);
47  merging_config.Register(&po);
48 
49  po.Read(argc, argv);
50 
51  if (po.NumArgs() != 2) {
52  po.PrintUsage();
53  exit(1);
54  }
55 
56  std::string examples_rspecifier = po.GetArg(1),
57  examples_wspecifier = po.GetArg(2);
58 
59  SequentialNnetDiscriminativeExampleReader example_reader(examples_rspecifier);
60  NnetDiscriminativeExampleWriter example_writer(examples_wspecifier);
61 
62  merging_config.ComputeDerived();
63  DiscriminativeExampleMerger merger(merging_config, &example_writer);
64  for (; !example_reader.Done(); example_reader.Next()) {
65  const NnetDiscriminativeExample &cur_eg = example_reader.Value();
66  merger.AcceptExample(new NnetDiscriminativeExample(cur_eg));
67  }
68  // the merger itself prints the necessary diagnostics.
69  merger.Finish();
70  return merger.ExitStatus();
71  } catch(const std::exception &e) {
72  std::cerr << e.what() << '\n';
73  return -1;
74  }
75 }
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
This class is responsible for arranging examples in groups that have the same strucure (i...
A templated class for writing objects to an archive or script file; see The Table concept...
Definition: kaldi-table.h:368
kaldi::int32 int32
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
NnetDiscriminativeExample is like NnetExample, but specialized for sequence training.