42 int main(
int argc,
char *argv[]) {
44 using namespace kaldi;
48 "Append a vector to each row of input feature files\n" 50 "Usage: append-vector-to-feats <in-rspecifier1> <in-rspecifier2> <out-wspecifier>\n" 51 " or: append-vector-to-feats <in-rxfilename1> <in-rxfilename2> <out-wxfilename>\n" 52 "See also: paste-feats, concat-feats\n";
57 po.
Register(
"binary", &binary,
"If true, output files in binary " 58 "(only relevant for single-file operation, i.e. no tables)");
72 string feat_rspecifier = po.
GetArg(1);
75 string vec_rspecifier = po.
GetArg(2);
78 string wspecifier = po.
GetArg(3);
81 int32 num_done = 0, num_err = 0;
83 for (; !feat_reader.
Done(); feat_reader.
Next()) {
84 string utt = feat_reader.
Key();
85 KALDI_VLOG(2) <<
"Processing utterance " << utt;
89 if (!vec_reader.
HasKey(utt)) {
90 KALDI_WARN <<
"Could not read vector for utterance " << utt;
98 feat_writer.
Write(utt, output);
101 KALDI_LOG <<
"Done " << num_done <<
" utts, errors on " 104 return (num_done == 0 ? -1 : 0);
113 std::string output_wxfilename = po.
GetArg(3);
115 KALDI_LOG <<
"Wrote appended features to " << output_wxfilename;
118 }
catch(
const std::exception &e) {
119 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
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)
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...
SubMatrix< Real > ColRange(const MatrixIndexT col_offset, const MatrixIndexT num_cols) const
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
const T & Value(const std::string &key)
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.
MatrixIndexT Dim() const
Returns the dimension of the vector.
bool HasKey(const std::string &key)
int NumArgs() const
Number of positional parameters (c.f. argc-1).
A class representing a vector.
#define KALDI_ASSERT(cond)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
void WriteKaldiObject(const C &c, const std::string &filename, bool binary)
void AppendVectorToFeats(const Matrix< BaseFloat > &in, const Vector< BaseFloat > &vec, Matrix< BaseFloat > *out)
void Resize(const MatrixIndexT r, const MatrixIndexT c, MatrixResizeType resize_type=kSetZero, MatrixStrideType stride_type=kDefaultStride)
Sets matrix to a specified size (zero is OK as long as both r and c are zero).
int main(int argc, char *argv[])