gmm-global-to-fgmm.cc
Go to the documentation of this file.
1 // gmmbin/gmm-global-to-fgmm.cc
2 
3 // Copyright 2009-2011 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 "util/common-utils.h"
21 #include "gmm/full-gmm.h"
22 #include "gmm/mle-full-gmm.h"
23 
24 
25 int main(int argc, char *argv[]) {
26  try {
27  using namespace kaldi;
28  typedef kaldi::int32 int32;
29 
30  const char *usage =
31  "Convert single diagonal-covariance GMM to single full-covariance GMM.\n"
32  "Usage: gmm-global-to-fgmm [options] 1.gmm 1.fgmm\n";
33 
34  bool binary = true;
35  ParseOptions po(usage);
36  po.Register("binary", &binary, "Write output in binary mode");
37  po.Read(argc, argv);
38 
39  if (po.NumArgs() != 2) {
40  po.PrintUsage();
41  exit(1);
42  }
43 
44  std::string gmm_rxfilename = po.GetArg(1),
45  fgmm_wxfilename = po.GetArg(2);
46 
47  DiagGmm gmm;
48 
49  {
50  bool binary_read;
51  Input ki(gmm_rxfilename, &binary_read);
52  gmm.Read(ki.Stream(), binary_read);
53  }
54 
55  FullGmm fgmm;
56  fgmm.CopyFromDiagGmm(gmm);
57  WriteKaldiObject(fgmm, fgmm_wxfilename, binary);
58  KALDI_LOG << "Written full GMM to " << fgmm_wxfilename;
59  } catch(const std::exception &e) {
60  std::cerr << e.what() << '\n';
61  return -1;
62  }
63 }
64 
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
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.
int main(int argc, char *argv[])
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).
void Read(std::istream &in, bool binary)
Definition: diag-gmm.cc:728
void CopyFromDiagGmm(const DiagGmm &diaggmm)
Copies from given DiagGmm.
Definition: full-gmm.cc:77
Definition for Gaussian Mixture Model with diagonal covariances.
Definition: diag-gmm.h:42
void WriteKaldiObject(const C &c, const std::string &filename, bool binary)
Definition: kaldi-io.h:257
#define KALDI_LOG
Definition: kaldi-error.h:153