vosk-api/kaldi-fst.patch
2024-12-18 12:24:32 +05:30

162 lines
7 KiB
Diff

diff -ur vosk-api-0.3.45.orig/kaldi/src/base/kaldi-types.h vosk-api-0.3.45/kaldi/src/base/kaldi-types.h
--- vosk-api-0.3.45.orig/kaldi/src/base/kaldi-types.h 2022-11-19 05:23:44.000000000 +0530
+++ vosk-api-0.3.45/kaldi/src/base/kaldi-types.h 2024-07-29 17:56:36.472446440 +0530
@@ -39,24 +39,21 @@
// we find in the future lacks stdint.h
#include <stdint.h>
-// for discussion on what to do if you need compile kaldi
-// without OpenFST, see the bottom of this this file
-#include <fst/types.h>
+#include <cstdlib> // for ssize_t.
+#include <cstdint> // for ?int*_t.
-namespace kaldi {
- using ::int16;
- using ::int32;
- using ::int64;
- using ::uint16;
- using ::uint32;
- using ::uint64;
- typedef float float32;
- typedef double double64;
-} // end namespace kaldi
+using int8 = int8_t;
+using int16 = int16_t;
+using int32 = int32_t;
+using int64 = int64_t;
+using uint8 = uint8_t;
+using uint16 = uint16_t;
+using uint32 = uint32_t;
+using uint64 = uint64_t;
// In a theoretical case you decide compile Kaldi without the OpenFST
// comment the previous namespace statement and uncomment the following
-/*
+
namespace kaldi {
typedef int8_t int8;
typedef int16_t int16;
@@ -70,6 +67,6 @@
typedef float float32;
typedef double double64;
} // end namespace kaldi
-*/
+
#endif // KALDI_BASE_KALDI_TYPES_H_
diff -ur vosk-api-0.3.45.orig/kaldi/src/configure vosk-api-0.3.45/kaldi/src/configure
--- vosk-api-0.3.45.orig/kaldi/src/configure 2022-11-19 05:23:44.000000000 +0530
+++ vosk-api-0.3.45/kaldi/src/configure 2024-07-29 18:06:59.370087996 +0530
@@ -933,7 +933,7 @@
OPENFST_VER=${OPENFST_VER:-$(grep 'PACKAGE_VERSION' $FSTROOT/Makefile | sed -e 's:.*= ::')}
OPENFST_VER_NUM=$(echo $OPENFST_VER | sed 's/\./ /g' | xargs printf "%d%02d%02d")
if [ $OPENFST_VER_NUM -lt 10600 ]; then
- failure "OpenFst-$OPENFST_VER is not supported. You need OpenFst >= 1.6.0.)"
+ :
fi
echo "OPENFSTINC = $FSTROOT/include" >> kaldi.mk
if $static_fst ; then
diff -ur vosk-api-0.3.45.orig/kaldi/src/fstext/kaldi-fst-io-inl.h vosk-api-0.3.45/kaldi/src/fstext/kaldi-fst-io-inl.h
--- vosk-api-0.3.45.orig/kaldi/src/fstext/kaldi-fst-io-inl.h 2022-11-19 05:23:44.000000000 +0530
+++ vosk-api-0.3.45/kaldi/src/fstext/kaldi-fst-io-inl.h 2024-07-29 18:11:03.346500252 +0530
@@ -99,7 +99,7 @@
fst->DeleteStates();
string line;
size_t nline = 0;
- string separator = FLAGS_fst_field_separator + "\r\n";
+ string separator = FST_FLAGS_fst_field_separator + "\r\n";
while (std::getline(is, line)) {
nline++;
vector<string> col;
diff -ur vosk-api-0.3.45.orig/kaldi/src/fstext/lattice-weight.h vosk-api-0.3.45/kaldi/src/fstext/lattice-weight.h
--- vosk-api-0.3.45.orig/kaldi/src/fstext/lattice-weight.h 2022-11-19 05:23:44.000000000 +0530
+++ vosk-api-0.3.45/kaldi/src/fstext/lattice-weight.h 2024-07-29 18:20:58.390880865 +0530
@@ -396,8 +396,8 @@
template <class FloatType>
inline std::ostream &operator <<(std::ostream &strm, const LatticeWeightTpl<FloatType> &w) {
LatticeWeightTpl<FloatType>::WriteFloatType(strm, w.Value1());
- CHECK(FLAGS_fst_weight_separator.size() == 1);
- strm << FLAGS_fst_weight_separator[0]; // comma by default;
+ CHECK(FST_FLAGS_fst_weight_separator.size() == 1);
+ strm << FST_FLAGS_fst_weight_separator[0]; // comma by default;
// may or may not be settable from Kaldi programs.
LatticeWeightTpl<FloatType>::WriteFloatType(strm, w.Value2());
return strm;
@@ -405,9 +405,9 @@
template <class FloatType>
inline std::istream &operator >>(std::istream &strm, LatticeWeightTpl<FloatType> &w1) {
- CHECK(FLAGS_fst_weight_separator.size() == 1);
+ CHECK(FST_FLAGS_fst_weight_separator.size() == 1);
// separator defaults to ','
- return w1.ReadNoParen(strm, FLAGS_fst_weight_separator[0]);
+ return w1.ReadNoParen(strm, FST_FLAGS_fst_weight_separator[0]);
}
@@ -728,8 +728,8 @@
template <class WeightType, class IntType>
inline std::ostream &operator <<(std::ostream &strm, const CompactLatticeWeightTpl<WeightType, IntType> &w) {
strm << w.Weight();
- CHECK(FLAGS_fst_weight_separator.size() == 1);
- strm << FLAGS_fst_weight_separator[0]; // comma by default.
+ CHECK(FST_FLAGS_fst_weight_separator.size() == 1);
+ strm << FST_FLAGS_fst_weight_separator[0]; // comma by default.
for(size_t i = 0; i < w.String().size(); i++) {
strm << w.String()[i];
if (i+1 < w.String().size())
@@ -745,8 +745,8 @@
if (strm.fail()) {
return strm;
}
- CHECK(FLAGS_fst_weight_separator.size() == 1);
- size_t pos = s.find_last_of(FLAGS_fst_weight_separator); // normally ","
+ CHECK(FST_FLAGS_fst_weight_separator.size() == 1);
+ size_t pos = s.find_last_of(FST_FLAGS_fst_weight_separator); // normally ","
if (pos == std::string::npos) {
strm.clear(std::ios::badbit);
return strm;
diff -ur vosk-api-0.3.45.orig/kaldi/src/fstext/trivial-factor-weight.h vosk-api-0.3.45/kaldi/src/fstext/trivial-factor-weight.h
--- vosk-api-0.3.45.orig/kaldi/src/fstext/trivial-factor-weight.h 2022-11-19 05:23:44.000000000 +0530
+++ vosk-api-0.3.45/kaldi/src/fstext/trivial-factor-weight.h 2024-07-29 18:24:27.314958419 +0530
@@ -390,7 +390,7 @@
template <class A, class F>
inline void TrivialFactorWeightFst<A, F>::InitStateIterator(
StateIteratorData<A> *data) const {
- data->base = fst::make_unique<StateIterator<TrivialFactorWeightFst<A, F> > >(*this);
+ data->base = std::make_unique<StateIterator<TrivialFactorWeightFst<A, F> > >(*this);
}
diff -ur vosk-api-0.3.45.orig/kaldi/src/lat/kaldi-lattice.cc vosk-api-0.3.45/kaldi/src/lat/kaldi-lattice.cc
--- vosk-api-0.3.45.orig/kaldi/src/lat/kaldi-lattice.cc 2022-11-19 05:23:44.000000000 +0530
+++ vosk-api-0.3.45/kaldi/src/lat/kaldi-lattice.cc 2024-07-29 18:27:40.742797294 +0530
@@ -114,7 +114,7 @@
CompactLattice *cfst = new CompactLattice();
string line;
size_t nline = 0;
- string separator = FLAGS_fst_field_separator + "\r\n";
+ string separator = FST_FLAGS_fst_field_separator + "\r\n";
while (std::getline(is, line)) {
nline++;
vector<string> col;
diff -ur vosk-api-0.3.45.orig/kaldi/src/lat/lattice-functions-transition-model.cc vosk-api-0.3.45/kaldi/src/lat/lattice-functions-transition-model.cc
--- vosk-api-0.3.45.orig/kaldi/src/lat/lattice-functions-transition-model.cc 2022-11-19 05:23:44.000000000 +0530
+++ vosk-api-0.3.45/kaldi/src/lat/lattice-functions-transition-model.cc 2024-07-29 18:30:17.735011144 +0530
@@ -248,13 +248,13 @@
int32 num_paths = 5, seed = Rand(), max_path_length = -1;
BaseFloat delta = 0.2; // some lattices have large costs -> use large delta.
- FLAGS_v = GetVerboseLevel(); // set the OpenFst verbose level to the Kaldi
+ FST_FLAGS_v = GetVerboseLevel(); // set the OpenFst verbose level to the Kaldi
// verbose level.
if (!RandEquivalent(clat, aligned_clat, num_paths, delta, seed, max_path_length)) {
KALDI_WARN << "Equivalence test failed during lattice alignment.";
return false;
}
- FLAGS_v = 0;
+ FST_FLAGS_v = 0;
return (num_err == 0);
}