26 int main(
int argc,
char *argv[]) {
31 "Sum multiple accumulated stats files for SGMM training.\n" 32 "Usage: sgmm2-sum-accs [options] stats-out stats-in1 stats-in2 ...\n";
35 bool parallel =
false;
37 po.
Register(
"binary", &binary,
"Write output in binary mode");
38 po.
Register(
"parallel", ¶llel,
"If true, the program makes sure to open all " 39 "filehandles before reading for any (useful when summing accs from " 48 std::string stats_out_filename = po.
GetArg(1);
53 std::vector<kaldi::Input*> inputs(po.
NumArgs() - 1);
55 std::string stats_in_filename = po.
GetArg(
i + 2);
60 for (
size_t i = 0;
i < po.
NumArgs() - 1;
i++) {
63 transition_accs.
Read(inputs[
i]->Stream(), b,
true );
64 sgmm_accs.
Read(inputs[
i]->Stream(), b,
true );
71 for (
int i = 2, max = po.
NumArgs();
i <= max;
i++) {
72 std::string stats_in_filename = po.
GetArg(
i);
75 transition_accs.
Read(ki.
Stream(), binary_read,
true );
76 sgmm_accs.
Read(ki.
Stream(), binary_read,
true );
87 KALDI_LOG <<
"Written stats to " << stats_out_filename;
88 }
catch(
const std::exception &e) {
89 std::cerr << e.what() <<
'\n';
bool InitKaldiInputStream(std::istream &is, bool *binary)
Initialize an opened stream for reading by detecting the binary header and.
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
void Read(std::istream &in_stream, bool binary, bool add)
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...
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 Write(std::ostream &out_stream, bool binary) const
int NumArgs() const
Number of positional parameters (c.f. argc-1).
int main(int argc, char *argv[])
Class for the accumulators associated with the phonetic-subspace model parameters.
void Read(std::istream &in, bool binary, bool add=false)
Read function using C++ streams.