copy-tree.cc
Go to the documentation of this file.
1 // bin/copy-tree.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 
21 #include "base/kaldi-common.h"
22 #include "util/common-utils.h"
23 #include "hmm/hmm-topology.h"
24 #include "tree/context-dep.h"
26 #include "util/text-utils.h"
27 
28 int main(int argc, char *argv[]) {
29  using namespace kaldi;
30  try {
31  using namespace kaldi;
32  typedef kaldi::int32 int32;
33 
34  const char *usage =
35  "Copy decision tree (possibly changing binary/text format)\n"
36  "Usage: copy-tree [--binary=false] <tree-in> <tree-out>\n";
37 
38  bool binary = true;
39  ParseOptions po(usage);
40  po.Register("binary", &binary, "Write output in binary mode");
41 
42  po.Read(argc, argv);
43 
44  if (po.NumArgs() != 2) {
45  po.PrintUsage();
46  exit(1);
47  }
48 
49  std::string tree_in_filename = po.GetArg(1),
50  tree_out_filename = po.GetArg(2);
51 
52  ContextDependency ctx_dep;
53  ReadKaldiObject(tree_in_filename, &ctx_dep);
54  WriteKaldiObject(ctx_dep, tree_out_filename, binary);
55  KALDI_LOG << "Copied tree";
56  } catch(const std::exception &e) {
57  std::cerr << e.what();
58  return -1;
59  }
60 }
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
int main(int argc, char *argv[])
Definition: copy-tree.cc:28
kaldi::int32 int32
void Register(const std::string &name, bool *ptr, const std::string &doc)
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
Definition: kaldi-io.cc:832
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.
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