nnet3-merge-egs.cc File Reference
Include dependency graph for nnet3-merge-egs.cc:

Go to the source code of this file.

Namespaces

 kaldi
 This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for mispronunciations detection tasks, the reference:
 
 kaldi::nnet3
 

Functions

int32 NumOutputIndexes (const NnetExample &eg)
 
int main (int argc, char *argv[])
 

Function Documentation

◆ main()

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

Definition at line 42 of file nnet3-merge-egs.cc.

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

42  {
43  try {
44  using namespace kaldi;
45  using namespace kaldi::nnet3;
46  typedef kaldi::int32 int32;
47  typedef kaldi::int64 int64;
48 
49  const char *usage =
50  "This copies nnet training examples from input to output, but while doing so it\n"
51  "merges many NnetExample objects into one, forming a minibatch consisting of a\n"
52  "single NnetExample.\n"
53  "\n"
54  "Usage: nnet3-merge-egs [options] <egs-rspecifier> <egs-wspecifier>\n"
55  "e.g.\n"
56  "nnet3-merge-egs --minibatch-size=512 ark:1.egs ark:- | nnet3-train-simple ... \n"
57  "See also nnet3-copy-egs\n";
58 
59  ParseOptions po(usage);
60 
61  ExampleMergingConfig merging_config;
62  merging_config.Register(&po);
63 
64  po.Read(argc, argv);
65 
66  if (po.NumArgs() != 2) {
67  po.PrintUsage();
68  exit(1);
69  }
70 
71  std::string examples_rspecifier = po.GetArg(1),
72  examples_wspecifier = po.GetArg(2);
73 
74  merging_config.ComputeDerived();
75 
76  SequentialNnetExampleReader example_reader(examples_rspecifier);
77  NnetExampleWriter example_writer(examples_wspecifier);
78 
79  ExampleMerger merger(merging_config, &example_writer);
80 
81  for (; !example_reader.Done(); example_reader.Next()) {
82  const NnetExample &cur_eg = example_reader.Value();
83  merger.AcceptExample(new NnetExample(cur_eg));
84  }
85  // the merger itself prints the necessary diagnostics.
86  merger.Finish();
87  return merger.ExitStatus();
88  } catch(const std::exception &e) {
89  std::cerr << e.what() << '\n';
90  return -1;
91  }
92 }
NnetExample is the input data and corresponding label (or labels) for one or more frames of input...
Definition: nnet-example.h:111
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
A templated class for writing objects to an archive or script file; see The Table concept...
Definition: kaldi-table.h:368
kaldi::int32 int32
This class is responsible for arranging examples in groups that have the same strucure (i...
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