From 36af34b293a18c0fc3b61de3b261b04468cac1b7 Mon Sep 17 00:00:00 2001 From: Hui Zhang Date: Tue, 18 Oct 2022 09:00:14 +0000 Subject: [PATCH] add DecoderBase and license --- speechx/speechx/decoder/ctc_beam_search_decoder.h | 2 +- speechx/speechx/decoder/ctc_prefix_beam_search_decoder.h | 5 ++++- speechx/speechx/decoder/ctc_prefix_beam_search_score.h | 2 ++ speechx/speechx/decoder/ctc_tlg_decoder.h | 2 +- speechx/speechx/decoder/decoder_itf.h | 3 +++ speechx/speechx/nnet/u2_nnet.cc | 3 +++ speechx/speechx/nnet/u2_nnet.h | 2 ++ 7 files changed, 16 insertions(+), 3 deletions(-) diff --git a/speechx/speechx/decoder/ctc_beam_search_decoder.h b/speechx/speechx/decoder/ctc_beam_search_decoder.h index 479754c3..6347bba8 100644 --- a/speechx/speechx/decoder/ctc_beam_search_decoder.h +++ b/speechx/speechx/decoder/ctc_beam_search_decoder.h @@ -23,7 +23,7 @@ namespace ppspeech { -class CTCBeamSearch : public DecoderInterface { +class CTCBeamSearch : public DecoderBase { public: explicit CTCBeamSearch(const CTCBeamSearchOptions& opts); ~CTCBeamSearch() {} diff --git a/speechx/speechx/decoder/ctc_prefix_beam_search_decoder.h b/speechx/speechx/decoder/ctc_prefix_beam_search_decoder.h index eef8823d..ef96ecd9 100644 --- a/speechx/speechx/decoder/ctc_prefix_beam_search_decoder.h +++ b/speechx/speechx/decoder/ctc_prefix_beam_search_decoder.h @@ -1,3 +1,4 @@ +// Copyright (c) 2020 Mobvoi Inc (Binbin Zhang) // Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// modified from https://github.com/wenet-e2e/wenet/blob/main/runtime/core/decoder/ctc_prefix_beam_search.cc + #pragma once #include "decoder/ctc_beam_search_opt.h" @@ -21,7 +24,7 @@ namespace ppspeech { class ContextGraph; -class CTCPrefixBeamSearch : public DecoderInterface { +class CTCPrefixBeamSearch : public DecoderBase { public: explicit CTCPrefixBeamSearch(const std::string vocab_path, const CTCBeamSearchOptions& opts); diff --git a/speechx/speechx/decoder/ctc_prefix_beam_search_score.h b/speechx/speechx/decoder/ctc_prefix_beam_search_score.h index da2fb80a..908be1d6 100644 --- a/speechx/speechx/decoder/ctc_prefix_beam_search_score.h +++ b/speechx/speechx/decoder/ctc_prefix_beam_search_score.h @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// modified from https://github.com/wenet-e2e/wenet/blob/main/runtime/core/decoder/ctc_prefix_beam_search.h + #pragma once #include "base/common.h" diff --git a/speechx/speechx/decoder/ctc_tlg_decoder.h b/speechx/speechx/decoder/ctc_tlg_decoder.h index cf8a9b73..f250ac25 100644 --- a/speechx/speechx/decoder/ctc_tlg_decoder.h +++ b/speechx/speechx/decoder/ctc_tlg_decoder.h @@ -54,7 +54,7 @@ struct TLGDecoderOptions { } }; -class TLGDecoder : public DecoderInterface { +class TLGDecoder : public DecoderBase { public: explicit TLGDecoder(TLGDecoderOptions opts); ~TLGDecoder() = default; diff --git a/speechx/speechx/decoder/decoder_itf.h b/speechx/speechx/decoder/decoder_itf.h index eec9bc3d..2289b317 100644 --- a/speechx/speechx/decoder/decoder_itf.h +++ b/speechx/speechx/decoder/decoder_itf.h @@ -51,7 +51,10 @@ class DecoderInterface { virtual std::vector> GetNBestPath() = 0; virtual std::vector> GetNBestPath(int n) = 0; +}; +class DecoderBase : public DecoderInterface { + protected: // start from one int NumFrameDecoded() { return num_frame_decoded_ + 1; } diff --git a/speechx/speechx/nnet/u2_nnet.cc b/speechx/speechx/nnet/u2_nnet.cc index c92c96aa..ff6a4dc3 100644 --- a/speechx/speechx/nnet/u2_nnet.cc +++ b/speechx/speechx/nnet/u2_nnet.cc @@ -1,3 +1,4 @@ +// Copyright 2022 Horizon Robotics. All Rights Reserved. // Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// modified from https://github.com/wenet-e2e/wenet/blob/main/runtime/core/decoder/asr_model.cc + #include "nnet/u2_nnet.h" #ifdef USE_PROFILING diff --git a/speechx/speechx/nnet/u2_nnet.h b/speechx/speechx/nnet/u2_nnet.h index a37a88f2..48dd8193 100644 --- a/speechx/speechx/nnet/u2_nnet.h +++ b/speechx/speechx/nnet/u2_nnet.h @@ -1,3 +1,4 @@ +// Copyright 2022 Horizon Robotics. All Rights Reserved. // Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,6 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// modified from https://github.com/wenet-e2e/wenet/blob/main/runtime/core/decoder/asr_model.h #pragma once #include "base/common.h"