26 int main(
int argc,
char *argv[]) {
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.");
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;
81 feat_writer.
Write(utt, output);
84 KALDI_LOG <<
"Done " << num_done <<
" utts, errors on " 87 return (num_done == 0 ? -1 : 0);
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...
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
A templated class for writing objects to an archive or script file; see The Table concept...
void Write(const std::string &key, const T &value) const
void Register(const std::string &name, bool *ptr, const std::string &doc)
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...
int Read(int argc, const char *const *argv)
Parses the command line options and fills the ParseOptions-registered variables.
std::string GetArg(int param) const
Returns one of the positional parameters; 1-based indexing for argc/argv compatibility.
int NumArgs() const
Number of positional parameters (c.f. argc-1).
void WriteKaldiObject(const C &c, const std::string &filename, bool binary)
int main(int argc, char *argv[])
void ReadPosterior(std::istream &is, bool binary, Posterior *post)
stand-alone function for reading a Posterior.