fstdeterminizelog.cc
Go to the documentation of this file.
1 // fstbin/fstdeterminizelog.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/kaldi-io.h"
23 #include "util/parse-options.h"
24 #include "util/text-utils.h"
25 #include "fst/fstlib.h"
26 #include "fstext/fstext-utils.h"
27 #include "fstext/kaldi-fst-io.h"
28 
29 int main(int argc, char *argv[]) {
30  try {
31  using namespace kaldi;
32  using namespace fst;
33  using kaldi::int32;
34 
35  const char *usage =
36  "Determinizes in the log semiring\n"
37  "\n"
38  "Usage: fstdeterminizelog [in.fst [out.fst] ]\n"
39  "\n"
40  "See also fstdeterminizestar\n";
41 
42  ParseOptions po(usage);
43  po.Read(argc, argv);
44 
45  if (po.NumArgs() > 2) {
46  po.PrintUsage();
47  exit(1);
48  }
49 
50  std::string fst_in_filename = po.GetOptArg(1),
51  fst_out_filename = po.GetOptArg(2);
52 
53  VectorFst<StdArc> *fst = ReadFstKaldi(fst_in_filename);
54 
55  DeterminizeInLog(fst);
56 
57  WriteFstKaldi(*fst, fst_out_filename);
58  delete fst;
59  return 0;
60  } catch(const std::exception &e) {
61  std::cerr << e.what();
62  return -1;
63  }
64 }
65 
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
int main(int argc, char *argv[])
For an extended explanation of the framework of which grammar-fsts are a part, please see Support for...
Definition: graph.dox:21
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
void DeterminizeInLog(VectorFst< StdArc > *fst)
kaldi::int32 int32
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 NumArgs() const
Number of positional parameters (c.f. argc-1).
void WriteFstKaldi(std::ostream &os, bool binary, const VectorFst< Arc > &t)
void ReadFstKaldi(std::istream &is, bool binary, VectorFst< Arc > *fst)
std::string GetOptArg(int param) const