post-to-pdf-post.cc File Reference
#include "base/kaldi-common.h"
#include "util/common-utils.h"
#include "gmm/am-diag-gmm.h"
#include "hmm/transition-model.h"
#include "hmm/hmm-utils.h"
#include "hmm/posterior.h"
Include dependency graph for post-to-pdf-post.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 28 of file post-to-pdf-post.cc.

References kaldi::ConvertPosteriorToPdfs(), SequentialTableReader< Holder >::Done(), ParseOptions::GetArg(), KALDI_LOG, SequentialTableReader< Holder >::Key(), SequentialTableReader< Holder >::Next(), ParseOptions::NumArgs(), ParseOptions::PrintUsage(), ParseOptions::Read(), TransitionModel::Read(), Input::Stream(), SequentialTableReader< Holder >::Value(), and TableWriter< Holder >::Write().

28  {
29  using namespace kaldi;
30  typedef kaldi::int32 int32;
31  try {
32  const char *usage =
33  "This program turns per-frame posteriors, which have transition-ids as\n"
34  "the integers, into pdf-level posteriors\n"
35  "See also: post-to-phone-post, post-to-weights, get-post-on-ali\n"
36  "\n"
37  "Usage: post-to-pdf-post [options] <model-file> <posteriors-rspecifier> <posteriors-wspecifier>\n"
38  "e.g.: post-to-pdf-post 1.mdl ark:- ark:-\n";
39 
40  ParseOptions po(usage);
41 
42  po.Read(argc, argv);
43 
44  if (po.NumArgs() != 3) {
45  po.PrintUsage();
46  exit(1);
47  }
48 
49  std::string model_rxfilename = po.GetArg(1),
50  posteriors_rspecifier = po.GetArg(2),
51  posteriors_wspecifier = po.GetArg(3);
52 
53  TransitionModel trans_model;
54  {
55  bool binary_in;
56  Input ki(model_rxfilename, &binary_in);
57  trans_model.Read(ki.Stream(), binary_in);
58  }
59 
60  int32 num_done = 0;
61  SequentialPosteriorReader posterior_reader(posteriors_rspecifier);
62  PosteriorWriter posterior_writer(posteriors_wspecifier);
63 
64  for (; !posterior_reader.Done(); posterior_reader.Next()) {
65  const kaldi::Posterior &posterior = posterior_reader.Value();
66  kaldi::Posterior pdf_posterior;
67  ConvertPosteriorToPdfs(trans_model, posterior, &pdf_posterior);
68  posterior_writer.Write(posterior_reader.Key(), pdf_posterior);
69  num_done++;
70  }
71  KALDI_LOG << "Done converting posteriors to pdf-level posteriors for "
72  << num_done << " utterances.";
73 
74  } catch(const std::exception &e) {
75  std::cerr << e.what();
76  return -1;
77  }
78 }
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
std::vector< std::vector< std::pair< int32, BaseFloat > > > Posterior
Posterior is a typedef for storing acoustic-state (actually, transition-id) posteriors over an uttera...
Definition: posterior.h:42
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
Definition: parse-options.h:36
void Read(std::istream &is, bool binary)
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
Definition: kaldi-table.h:287
void ConvertPosteriorToPdfs(const TransitionModel &tmodel, const Posterior &post_in, Posterior *post_out)
Converts a posterior over transition-ids to be a posterior over pdf-ids.
Definition: posterior.cc:322
#define KALDI_LOG
Definition: kaldi-error.h:153