26 int main(
int argc,
char *argv[]) {
28 using namespace kaldi;
31 "Scale vectors, or archives of vectors (useful for speaker vectors and " 32 "per-frame weights)\n" 33 "Usage: vector-scale [options] <vector-in-rspecifier> <vector-out-wspecifier>\n" 34 " or: vector-scale [options] <vector-in-rxfilename> <vector-out-wxfilename>\n" 35 " e.g.: vector-scale --scale=-1.0 1.vec -\n" 36 " vector-scale --scale=-2.0 ark:vec.ark ark,t:-\n" 37 "See also: copy-vector, vector-sum\n";
43 po.
Register(
"binary", &binary,
"If true, write output as binary " 44 "not relevant for archives");
45 po.
Register(
"scale", &scale,
"Scaling factor for vectors");
53 std::string vector_in_fn = po.
GetArg(1);
54 std::string vector_out_fn = po.
GetArg(2);
58 KALDI_ERR <<
"Cannot mix archives and regular files";
62 for (; !vec_reader.
Done(); vec_reader.
Next()) {
65 vec_writer.
Write(vec_reader.
Key(), vec);
69 KALDI_ERR <<
"Cannot mix archives and regular files";
72 Input ki(vector_in_fn, &binary_in);
76 Output ko(vector_out_fn, binary);
81 }
catch(
const std::exception &e) {
82 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 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)
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 Scale(Real alpha)
Multiplies all elements by this constant.
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[])
void Read(std::istream &in, bool binary, bool add=false)
Read function using C++ streams.