From 4c92af5717dc16bbd509c700aea9a03a082a0be5 Mon Sep 17 00:00:00 2001 From: lidongdong Date: Mon, 18 Jul 2022 19:47:12 +0800 Subject: [PATCH] feat:add windows ctc-decoders compile func --- third_party/ctc_decoders/scorer.cpp | 3 ++- third_party/ctc_decoders/setup.py | 15 ++++++++------- third_party/install.bat | 24 ++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 third_party/install.bat diff --git a/third_party/ctc_decoders/scorer.cpp b/third_party/ctc_decoders/scorer.cpp index 6c1d96be..6e7f68cf 100644 --- a/third_party/ctc_decoders/scorer.cpp +++ b/third_party/ctc_decoders/scorer.cpp @@ -13,7 +13,8 @@ #include "decoder_utils.h" using namespace lm::ngram; - +// if your platform is windows ,you need add the define +#define F_OK 0 Scorer::Scorer(double alpha, double beta, const std::string& lm_path, diff --git a/third_party/ctc_decoders/setup.py b/third_party/ctc_decoders/setup.py index ce2787e3..ee81c8fd 100644 --- a/third_party/ctc_decoders/setup.py +++ b/third_party/ctc_decoders/setup.py @@ -89,10 +89,11 @@ FILES = [ or fn.endswith('unittest.cc')) ] # yapf: enable - -LIBS = ['stdc++'] +# LIBS = ['stdc++'] +LIBS = ['-static-libstdc++'] if platform.system() != 'Darwin': - LIBS.append('rt') + # LIBS.append('rt') + pass ARGS = ['-O3', '-DNDEBUG', '-DKENLM_MAX_ORDER=6', '-std=c++11'] @@ -126,12 +127,12 @@ decoders_module = [ ] setup( - name='paddlespeech_ctcdecoders', + name='paddlespeech_ldd_ctcdecoders', version='0.2.0', description="CTC decoders in paddlespeech", - author="PaddlePaddle Speech and Language Team", - author_email="paddlesl@baidu.com", + author="PaddlePaddle Speech user lidongdong compile for windows", + author_email="double_dongli@foxmail.com", url="https://github.com/PaddlePaddle/PaddleSpeech", license='Apache 2.0, GNU Lesser General Public License v3 (LGPLv3) (LGPL-3)', ext_modules=decoders_module, - py_modules=['paddlespeech_ctcdecoders']) + py_modules=['paddlespeech_ldd_ctcdecoders']) diff --git a/third_party/install.bat b/third_party/install.bat new file mode 100644 index 00000000..8669e444 --- /dev/null +++ b/third_party/install.bat @@ -0,0 +1,24 @@ +@echo off + +cd ctc_decoders +if not exist kenlm ( + git clone https://github.com/Doubledongli/kenlm.git + cd kenlm/ + git checkout df2d717e95183f79a90b2fa6e4307083a351ca6a + cd .. + @echo. +) + +if not exist openfst-1.6.3 ( + echo "Download and extract openfst ..." + git clone https://gitee.com/koala999/openfst.git + ren openfst openfst-1.6.3 + @echo. +) + +if not exist ThreadPool ( + git clone https://github.com/progschj/ThreadPool.git + @echo. +) +echo "Install decoders ..." +python setup.py install --num_processes 4 \ No newline at end of file