ivector-extractor-copy.cc
Go to the documentation of this file.
1 // ivectorbin/ivector-extractor-copy.cc
2 
3 // Copyright 2019 Zili Huang
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"
24 
25 
26 int main(int argc, char *argv[]) {
27  try {
28  using namespace kaldi;
29  using kaldi::int32;
30 
31  const char *usage =
32  "Copy the i-vector extractor to a text file\n"
33  "Usage: ivector-extractor-copy [options] <ivector-extractor-in> <ivector-extractor-out>\n"
34  "e.g.:\n"
35  " ivector-extractor-copy --binary=false 0.ie 0_txt.ie\n";
36 
37  bool binary = true;
38  IvectorExtractorOptions ivector_opts;
39  ParseOptions po(usage);
40  po.Register("binary", &binary, "Write output in binary mode");
41  ivector_opts.Register(&po);
42 
43  po.Read(argc, argv);
44 
45  if (po.NumArgs() != 2) {
46  po.PrintUsage();
47  exit(1);
48  }
49 
50  std::string ivector_extractor_rxfilename = po.GetArg(1),
51  ivector_extractor_wxfilename = po.GetArg(2);
52 
53  IvectorExtractor extractor;
54  ReadKaldiObject(ivector_extractor_rxfilename, &extractor);
55 
56  WriteKaldiObject(extractor, ivector_extractor_wxfilename, binary);
57 
58  return 0;
59  } catch(const std::exception &e) {
60  std::cerr << e.what();
61  return -1;
62  }
63 }
64 
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
int main(int argc, char *argv[])
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)
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 Register(OptionsItf *opts)
void WriteKaldiObject(const C &c, const std::string &filename, bool binary)
Definition: kaldi-io.h:257