All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
reverse-feats.cc File Reference
Include dependency graph for reverse-feats.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 reverse-feats.cc.

References SequentialTableReader< Holder >::Done(), ParseOptions::GetArg(), KALDI_WARN, SequentialTableReader< Holder >::Key(), SequentialTableReader< Holder >::Next(), ParseOptions::NumArgs(), MatrixBase< Real >::NumRows(), ParseOptions::PrintUsage(), ParseOptions::Read(), kaldi::ReverseFrames(), SequentialTableReader< Holder >::Value(), and TableWriter< Holder >::Write().

26  {
27  try {
28  using namespace kaldi;
29 
30  const char *usage =
31  "Reverse features in time (for backwards decoding)\n"
32  "Usage: reverse-feats [options] in-rspecifier out-wspecifier\n";
33  ParseOptions po(usage);
34 
35  po.Read(argc, argv);
36  if (po.NumArgs() != 2) {
37  po.PrintUsage();
38  exit(1);
39  }
40 
41  std::string rspecifier = po.GetArg(1);
42  std::string wspecifier = po.GetArg(2);
43 
44  BaseFloatMatrixWriter feat_writer(wspecifier);
45  SequentialBaseFloatMatrixReader feat_reader(rspecifier);
46  for (; !feat_reader.Done(); feat_reader.Next()) {
47  std::string key = feat_reader.Key();
48  const Matrix<BaseFloat> &feats = feat_reader.Value();
49 
50  if (feats.NumRows() == 0) {
51  KALDI_WARN << "Empty feature matrix for key " << key;
52  continue;
53  }
54 
55  Matrix<BaseFloat> new_feats;
56  ReverseFrames(feats, &new_feats);
57  feat_writer.Write(key, new_feats);
58  }
59  return 0;
60  } catch(const std::exception &e) {
61  std::cerr << e.what();
62  return -1;
63  }
64 }
Relabels neural network egs with the read pdf-id alignments.
Definition: chain.dox:20
A templated class for writing objects to an archive or script file; see The Table concept...
Definition: kaldi-table.h:366
void ReverseFrames(const MatrixBase< BaseFloat > &input_features, Matrix< BaseFloat > *output_features)
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_WARN
Definition: kaldi-error.h:130
MatrixIndexT NumRows() const
Returns number of rows (or zero for emtpy matrix).
Definition: kaldi-matrix.h:58