26 int main(
int argc,
char *argv[]) {
28 using namespace kaldi;
31 "Copy matrices of online-estimated iVectors, but randomize them;\n" 32 "this is intended primarily for training the online nnet2 setup\n" 33 "with iVectors. For each input matrix, each row with index t is,\n" 34 "with probability given by the option --randomize-prob, replaced\n" 35 "with the contents an input row chosen randomly from the interval [t, T]\n" 36 "where T is the index of the last row of the matrix.\n" 38 "Usage: ivector-randomize [options] <ivector-rspecifier> <ivector-wspecifier>\n" 39 " e.g.: ivector-randomize ark:- ark:-\n" 40 "See also: ivector-extract-online, ivector-extract-online2, subsample-feats\n";
47 po.
Register(
"srand", &srand_seed,
"Seed for random number generator");
48 po.
Register(
"randomize-prob", &randomize_prob,
"For each row, replace it with a " 49 "random row with this probability.");
59 std::string ivector_rspecifier = po.
GetArg(1),
60 ivector_wspecifier = po.
GetArg(2);
66 for (; !reader.
Done(); reader.
Next(), num_done++) {
67 std::string utt = reader.
Key();
71 for (
int32 t = 0; t < T; t++) {
75 ivectors_out.
Row(t).CopyFromVec(ivectors_in.
Row(t_src));
77 writer.
Write(utt, ivectors_out);
80 KALDI_LOG <<
"Randomized " << num_done <<
" iVectors.";
81 return (num_done != 0 ? 0 : 1);
82 }
catch(
const std::exception &e) {
83 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].
bool WithProb(BaseFloat prob, struct RandomState *state)
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)
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
const SubVector< Real > Row(MatrixIndexT i) const
Return specific row of matrix [const].
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.
int NumArgs() const
Number of positional parameters (c.f. argc-1).
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
int main(int argc, char *argv[])
int32 RandInt(int32 min_val, int32 max_val, struct RandomState *state)