fgmm-global-copy.cc
Go to the documentation of this file.
1 // fgmmbin/fgmm-global-copy.cc
2 
3 // Copyright 2009-2011 Saarland University; Microsoft Corporation
4 
5 // See ../../COPYING for clarification regarding multiple authors
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
15 // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
16 // MERCHANTABLITY OR NON-INFRINGEMENT.
17 // See the Apache 2 License for the specific language governing permissions and
18 // limitations under the License.
19 
20 #include "base/kaldi-common.h"
21 #include "util/common-utils.h"
22 #include "gmm/full-gmm.h"
23 
24 int main(int argc, char *argv[]) {
25  try {
26  using namespace kaldi;
27  typedef kaldi::int32 int32;
28 
29  const char *usage =
30  "Copy a full-covariance GMM\n"
31  "Usage: fgmm-global-copy [options] <model-in> <model-out>\n"
32  "e.g.: fgmm-global-copy --binary=false 1.model - | less";
33 
34  bool binary_write = true;
35  ParseOptions po(usage);
36  po.Register("binary", &binary_write, "Write output in binary mode");
37 
38  po.Read(argc, argv);
39 
40  if (po.NumArgs() != 2) {
41  po.PrintUsage();
42  exit(1);
43  }
44 
45  std::string model_in_filename = po.GetArg(1),
46  model_out_filename = po.GetArg(2);
47 
48  FullGmm fgmm;
49  {
50  bool binary_read;
51  Input ki(model_in_filename, &binary_read);
52  fgmm.Read(ki.Stream(), binary_read);
53  }
54  WriteKaldiObject(fgmm, model_out_filename, binary_write);
55 
56  KALDI_LOG << "Written model to " << model_out_filename;
57  } catch(const std::exception &e) {
58  std::cerr << e.what() << '\n';
59  return -1;
60  }
61 }
62 
63 
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
int main(int argc, char *argv[])
Definition for Gaussian Mixture Model with full covariances.
Definition: full-gmm.h:40
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
kaldi::int32 int32
void Register(const std::string &name, bool *ptr, const std::string &doc)
std::istream & Stream()
Definition: kaldi-io.cc:826
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
Definition: parse-options.h:36
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 &is, bool binary)
Definition: full-gmm.cc:813
int NumArgs() const
Number of positional parameters (c.f. argc-1).
void WriteKaldiObject(const C &c, const std::string &filename, bool binary)
Definition: kaldi-io.h:257
#define KALDI_LOG
Definition: kaldi-error.h:153