From 0500d4f67ebba3bc9f420d5138f9bbd6c8c2c51e Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Tue, 12 Sep 2023 16:37:00 +0800 Subject: [PATCH 1/2] Catch exception from non-streaming paraformer. --- sherpa-onnx/csrc/offline-recognizer-paraformer-impl.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sherpa-onnx/csrc/offline-recognizer-paraformer-impl.h b/sherpa-onnx/csrc/offline-recognizer-paraformer-impl.h index 15f9830d3..e57b38489 100644 --- a/sherpa-onnx/csrc/offline-recognizer-paraformer-impl.h +++ b/sherpa-onnx/csrc/offline-recognizer-paraformer-impl.h @@ -184,7 +184,14 @@ class OfflineRecognizerParaformerImpl : public OfflineRecognizerImpl { // i.e., -23.025850929940457f Ort::Value x = PadSequence(model_->Allocator(), features_pointer, 0); - auto t = model_->Forward(std::move(x), std::move(x_length)); + std::pair t{nullptr, nullptr}; + try { + t = model_->Forward(std::move(x), std::move(x_length)); + } catch (const Ort::Exception &ex) { + SHERPA_ONNX_LOGE("\n\nCaught exception:\n\n%s\n\nReturn empty result", + ex.what()); + return; + } auto results = decoder_->Decode(std::move(t.first), std::move(t.second)); From a6674eb8cbed41fa0fd09434e9aaa9e313133328 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Tue, 12 Sep 2023 16:42:58 +0800 Subject: [PATCH 2/2] fix a typo --- sherpa-onnx/csrc/offline-recognizer-paraformer-impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sherpa-onnx/csrc/offline-recognizer-paraformer-impl.h b/sherpa-onnx/csrc/offline-recognizer-paraformer-impl.h index e57b38489..9d7186124 100644 --- a/sherpa-onnx/csrc/offline-recognizer-paraformer-impl.h +++ b/sherpa-onnx/csrc/offline-recognizer-paraformer-impl.h @@ -188,7 +188,7 @@ class OfflineRecognizerParaformerImpl : public OfflineRecognizerImpl { try { t = model_->Forward(std::move(x), std::move(x_length)); } catch (const Ort::Exception &ex) { - SHERPA_ONNX_LOGE("\n\nCaught exception:\n\n%s\n\nReturn empty result", + SHERPA_ONNX_LOGE("\n\nCaught exception:\n\n%s\n\nReturn an empty result", ex.what()); return; }