All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
duplicate-matrix.cc File Reference
Include dependency graph for duplicate-matrix.cc:

Go to the source code of this file.

Functions

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

Function Documentation

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

Definition at line 26 of file duplicate-matrix.cc.

References SequentialTableReader< Holder >::Done(), ParseOptions::GetArg(), rnnlm::i, KALDI_ERR, KALDI_LOG, SequentialTableReader< Holder >::Key(), SequentialTableReader< Holder >::Next(), ParseOptions::NumArgs(), ParseOptions::PrintUsage(), ParseOptions::Read(), and SequentialTableReader< Holder >::Value().

26  {
27  try {
28  using namespace kaldi;
29 
30  const char *usage =
31  "Copy tables of BaseFloat matrices, from one input to possibly multiple outputs,\n"
32  "with each element of the input written too all outputs.\n"
33  "\n"
34  "Usage: duplicate-matrix [options] <matrix-rspecifier> <matrix-wspecifier1> [<matrix-wspecifier2> ...]\n";
35 
36  ParseOptions po(usage);
37 
38  po.Read(argc, argv);
39 
40  if (po.NumArgs() < 2) {
41  po.PrintUsage();
42  exit(1);
43  }
44 
45 
46  std::string matrix_rspecifier = po.GetArg(1);
47 
48  SequentialBaseFloatMatrixReader matrix_reader(matrix_rspecifier);
49 
50  std::vector<BaseFloatMatrixWriter> writers(po.NumArgs() - 1);
51  for (size_t i = 0; i < writers.size(); i++)
52  if (!writers[i].Open(po.GetArg(i + 1)))
53  KALDI_ERR << "Error opening table for writing with wspecifier \""
54  << po.GetArg(i + 1) << '"';
55 
56  int32 num_done = 0;
57  for (; !matrix_reader.Done(); matrix_reader.Next(), num_done++)
58  for (size_t i = 0; i < writers.size(); i++)
59  writers[i].Write(matrix_reader.Key(), matrix_reader.Value());
60 
61  KALDI_LOG << "Copied " << num_done << " matrices to "
62  << writers.size() << " outputs.";
63  } catch(const std::exception &e) {
64  std::cerr << e.what();
65  return -1;
66  }
67 }
Relabels neural network egs with the read pdf-id alignments.
Definition: chain.dox:20
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
#define KALDI_ERR
Definition: kaldi-error.h:127
#define KALDI_LOG
Definition: kaldi-error.h:133