From d288a408d5e0f67ad04c3db7b4d682dc3d22ed58 Mon Sep 17 00:00:00 2001 From: Administrator Date: Fri, 17 May 2024 16:08:40 +0800 Subject: [PATCH] =?UTF-8?q?2024.5.16=20=E6=B5=8B=E8=AF=95=E6=95=B4?= =?UTF-8?q?=E4=BD=93=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 2 +- cmake-linux/openfst.cmake | 3 +-- kaldi/base/kaldi-error.h | 8 +++--- kaldi/base/kaldi-types.h | 28 ++++++++++---------- kaldi/fstext/determinize-lattice.h | 2 +- kaldi/fstext/lattice-weight.h | 4 +-- post_processor/processor/wetext_processor.cc | 4 +-- utils/log.h | 4 +-- 8 files changed, 27 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 173006b..e286fa5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ set(ColourReset "${Esc}[m") set(BoldGreen "${Esc}[1;32m") set(BoldRed "${Esc}[31m") # 运行参数 -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -pthread -fPIC") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -pthread -fPIC -w") set(LIB_BASE_DIR /root/CXX_ENVS/wenet_runtime) set(third_party_libraries) option(GRPC "whether to build with gRPC" ON) diff --git a/cmake-linux/openfst.cmake b/cmake-linux/openfst.cmake index 2036211..6fcd79a 100644 --- a/cmake-linux/openfst.cmake +++ b/cmake-linux/openfst.cmake @@ -67,8 +67,7 @@ endif () find_path(OPENFST_INCLUDE_DIR fst/fst.h PATHS ${OPENFST_ROOT}/include) find_path(OPENFST_BINARY_DIR fstsymbols PATHS ${OPENFST_ROOT}/bin) -find_path(OPENFST_LIBRARY_DIR libfst.so PATHS ${OPENFST_ROOT}/lib) -set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${OPENFST_LIBRARY_DIR}) +find_library(fst fst PATHS ${OPENFST_ROOT}/lib) set(OPENFST_LIBRARYS fst gflags_nothreads_static glog dl) #验证库和文件是否被找到 include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) diff --git a/kaldi/base/kaldi-error.h b/kaldi/base/kaldi-error.h index 0a5103d..74c6b90 100644 --- a/kaldi/base/kaldi-error.h +++ b/kaldi/base/kaldi-error.h @@ -17,8 +17,7 @@ #ifndef KALDI_BASE_KALDI_ERROR_H_ #define KALDI_BASE_KALDI_ERROR_H_ 1 -#include "kaldi-types.h" -#include +#include "utils/log.h" namespace kaldi { @@ -33,6 +32,7 @@ namespace kaldi { #define KALDI_ASSERT(condition) CHECK(condition) /***** PROGRAM NAME AND VERBOSITY LEVEL *****/ + /// Called by ParseOptions to set base name (no directory) of the executing /// program. The name is printed in logging code along with every message, /// because in our scripts, we often mix together the stderr of many programs. @@ -41,10 +41,10 @@ void SetProgramName(const char* basename); /// This is set by util/parse-options.{h,cc} if you set --verbose=? option. /// Do not use directly, prefer {Get,Set}VerboseLevel(). -extern kaldi::int32 g_kaldi_verbose_level; +extern int32 g_kaldi_verbose_level; /// Get verbosity level, usually set via command line '--verbose=' switch. -inline kaldi::int32 GetVerboseLevel() { return g_kaldi_verbose_level; } +inline int32 GetVerboseLevel() { return g_kaldi_verbose_level; } /// This should be rarely used, except by programs using Kaldi as library; /// command-line programs set the verbose level automatically from ParseOptions. diff --git a/kaldi/base/kaldi-types.h b/kaldi/base/kaldi-types.h index 46c7be7..8b4013e 100644 --- a/kaldi/base/kaldi-types.h +++ b/kaldi/base/kaldi-types.h @@ -41,22 +41,22 @@ typedef float BaseFloat; // for discussion on what to do if you need compile kaldi // without OpenFST, see the bottom of this this file -//#include -// -//namespace kaldi { -//using ::int16; -//using ::int32; -//using ::int64; -//using ::uint16; -//using ::uint32; -//using ::uint64; -//typedef float float32; -//typedef double double64; -//} // end namespace kaldi +#include + +namespace kaldi { +using ::int16; +using ::int32; +using ::int64; +using ::uint16; +using ::uint32; +using ::uint64; +typedef float float32; +typedef double double64; +} // end namespace kaldi // 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 +70,6 @@ namespace kaldi { typedef float float32; typedef double double64; } // end namespace kaldi - +*/ #endif // KALDI_BASE_KALDI_TYPES_H_ diff --git a/kaldi/fstext/determinize-lattice.h b/kaldi/fstext/determinize-lattice.h index f356f7d..8a34071 100644 --- a/kaldi/fstext/determinize-lattice.h +++ b/kaldi/fstext/determinize-lattice.h @@ -20,7 +20,7 @@ #ifndef KALDI_FSTEXT_DETERMINIZE_LATTICE_H_ #define KALDI_FSTEXT_DETERMINIZE_LATTICE_H_ #include -//#include +#include #include #include #include diff --git a/kaldi/fstext/lattice-weight.h b/kaldi/fstext/lattice-weight.h index 1d3a08c..3cec418 100644 --- a/kaldi/fstext/lattice-weight.h +++ b/kaldi/fstext/lattice-weight.h @@ -24,9 +24,9 @@ #include #include #include - +#include "base/kaldi-types.h" #include "base/kaldi-common.h" -//#include "fst/fstlib.h" +#include "fst/fstlib.h" namespace fst { diff --git a/post_processor/processor/wetext_processor.cc b/post_processor/processor/wetext_processor.cc index a186071..b6ed6d0 100644 --- a/post_processor/processor/wetext_processor.cc +++ b/post_processor/processor/wetext_processor.cc @@ -19,7 +19,7 @@ Processor::Processor(const std::string& tagger_path, const std::string& verbalizer_path) { tagger_.reset(StdVectorFst::Read(tagger_path)); verbalizer_.reset(StdVectorFst::Read(verbalizer_path)); - compiler_ = std::make_shared>(fst::TokenType::BYTE); +// compiler_ = std::make_shared>(fst::TokenType::BYTE); printer_ = std::make_shared>(fst::TokenType::BYTE); if (tagger_path.find("_tn_") != tagger_path.npos) { @@ -44,7 +44,7 @@ std::string Processor::ShortestPath(const StdVectorFst& lattice) { std::string Processor::Compose(const std::string& input, const StdVectorFst* fst) { StdVectorFst input_fst; - compiler_->operator()(input, &input_fst); +// compiler_->operator()(input, &input_fst); StdVectorFst lattice; fst::Compose(input_fst, *fst, &lattice); diff --git a/utils/log.h b/utils/log.h index c2bf03f..d9bedff 100644 --- a/utils/log.h +++ b/utils/log.h @@ -14,10 +14,10 @@ #ifndef UTILS_LOG_H_ #define UTILS_LOG_H_ - // Because openfst is a dynamic library compiled with gflags/glog, we must use // the gflags/glog from openfst to avoid them linked both statically and // dynamically into the executable. +#ifndef FST_LOG_H_ #include "fst/log.h" - +#endif #endif // UTILS_LOG_H_