Blame view

src/lat/phone-align-lattice.h 2.76 KB
8dcb6dfcb   Yannick Estève   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
  // lat/phone-align-lattice.h
  
  // Copyright 2009-2012  Microsoft Corporation  Johns Hopkins University (Author: Daniel Povey)
  
  // See ../../COPYING for clarification regarding multiple authors
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //  http://www.apache.org/licenses/LICENSE-2.0
  //
  // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  // MERCHANTABLITY OR NON-INFRINGEMENT.
  // See the Apache 2 License for the specific language governing permissions and
  // limitations under the License.
  
  #ifndef KALDI_LAT_PHONE_ALIGN_LATTICE_H_
  #define KALDI_LAT_PHONE_ALIGN_LATTICE_H_
  #include <fst/fstlib.h>
  #include <fst/fst-decl.h>
  
  #include "base/kaldi-common.h"
  #include "util/common-utils.h"
  #include "fstext/fstext-lib.h"
  #include "hmm/transition-model.h"
  #include "lat/kaldi-lattice.h"
  
  namespace kaldi {
  
  
  struct PhoneAlignLatticeOptions {
    bool reorder;
    bool remove_epsilon;
    bool replace_output_symbols;
    PhoneAlignLatticeOptions(): reorder(true),
                                remove_epsilon(true),
                                replace_output_symbols(false) { }
    void Register(OptionsItf *opts) {
      opts->Register("reorder", &reorder, "True if lattice was created from HCLG with "
                     "--reorder=true option.");
      opts->Register("remove-epsilon", &remove_epsilon, "If true, removes epsilons from "
                     "the phone lattice; if replace-output-symbols==false, this will "
                     "mean that an arc can have multiple phones on it.");
      opts->Register("replace-output-symbols", &replace_output_symbols, "If true, "
                     "the output symbols (typically words) will be replaced with "
                     "phones.");
    }
  };
  
  /// Outputs a lattice in which the arcs correspond exactly to sequences of
  /// phones, so the boundaries between the arcs correspond to the boundaries
  /// between phones If remove-epsilon == false and replace-output-symbols ==
  /// false, but an arc may have >1 phone on it, but the boundaries will still
  /// correspond with the boundaries between phones.  Note: it's possible
  /// to have arcs with words on them but no transition-ids at all.  Returns true if
  /// everything was OK, false if some kind of error was detected (e.g. the
  /// "reorder" option was incorrectly specified.)
  bool PhoneAlignLattice(const CompactLattice &lat,
                         const TransitionModel &tmodel,
                         const PhoneAlignLatticeOptions &opts,
                         CompactLattice *lat_out);
  
  
  } // end namespace kaldi
  #endif