diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f26596ce86..80bdbfd0712 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,11 +28,7 @@ if(BuildForFedora) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) - - #find_package(PkgConfig REQUIRED) - - #pkg_check_modules(FST REQUIRED fst) - + set(CMAKE_POSITION_INDEPENDENT_CODE ON) else() include(third_party/get_third_party) diff --git a/README.md b/README.md index 49baedaf85e..72218a23a2d 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ then build the package as follows: ``` cmake -S ./ -Bbuild/Release -DFETCHCONTENT_FULLY_DISCONNECTED=ON -DBuildForFedora=ON -cmake --build /home/gerhard/workspace/kaldi/build/Release +cmake --build ./build/Release ``` diff --git a/src/chain/chain-den-graph.cc b/src/chain/chain-den-graph.cc index cbe15740872..ae350aefea7 100644 --- a/src/chain/chain-den-graph.cc +++ b/src/chain/chain-den-graph.cc @@ -312,7 +312,7 @@ void CreateDenominatorFst(const ContextDependency &ctx_dep, // previously an acceptor, so we project, i.e. copy the ilabels to the // olabels AddSubsequentialLoop(subsequential_symbol, &phone_lm); - fst::Project(&phone_lm, fst::PROJECT_INPUT); + fst::Project(&phone_lm, fst::ProjectType::INPUT); } std::vector disambig_syms; // empty list of disambiguation symbols. @@ -330,7 +330,7 @@ void CreateDenominatorFst(const ContextDependency &ctx_dep, // at this point, context_dep_lm will have indexes into 'ilabels' as its // input symbol (representing context-dependent phones), and phones on its // output. We don't need the phones, so we'll project. - fst::Project(&context_dep_lm, fst::PROJECT_INPUT); + fst::Project(&context_dep_lm, fst::ProjectType::INPUT); KALDI_LOG << "Number of states and arcs in context-dependent LM FST is " << context_dep_lm.NumStates() << " and " << NumArcs(context_dep_lm); @@ -365,7 +365,7 @@ void CreateDenominatorFst(const ContextDependency &ctx_dep, // context-dependent phones (indexes into IlabelInfo()) as its olabels. // Discard the context-dependent phones by projecting on the input, keeping // only the transition-ids. - fst::Project(&transition_id_fst, fst::PROJECT_INPUT); + fst::Project(&transition_id_fst, fst::ProjectType::INPUT); MapFstToPdfIdsPlusOne(trans_model, &transition_id_fst); KALDI_LOG << "Number of states and arcs in transition-id FST is " diff --git a/src/chain/chain-supervision.cc b/src/chain/chain-supervision.cc index b29000a448c..9c009c6c0da 100644 --- a/src/chain/chain-supervision.cc +++ b/src/chain/chain-supervision.cc @@ -306,7 +306,7 @@ bool ProtoSupervisionToSupervision( // previously an acceptor, so we project, i.e. copy the ilabels to the // olabels AddSubsequentialLoop(subsequential_symbol, &phone_fst); - fst::Project(&phone_fst, fst::PROJECT_INPUT); + fst::Project(&phone_fst, fst::ProjectType::INPUT); } // inv_cfst will be expanded on the fly, as needed. @@ -325,7 +325,7 @@ bool ProtoSupervisionToSupervision( // 'inv_cfst.IlabelInfo()' as its input symbol (representing context-dependent // phones), and phones on its output. We don't need the phones, so we'll // project. - fst::Project(&context_dep_fst, fst::PROJECT_INPUT); + fst::Project(&context_dep_fst, fst::ProjectType::INPUT); std::vector disambig_syms_h; // disambiguation symbols on input side of // H -- will be empty, as there were no @@ -364,7 +364,7 @@ bool ProtoSupervisionToSupervision( // context-dependent phones (indexes into ILabelInfo()) as its olabels. // Discard the context-dependent phones by projecting on the input, keeping // only the transition-ids. - fst::Project(&transition_id_fst, fst::PROJECT_INPUT); + fst::Project(&transition_id_fst, fst::ProjectType::INPUT); if (transition_id_fst.Properties(fst::kIEpsilons, true) != 0) { // remove epsilons, if there are any. fst::RmEpsilon(&transition_id_fst); @@ -385,7 +385,7 @@ bool ProtoSupervisionToSupervision( if (convert_to_pdfs) { // at this point supervision->fst will have pdf-ids plus one as the olabels, // but still transition-ids as the ilabels. Copy olabels to ilabels. - fst::Project(&(supervision->fst), fst::PROJECT_OUTPUT); + fst::Project(&(supervision->fst), fst::ProjectType::OUTPUT); } KALDI_ASSERT(supervision->fst.Properties(fst::kIEpsilons, true) == 0); diff --git a/src/fstbin/fsts-project.cc b/src/fstbin/fsts-project.cc index 015f1431725..22a96afa4e4 100644 --- a/src/fstbin/fsts-project.cc +++ b/src/fstbin/fsts-project.cc @@ -67,7 +67,7 @@ int main(int argc, char *argv[]) { std::string key = fst_reader.Key(); VectorFst fst(fst_reader.Value()); - Project(&fst, project_output ? PROJECT_OUTPUT : PROJECT_INPUT); + Project(&fst, project_output ? ProjectType::OUTPUT : ProjectType::INPUT); fst_writer.Write(key, fst); n_done++; diff --git a/src/fstext/context-fst.cc b/src/fstext/context-fst.cc index d382144700d..817cf04cf50 100644 --- a/src/fstext/context-fst.cc +++ b/src/fstext/context-fst.cc @@ -279,7 +279,7 @@ void ComposeContext(const vector &disambig_syms_in, if (central_position != context_width-1) { AddSubsequentialLoop(subseq_sym, ifst); if (project_ifst) { - fst::Project(ifst, fst::PROJECT_INPUT); + fst::Project(ifst, fst::ProjectType::INPUT); } } diff --git a/src/fstext/kaldi-fst-io.cc b/src/fstext/kaldi-fst-io.cc index 61d6cc74724..626e6508a39 100644 --- a/src/fstext/kaldi-fst-io.cc +++ b/src/fstext/kaldi-fst-io.cc @@ -132,7 +132,7 @@ fst::VectorFst *ReadAndPrepareLmFst(std::string rxfilename) { // symbol #0 on the input symbols of the backoff arc, and projection will // replace them with epsilons which is what is on the output symbols of // those arcs. - fst::Project(ans, fst::PROJECT_OUTPUT); + fst::Project(ans, fst::ProjectType::OUTPUT); } if (ans->Properties(fst::kILabelSorted, true) == 0) { // Make sure LM is sorted on ilabel. diff --git a/src/lat/word-align-lattice-lexicon.cc b/src/lat/word-align-lattice-lexicon.cc index 5cd75078cb9..3726ca8c5fc 100644 --- a/src/lat/word-align-lattice-lexicon.cc +++ b/src/lat/word-align-lattice-lexicon.cc @@ -311,7 +311,7 @@ class LatticeLexiconWordAligner { std::vector syms_to_remove; syms_to_remove.push_back(kTemporaryEpsilon); RemoveSomeInputSymbols(syms_to_remove, lat_out_); - Project(lat_out_, fst::PROJECT_INPUT); + Project(lat_out_, fst::ProjectType::INPUT); } bool AlignLattice() { diff --git a/src/lat/word-align-lattice.cc b/src/lat/word-align-lattice.cc index d644709cb2a..86407ecd387 100644 --- a/src/lat/word-align-lattice.cc +++ b/src/lat/word-align-lattice.cc @@ -299,7 +299,7 @@ class LatticeWordAligner { syms_to_remove.push_back(info_.silence_label); if (!syms_to_remove.empty()) { RemoveSomeInputSymbols(syms_to_remove, lat_out_); - Project(lat_out_, fst::PROJECT_INPUT); + Project(lat_out_, fst::ProjectType::INPUT); } } @@ -890,7 +890,7 @@ class WordAlignedLatticeTester { std::vector to_remove; to_remove.push_back(info_.silence_label); RemoveSomeInputSymbols(to_remove, &aligned_lat); - Project(&aligned_lat, fst::PROJECT_INPUT); + Project(&aligned_lat, fst::ProjectType::INPUT); } if (!RandEquivalent(lat_, aligned_lat, 5/*paths*/, 1.0e+10/*delta*/, Rand()/*seed*/, diff --git a/src/latbin/lattice-interp.cc b/src/latbin/lattice-interp.cc index 41e1b32658f..b0cd9b433b9 100644 --- a/src/latbin/lattice-interp.cc +++ b/src/latbin/lattice-interp.cc @@ -80,7 +80,7 @@ int main(int argc, char *argv[]) { Lattice lat2; ConvertLattice(clat2, &lat2); - fst::Project(&lat2, fst::PROJECT_OUTPUT); // project on words. + fst::Project(&lat2, fst::ProjectType::OUTPUT); // project on words. ScaleLattice(fst::LatticeScale(1.0-alpha, 1.0-alpha), &lat2); ArcSort(&lat2, fst::ILabelCompare()); diff --git a/src/latbin/lattice-oracle.cc b/src/latbin/lattice-oracle.cc index f6ce790d51d..f3c851dab46 100644 --- a/src/latbin/lattice-oracle.cc +++ b/src/latbin/lattice-oracle.cc @@ -69,7 +69,7 @@ void ConvertLatticeToUnweightedAcceptor(const kaldi::Lattice &ilat, fst::ConvertLattice(ilat, ofst); // remove weights, project to output, sort according to input arg fst::Map(ofst, fst::RmWeightMapper()); - fst::Project(ofst, fst::PROJECT_OUTPUT); // The words are on the output side + fst::Project(ofst, fst::ProjectType::OUTPUT); // The words are on the output side fst::Relabel(ofst, wildcards, wildcards); fst::RmEpsilon(ofst); // Don't tolerate epsilons as they make it hard to // tally errors @@ -367,7 +367,7 @@ int main(int argc, char *argv[]) { fst::ArcSort(&clat, fst::ILabelCompare()); fst::Compose(oracle_clat_mask, clat, &oracle_clat_mask); fst::ShortestPath(oracle_clat_mask, &oracle_clat); - fst::Project(&oracle_clat, fst::PROJECT_OUTPUT); + fst::Project(&oracle_clat, fst::ProjectType::OUTPUT); TopSortCompactLatticeIfNeeded(&oracle_clat); if (oracle_clat.Start() == fst::kNoStateId) { diff --git a/src/latbin/lattice-project.cc b/src/latbin/lattice-project.cc index b74ab177594..d865a53e443 100644 --- a/src/latbin/lattice-project.cc +++ b/src/latbin/lattice-project.cc @@ -67,7 +67,7 @@ int main(int argc, char *argv[]) { RemoveAlignmentsFromCompactLattice(&clat); Lattice lat; ConvertLattice(clat, &lat); - fst::Project(&lat, fst::PROJECT_OUTPUT); // project on words. + fst::Project(&lat, fst::ProjectType::OUTPUT); // project on words. lattice_writer.Write(key, lat); n_done++; } @@ -78,7 +78,7 @@ int main(int argc, char *argv[]) { std::string key = lattice_reader.Key(); Lattice lat = lattice_reader.Value(); lattice_reader.FreeCurrent(); - fst::Project(&lat, fst::PROJECT_INPUT); + fst::Project(&lat, fst::ProjectType::INPUT); lattice_writer.Write(key, lat); n_done++; } diff --git a/src/latbin/lattice-to-fst.cc b/src/latbin/lattice-to-fst.cc index 0d2ac29a99b..39a9ec97f38 100644 --- a/src/latbin/lattice-to-fst.cc +++ b/src/latbin/lattice-to-fst.cc @@ -78,7 +78,7 @@ int main(int argc, char *argv[]) { // extra states because already removed alignments. ConvertLattice(lat, &fst); // this adds up the (lm,acoustic) costs to get // the normal (tropical) costs. - Project(&fst, fst::PROJECT_OUTPUT); // Because in the standard Lattice format, + Project(&fst, fst::ProjectType::OUTPUT); // Because in the standard Lattice format, // the words are on the output, and we want the word labels. } if (rm_eps) RemoveEpsLocal(&fst); diff --git a/src/nnet2/nnet-example-functions.cc b/src/nnet2/nnet-example-functions.cc index 47e039d3341..915c3262ec5 100644 --- a/src/nnet2/nnet-example-functions.cc +++ b/src/nnet2/nnet-example-functions.cc @@ -264,7 +264,7 @@ void DiscriminativeExampleSplitter::CollapseTransitionIds() { void DiscriminativeExampleSplitter::PrepareLattice(bool first_time) { ::fst::ConvertLattice(eg_.den_lat, &lat_); - Project(&lat_, fst::PROJECT_INPUT); // Get rid of the word labels and put the + Project(&lat_, fst::ProjectType::INPUT); // Get rid of the word labels and put the // transition-ids on both sides. RmEpsilon(&lat_); // Remove epsilons.. this simplifies diff --git a/src/nnet3/discriminative-supervision.cc b/src/nnet3/discriminative-supervision.cc index 0f8f8a4aef7..5431382c4cd 100644 --- a/src/nnet3/discriminative-supervision.cc +++ b/src/nnet3/discriminative-supervision.cc @@ -326,7 +326,7 @@ void DiscriminativeSupervisionSplitter::CreateRangeLattice( // Get rid of the word labels and put the // transition-ids on both sides. - fst::Project(out_lat, fst::PROJECT_INPUT); + fst::Project(out_lat, fst::ProjectType::INPUT); fst::RmEpsilon(out_lat); if (config_.collapse_transition_ids)