splice-feats.cc File Reference
Include dependency graph for splice-feats.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 25 of file splice-feats.cc.

References SequentialTableReader< Holder >::Done(), ParseOptions::GetArg(), SequentialTableReader< Holder >::Key(), SequentialTableReader< Holder >::Next(), ParseOptions::NumArgs(), ParseOptions::PrintUsage(), ParseOptions::Read(), ParseOptions::Register(), kaldi::SpliceFrames(), SequentialTableReader< Holder >::Value(), and TableWriter< Holder >::Write().

25  {
26  try {
27  using namespace kaldi;
28 
29  const char *usage =
30  "Splice features with left and right context (e.g. prior to LDA)\n"
31  "Usage: splice-feats [options] <feature-rspecifier> <feature-wspecifier>\n"
32  "e.g.: splice-feats scp:feats.scp ark:-\n";
33 
34 
35  ParseOptions po(usage);
36  int32 left_context = 4, right_context = 4;
37 
38 
39  po.Register("left-context", &left_context, "Number of frames of left context");
40  po.Register("right-context", &right_context, "Number of frames of right context");
41 
42  po.Read(argc, argv);
43 
44  if (po.NumArgs() != 2) {
45  po.PrintUsage();
46  exit(1);
47  }
48 
49  std::string rspecifier = po.GetArg(1);
50  std::string wspecifier = po.GetArg(2);
51 
52  BaseFloatMatrixWriter kaldi_writer(wspecifier);
53  SequentialBaseFloatMatrixReader kaldi_reader(rspecifier);
54  for (; !kaldi_reader.Done(); kaldi_reader.Next()) {
55  Matrix<BaseFloat> spliced;
56  SpliceFrames(kaldi_reader.Value(),
57  left_context,
58  right_context,
59  &spliced);
60  kaldi_writer.Write(kaldi_reader.Key(), spliced);
61  }
62  return 0;
63  } catch(const std::exception &e) {
64  std::cerr << e.what();
65  return -1;
66  }
67 }
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
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
void SpliceFrames(const MatrixBase< BaseFloat > &input_features, int32 left_context, int32 right_context, Matrix< BaseFloat > *output_features)