27 int main(
int argc,
char *argv[]) {
29 using namespace kaldi;
33 "Apply I-smoothing to statistics, e.g. for discriminative training\n" 34 "Usage: gmm-ismooth-stats [options] [--smooth-from-model] [<src-stats-in>|<src-model-in>] <dst-stats-in> <stats-out>\n" 35 "e.g.: gmm-ismooth-stats --tau=100 ml.acc num.acc smoothed.acc\n" 36 "or: gmm-ismooth-stats --tau=50 --smooth-from-model 1.mdl num.acc smoothed.acc\n" 37 "or: gmm-ismooth-stats --tau=100 num.acc num.acc smoothed.acc\n";
39 bool binary_write =
false;
40 bool smooth_from_model =
false;
44 po.
Register(
"binary", &binary_write,
"Write output in binary mode");
45 po.
Register(
"smooth-from-model", &smooth_from_model,
"If true, " 46 "expect first argument to be a model file");
47 po.
Register(
"tau", &tau,
"Tau value for I-smoothing");
56 std::string src_stats_or_model_filename = po.
GetArg(1),
57 dst_stats_filename = po.
GetArg(2),
58 stats_out_filename = po.
GetArg(3);
60 double tot_count_before, tot_count_after;
62 if (src_stats_or_model_filename == dst_stats_filename) {
68 Input ki(dst_stats_filename, &binary);
75 Output ko(stats_out_filename, binary_write);
78 }
else if (smooth_from_model) {
85 Input ki(src_stats_or_model_filename, &binary);
91 Input ki(dst_stats_filename, &binary);
98 Output ko(stats_out_filename, binary_write);
99 dst_transition_accs.
Write(ko.
Stream(), binary_write);
108 Input ki(src_stats_or_model_filename, &binary);
109 src_transition_accs.
Read(ki.
Stream(), binary);
114 Input ki(dst_stats_filename, &binary);
115 dst_transition_accs.
Read(ki.
Stream(), binary);
122 Output ko(stats_out_filename, binary_write);
123 dst_transition_accs.
Write(ko.
Stream(), binary_write);
126 KALDI_LOG <<
"Smoothed stats with tau = " << tau <<
", count changed from " 127 << tot_count_before <<
" to " << tot_count_after;
128 }
catch(
const std::exception &e) {
129 std::cerr << e.what() <<
'\n';
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).
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...
void IsmoothStatsAmDiagGmmFromModel(const AmDiagGmm &src_model, double tau, AccumAmDiagGmm *dst_stats)
This version of the I-smoothing function takes a model as input.
void Read(std::istream &is, bool binary)
void IsmoothStatsAmDiagGmm(const AccumAmDiagGmm &src_stats, double tau, AccumAmDiagGmm *dst_stats)
Smooth "dst_stats" with "src_stats".
BaseFloat TotStatsCount() const
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 Read(std::istream &in_stream, bool binary, bool add=false)
int NumArgs() const
Number of positional parameters (c.f. argc-1).
#define KALDI_ASSERT(cond)
void Write(std::ostream &out_stream, bool binary) const
int main(int argc, char *argv[])
void Read(std::istream &in_stream, bool binary)
void Read(std::istream &in, bool binary, bool add=false)
Read function using C++ streams.