From 8271fcfb0a7837d0cc8fdbe8764dedaa17924cc0 Mon Sep 17 00:00:00 2001 From: Hui Zhang Date: Mon, 24 Oct 2022 08:31:42 +0000 Subject: [PATCH] fix as comment --- speechx/CMakeLists.txt | 27 ++++++++++++++++--- speechx/README.md | 4 +-- speechx/cmake/paddleinference.cmake | 9 ------- speechx/examples/codelab/feat/run.sh | 6 ++--- speechx/examples/codelab/u2/local/decode.sh | 2 +- speechx/speechx/decoder/CMakeLists.txt | 10 +++---- speechx/speechx/decoder/ctc_beam_search_opt.h | 5 ++-- .../decoder/ctc_prefix_beam_search_decoder.cc | 6 ++--- .../decoder/ctc_prefix_beam_search_decoder.h | 4 +-- 9 files changed, 42 insertions(+), 31 deletions(-) diff --git a/speechx/CMakeLists.txt b/speechx/CMakeLists.txt index 6255cb2e..978a23d9 100644 --- a/speechx/CMakeLists.txt +++ b/speechx/CMakeLists.txt @@ -102,7 +102,16 @@ message(STATUS "Pybind11_INCLUDES = ${pybind11_INCLUDE_DIRS}, pybind11_LIBRARIES # paddle include and link option # -L/workspace/DeepSpeech-2.x/speechx/venv/lib/python3.7/site-packages/paddle/libs -L/workspace/DeepSpeech-2.x/speechx/venv/lib/python3.7/site-packages/paddle/fluid -l:libpaddle.so -l:libdnnl.so.2 -l:libiomp5.so execute_process( - COMMAND python -c "import os; import paddle; include_dir=paddle.sysconfig.get_include(); paddle_dir=os.path.split(include_dir)[0]; libs_dir=os.path.join(paddle_dir, 'libs'); fluid_dir=os.path.join(paddle_dir, 'fluid'); out=' '.join([\"-L\" + libs_dir, \"-L\" + fluid_dir]); out += \" -l:libpaddle.so -l:libdnnl.so.2 -l:libiomp5.so\"; print(out);" + COMMAND python -c "\ +import os;\ +import paddle;\ +include_dir=paddle.sysconfig.get_include();\ +paddle_dir=os.path.split(include_dir)[0];\ +libs_dir=os.path.join(paddle_dir, 'libs');\ +fluid_dir=os.path.join(paddle_dir, 'fluid');\ +out=' '.join([\"-L\" + libs_dir, \"-L\" + fluid_dir]);\ +out += \" -l:libpaddle.so -l:libdnnl.so.2 -l:libiomp5.so\"; print(out);\ + " OUTPUT_VARIABLE PADDLE_LINK_FLAGS RESULT_VARIABLE SUCESS) @@ -112,7 +121,11 @@ string(STRIP ${PADDLE_LINK_FLAGS} PADDLE_LINK_FLAGS) # paddle compile option # -I/workspace/DeepSpeech-2.x/speechx/venv/lib/python3.7/site-packages/paddle/include execute_process( - COMMAND python -c "import paddle; include_dir = paddle.sysconfig.get_include(); print(f\"-I{include_dir}\");" + COMMAND python -c "\ +import paddle; \ +include_dir = paddle.sysconfig.get_include(); \ +print(f\"-I{include_dir}\"); \ + " OUTPUT_VARIABLE PADDLE_COMPILE_FLAGS) message(STATUS PADDLE_COMPILE_FLAGS= ${PADDLE_COMPILE_FLAGS}) string(STRIP ${PADDLE_COMPILE_FLAGS} PADDLE_COMPILE_FLAGS) @@ -121,7 +134,15 @@ string(STRIP ${PADDLE_COMPILE_FLAGS} PADDLE_COMPILE_FLAGS) # for LD_LIBRARY_PATH # set(PADDLE_LIB_DIRS /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages/paddle/fluid:/workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages/paddle/libs/) execute_process( - COMMAND python -c "import os; import paddle; include_dir=paddle.sysconfig.get_include(); paddle_dir=os.path.split(include_dir)[0]; libs_dir=os.path.join(paddle_dir, 'libs'); fluid_dir=os.path.join(paddle_dir, 'fluid'); out=':'.join([libs_dir, fluid_dir]); print(out);" + COMMAND python -c " \ +import os; \ +import paddle; \ +include_dir=paddle.sysconfig.get_include(); \ +paddle_dir=os.path.split(include_dir)[0]; \ +libs_dir=os.path.join(paddle_dir, 'libs'); \ +fluid_dir=os.path.join(paddle_dir, 'fluid'); \ +out=':'.join([libs_dir, fluid_dir]); print(out); \ + " OUTPUT_VARIABLE PADDLE_LIB_DIRS) message(STATUS PADDLE_LIB_DIRS= ${PADDLE_LIB_DIRS}) diff --git a/speechx/README.md b/speechx/README.md index 3861edf3..f744defa 100644 --- a/speechx/README.md +++ b/speechx/README.md @@ -9,7 +9,7 @@ We develop under: * gcc/g++/gfortran - 8.2.0 * cmake - 3.16.0 -> Please using `tools/env.sh` to create python `venv`, then `source venv/bin/activate` to build speechx. +> Please use `tools/env.sh` to create python `venv`, then `source venv/bin/activate` to build speechx. > We make sure all things work fun under docker, and recommend using it to develop and deploy. @@ -35,7 +35,7 @@ bash tools/venv.sh 2. Build `speechx` and `examples`. -For now we using feature under `develop` branch of paddle, so we need install `paddlepaddle` nightly build version. +For now we are using feature under `develop` branch of paddle, so we need to install `paddlepaddle` nightly build version. For example: ``` source venv/bin/activate diff --git a/speechx/cmake/paddleinference.cmake b/speechx/cmake/paddleinference.cmake index 311804d6..d8a9c613 100644 --- a/speechx/cmake/paddleinference.cmake +++ b/speechx/cmake/paddleinference.cmake @@ -1,14 +1,5 @@ set(paddle_SOURCE_DIR ${fc_patch}/paddle-lib) set(paddle_PREFIX_DIR ${fc_patch}/paddle-lib-prefix) -# ExternalProject_Add(paddle -# URL https://paddle-inference-lib.bj.bcebos.com/2.2.2/cxx_c/Linux/CPU/gcc8.2_avx_mkl/paddle_inference.tgz -# URL_HASH SHA256=7c6399e778c6554a929b5a39ba2175e702e115145e8fa690d2af974101d98873 -# PREFIX ${paddle_PREFIX_DIR} -# SOURCE_DIR ${paddle_SOURCE_DIR} -# CONFIGURE_COMMAND "" -# BUILD_COMMAND "" -# INSTALL_COMMAND "" -# ) include(FetchContent) FetchContent_Declare( diff --git a/speechx/examples/codelab/feat/run.sh b/speechx/examples/codelab/feat/run.sh index 66bd8ae2..5d7612ae 100755 --- a/speechx/examples/codelab/feat/run.sh +++ b/speechx/examples/codelab/feat/run.sh @@ -42,8 +42,8 @@ mkdir -p $exp_dir export GLOG_logtostderr=1 cmvn_json2kaldi_main \ - --json_file $model_dir/data/mean_std.json \ - --cmvn_write_path $exp_dir/cmvn.ark \ + --json_file=$model_dir/data/mean_std.json \ + --cmvn_write_path=$exp_dir/cmvn.ark \ --binary=false echo "convert json cmvn to kaldi ark." @@ -55,7 +55,7 @@ compute_linear_spectrogram_main \ echo "compute linear spectrogram feature." compute_fbank_main \ - --num_bins 161 \ + --num_bins=161 \ --wav_rspecifier=scp:$data_dir/wav.scp \ --feature_wspecifier=ark,t:$exp_dir/fbank.ark \ --cmvn_file=$exp_dir/cmvn.ark diff --git a/speechx/examples/codelab/u2/local/decode.sh b/speechx/examples/codelab/u2/local/decode.sh index c22ad7f0..11c1afe8 100755 --- a/speechx/examples/codelab/u2/local/decode.sh +++ b/speechx/examples/codelab/u2/local/decode.sh @@ -7,7 +7,7 @@ set -e data=data exp=exp mkdir -p $exp -ckpt_dir=./data/model +ckpt_dir=$data/model model_dir=$ckpt_dir/asr1_chunk_conformer_u2pp_wenetspeech_static_1.1.0.model/ ctc_prefix_beam_search_decoder_main \ diff --git a/speechx/speechx/decoder/CMakeLists.txt b/speechx/speechx/decoder/CMakeLists.txt index 5bec24a6..f0fd32ba 100644 --- a/speechx/speechx/decoder/CMakeLists.txt +++ b/speechx/speechx/decoder/CMakeLists.txt @@ -4,11 +4,11 @@ set(srcs) if (USING_DS2) list(APPEND srcs -ctc_decoders/decoder_utils.cpp -ctc_decoders/path_trie.cpp -ctc_decoders/scorer.cpp -ctc_beam_search_decoder.cc -ctc_tlg_decoder.cc + ctc_decoders/decoder_utils.cpp + ctc_decoders/path_trie.cpp + ctc_decoders/scorer.cpp + ctc_beam_search_decoder.cc + ctc_tlg_decoder.cc ) endif() diff --git a/speechx/speechx/decoder/ctc_beam_search_opt.h b/speechx/speechx/decoder/ctc_beam_search_opt.h index 4a4f817d..f9e5933c 100644 --- a/speechx/speechx/decoder/ctc_beam_search_opt.h +++ b/speechx/speechx/decoder/ctc_beam_search_opt.h @@ -11,12 +11,11 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#pragma once #include "base/common.h" #include "util/parse-options.h" -#pragma once - namespace ppspeech { @@ -76,4 +75,4 @@ struct CTCBeamSearchOptions { } }; -} // namespace ppspeech \ No newline at end of file +} // namespace ppspeech diff --git a/speechx/speechx/decoder/ctc_prefix_beam_search_decoder.cc b/speechx/speechx/decoder/ctc_prefix_beam_search_decoder.cc index 7414d06d..56867c70 100644 --- a/speechx/speechx/decoder/ctc_prefix_beam_search_decoder.cc +++ b/speechx/speechx/decoder/ctc_prefix_beam_search_decoder.cc @@ -107,12 +107,12 @@ void CTCPrefixBeamSearch::AdvanceDecoding( std::min(static_cast(logp[0].size()), opts_.first_beam_size); for (int t = 0; t < logp.size(); ++t, ++num_frame_decoded_) { - const std::vector& logp_t = logp[t]; + const std::vector& logp_t = logp[t]; std::unordered_map, PrefixScore, PrefixScoreHash> next_hyps; // 1. first beam prune, only select topk candidates - std::vector topk_score; + std::vector topk_score; std::vector topk_index; TopK(logp_t, first_beam_size, &topk_score, &topk_index); VLOG(2) << "topk: " << num_frame_decoded_ << " " @@ -367,4 +367,4 @@ std::string CTCPrefixBeamSearch::GetFinalBestPath() { return GetBestPath(); } std::string CTCPrefixBeamSearch::GetPartialResult() { return GetBestPath(); } -} // namespace ppspeech \ No newline at end of file +} // namespace ppspeech diff --git a/speechx/speechx/decoder/ctc_prefix_beam_search_decoder.h b/speechx/speechx/decoder/ctc_prefix_beam_search_decoder.h index a0c2a74e..91977092 100644 --- a/speechx/speechx/decoder/ctc_prefix_beam_search_decoder.h +++ b/speechx/speechx/decoder/ctc_prefix_beam_search_decoder.h @@ -27,7 +27,7 @@ namespace ppspeech { class ContextGraph; class CTCPrefixBeamSearch : public DecoderBase { public: - explicit CTCPrefixBeamSearch(const std::string& vocab_path, + CTCPrefixBeamSearch(const std::string& vocab_path, const CTCBeamSearchOptions& opts); ~CTCPrefixBeamSearch() {} @@ -98,4 +98,4 @@ class CTCPrefixBeamSearch : public DecoderBase { }; -} // namespace ppspeech \ No newline at end of file +} // namespace ppspeech -- GitLab