56 using namespace kaldi;
59 "Read in transform from dimension d -> d (affine or linear), and output a transform\n" 60 "from dimension e -> e (with e >= d, and e controlled by option --new-dimension).\n" 61 "This new transform will leave the extra dimension unaffected, and transform the old\n" 62 "dimensions in the same way.\n" 63 "Usage: extend-transform-dim [options] (transform-A-rspecifier|transform-A-rxfilename) (transform-out-wspecifier|transform-out-wxfilename)\n" 64 "E.g.: extend-transform-dim --new-dimension=117 in.mat big.mat\n";
67 int32 new_dimension = -1;
70 po.Register(
"binary", &binary,
"Write in binary mode (only relevant if output is a wxfilename)");
71 po.Register(
"new-dimension", &new_dimension,
72 "Larger dimension we are changing matrix to");
76 if (po.NumArgs() != 2) {
81 std::string transform_in_fn = po.GetArg(1);
82 std::string transform_out_fn = po.GetArg(2);
85 bool in_is_rspecifier =
92 if (in_is_rspecifier != out_is_wspecifier)
93 KALDI_ERR <<
"Either none or both of the (input, output) must be a Table.";
95 if (in_is_rspecifier) {
99 for (; !reader.Done(); reader.Next()) {
100 std::string key = reader.Key();
103 writer.Write(key, mat);
106 KALDI_LOG <<
"Increased transform dim to " << new_dimension
107 <<
" for " << num_done <<
" matrices.";
108 return (num_done != 0 ? 0 : 1);
115 KALDI_LOG <<
"Increased transform dim from " << old_dim <<
" to " 116 << mat.
NumRows() <<
" and wrote to " << transform_out_fn;
119 }
catch(
const std::exception &e) {
120 std::cerr << e.what();
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)
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...
WspecifierType ClassifyWspecifier(const std::string &wspecifier, std::string *archive_wxfilename, std::string *script_wxfilename, WspecifierOptions *opts)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
void WriteKaldiObject(const C &c, const std::string &filename, bool binary)
void IncreaseTransformDimension(int32 new_dimension, Matrix< BaseFloat > *mat)