27 int main(
int argc, 
char *argv[]) {
    29     using namespace kaldi;
    32         "Copy vectors, or archives of vectors (e.g. transition-accs; speaker vectors)\n"    34         "Usage: copy-vector [options] (<vector-in-rspecifier>|<vector-in-rxfilename>) (<vector-out-wspecifier>|<vector-out-wxfilename>)\n"    35         " e.g.: copy-vector --binary=false 1.mat -\n"    36         "   copy-vector ark:2.trans ark,t:-\n"    37         "see also: dot-weights, append-vector-to-feats\n";
    40     int32 change_dim = -1;
    44     po.
Register(
"binary", &binary, 
"Write in binary mode (only "    45                 "relevant if output is a wxfilename)");
    46     po.
Register(
"change_dim", &change_dim,
    47                 "Use this option to truncate or zero-pad the vectors.");
    49                 "This option can be used to scale the vectors being copied.");
    59     std::string vector_in_fn = po.
GetArg(1),
    60         vector_out_fn = po.
GetArg(2);
    64     bool in_is_rspecifier =
    71     if (in_is_rspecifier != out_is_wspecifier)
    72       KALDI_ERR << 
"Cannot mix archives with regular files (copying vectors)";
    74     if (!in_is_rspecifier) {
    77       Output ko(vector_out_fn, binary);
    80       KALDI_LOG << 
"Copied vector to " << vector_out_fn;
    86       if (change_dim < 0 && scale == 1.0) {
    87         for (; !reader.
Done(); reader.
Next(), num_done++) {
    90         KALDI_LOG << 
"Copied " << num_done << 
" vectors.";
    92         for (; !reader.
Done(); reader.
Next(), num_done++) {
    95           if (scale != 1.0) vec.Scale(scale);
    98         KALDI_LOG << 
"Copied " << num_done << 
" vectors, setting dim to "    99                   << change_dim << 
" scaled by " << scale;
   101       return (num_done != 0 ? 0 : 1);
   103   } 
catch(
const std::exception &e) {
   104     std::cerr << e.what();
 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]. 
 
void Write(std::ostream &Out, bool binary) const
Writes to C++ stream (option to write in binary). 
 
A templated class for writing objects to an archive or script file; see The Table concept...
 
void Resize(MatrixIndexT length, MatrixResizeType resize_type=kSetZero)
Set vector to a specified size (can be zero). 
 
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)
 
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. 
 
WspecifierType ClassifyWspecifier(const std::string &wspecifier, std::string *archive_wxfilename, std::string *script_wxfilename, WspecifierOptions *opts)
 
int NumArgs() const
Number of positional parameters (c.f. argc-1). 
 
A class representing a vector. 
 
int main(int argc, char *argv[])