28 using namespace kaldi;
32 "Convert posteriors to features\n" 34 "Usage: post-to-feats [options] <in-rspecifier> <out-wspecifier>\n" 35 " or: post-to-feats [options] <in-rxfilename> <out-wxfilename>\n" 36 "e.g.: post-to-feats --post-dim=50 ark:post.ark ark:feat.ark\n" 37 "See also: post-to-weights feat-to-post, append-vector-to-feats, append-post-to-feats\n";
42 po.Register(
"binary", &binary,
"If true, output files in binary " 43 "(only relevant for single-file operation, i.e. no tables)");
46 po.Register(
"post-dim", &post_dim,
"Dimensionality of the posteriors.");
50 if (po.NumArgs() != 2) {
56 KALDI_ERR <<
"You have to set the dimensionality of posteriors " 57 "with '--post-dim=D'";
64 string post_rspecifier = po.GetArg(1);
67 string wspecifier = po.GetArg(2);
70 int32 num_done = 0, num_err = 0;
72 for (; !post_reader.Done(); post_reader.Next()) {
73 string utt = post_reader.Key();
74 KALDI_VLOG(2) <<
"Processing utterance " << utt;
76 const Posterior &post(post_reader.Value());
81 feat_writer.Write(utt, output);
84 KALDI_LOG <<
"Done " << num_done <<
" utts, errors on " 87 return (num_done == 0 ? -1 : 0);
92 Input ki(po.GetArg(1), &binary_in);
98 std::string output_wxfilename = po.GetArg(3);
100 KALDI_LOG <<
"Wrote posteriors as feature-matrix to " << output_wxfilename;
103 }
catch(
const std::exception &e) {
104 std::cerr << e.what();
void PosteriorToMatrix(const Posterior &post, const int32 post_dim, Matrix< Real > *mat)
This converts a Posterior to a Matrix.
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
A templated class for writing objects to an archive or script file; see The Table concept...
RspecifierType ClassifyRspecifier(const std::string &rspecifier, std::string *rxfilename, RspecifierOptions *opts)
std::vector< std::vector< std::pair< int32, BaseFloat > > > Posterior
Posterior is a typedef for storing acoustic-state (actually, transition-id) posteriors over an uttera...
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
void WriteKaldiObject(const C &c, const std::string &filename, bool binary)
void ReadPosterior(std::istream &is, bool binary, Posterior *post)
stand-alone function for reading a Posterior.