52 using namespace kaldi;
56 "Append posteriors to features\n" 58 "Usage: append-post-to-feats [options] <in-rspecifier1> <in-rspecifier2> <out-wspecifier>\n" 59 " or: append-post-to-feats [options] <in-rxfilename1> <in-rxfilename2> <out-wxfilename>\n" 60 "e.g.: append-post-to-feats --post-dim=50 ark:input.ark scp:post.scp ark:output.ark\n" 61 "See also: paste-feats, concat-feats, append-vector-to-feats\n";
66 po.Register(
"binary", &binary,
"If true, output files in binary " 67 "(only relevant for single-file operation, i.e. no tables)");
70 po.Register(
"post-dim", &post_dim,
"Dimensionality of the posteriors.");
74 if (po.NumArgs() != 3) {
80 KALDI_ERR <<
"You have to set the dimensionality of posteriors " 81 "with '--post-dim=D'";
88 string feat_rspecifier = po.GetArg(1);
91 string post_rspecifier = po.GetArg(2);
94 string wspecifier = po.GetArg(3);
97 int32 num_done = 0, num_err = 0;
99 for (; !feat_reader.Done(); feat_reader.Next()) {
100 string utt = feat_reader.Key();
101 KALDI_VLOG(2) <<
"Processing utterance " << utt;
105 if (!post_reader.HasKey(utt)) {
106 KALDI_WARN <<
"Could not read posteriors for utterance " << utt;
110 const Posterior &post(post_reader.Value(utt));
114 feat_writer.Write(utt, output);
117 KALDI_LOG <<
"Done " << num_done <<
" utts, errors on " 120 return (num_done == 0 ? -1 : 0);
128 Input ki(po.GetArg(2), &binary_in);
134 std::string output_wxfilename = po.GetArg(3);
136 KALDI_LOG <<
"Wrote appended features to " << output_wxfilename;
139 }
catch(
const std::exception &e) {
140 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void AppendPostToFeats(const Matrix< BaseFloat > &in, const Posterior &post, const int32 post_dim, Matrix< BaseFloat > *out)
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)
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
Allows random access to a collection of objects in an archive or script file; see The Table concept...
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.