diff --git a/sherpa-onnx/csrc/offline-recognizer-paraformer-impl.h b/sherpa-onnx/csrc/offline-recognizer-paraformer-impl.h index 15f9830d3..9d7186124 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 an empty result", + ex.what()); + return; + } auto results = decoder_->Decode(std::move(t.first), std::move(t.second));