26 int main(
int argc,
char *argv[]) {
28 using namespace kaldi;
31 "This program applies a linear or affine transform to individual vectors, e.g.\n" 32 "iVectors. It is transform-feats, except it works on vectors rather than matrices,\n" 33 "and expects a single transform matrix rather than possibly a table of matrices\n" 35 "Usage: transform-vec [options] <transform-rxfilename> <feats-rspecifier> <feats-wspecifier>\n" 36 "See also: transform-feats, est-pca\n";
47 std::string transform_rxfilename = po.
GetArg(1);
48 std::string vec_rspecifier = po.
GetArg(2);
49 std::string vec_wspecifier = po.
GetArg(3);
59 for (; !vec_reader.
Done(); vec_reader.
Next()) {
60 std::string key = vec_reader.
Key();
64 transform_cols = transform.
NumCols(),
69 if (transform_cols == vec_dim) {
72 if (transform_cols != vec_dim + 1) {
73 KALDI_ERR <<
"Dimension mismatch: input vector has dimension " 74 << vec.Dim() <<
" and transform has " << transform_cols
81 vec_writer.
Write(key, vec_out);
85 KALDI_LOG <<
"Applied transform to " << num_done <<
" vectors.";
87 return (num_done != 0 ? 0 : 1);
88 }
catch(
const std::exception &e) {
89 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 ReadKaldiObject(const std::string &filename, Matrix< float > *m)
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.
void AddMatVec(const Real alpha, const MatrixBase< Real > &M, const MatrixTransposeType trans, const VectorBase< Real > &v, const Real beta)
Add matrix times vector : this <– beta*this + alpha*M*v.
int NumArgs() const
Number of positional parameters (c.f. argc-1).
void CopyColFromMat(const MatrixBase< OtherReal > &M, MatrixIndexT col)
Extracts a column of the matrix M.
A class representing a vector.
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
SubMatrix< Real > Range(const MatrixIndexT row_offset, const MatrixIndexT num_rows, const MatrixIndexT col_offset, const MatrixIndexT num_cols) const
Return a sub-part of matrix.