From 1b47754659157bcedc45627f99b3d17abbd43379 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Fri, 26 Apr 2024 16:24:24 +0800 Subject: [PATCH] Fix a bug for offline paraformer --- .gitignore | 5 +++++ .../csrc/offline-paraformer-greedy-search-decoder.cc | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 83ca941d2..40b772275 100644 --- a/.gitignore +++ b/.gitignore @@ -96,3 +96,8 @@ spoken-language-identification-test-wavs my-release-key* vits-zh-hf-fanchen-C sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01 +*.dll +*.lib +*.tar.gz +*.tar.bz2 +*.zip diff --git a/sherpa-onnx/csrc/offline-paraformer-greedy-search-decoder.cc b/sherpa-onnx/csrc/offline-paraformer-greedy-search-decoder.cc index c1d89a3ab..0e31bd97c 100644 --- a/sherpa-onnx/csrc/offline-paraformer-greedy-search-decoder.cc +++ b/sherpa-onnx/csrc/offline-paraformer-greedy-search-decoder.cc @@ -40,7 +40,7 @@ OfflineParaformerGreedySearchDecoder::Decode( } if (us_cif_peak) { - int32_t dim = us_cif_peak.GetTensorTypeAndShapeInfo().GetShape()[1]; + int32_t dim = us_cif_peak.GetTensorTypeAndShapeInfo().GetShape().back(); const auto *peak = us_cif_peak.GetTensorData() + i * dim; std::vector timestamps; @@ -57,7 +57,10 @@ OfflineParaformerGreedySearchDecoder::Decode( timestamps.push_back(k * scale); } } - timestamps.pop_back(); + + if (!timestamps.empty()) { + timestamps.pop_back(); + } if (timestamps.size() == results[i].tokens.size()) { results[i].timestamps = std::move(timestamps);