Skip to content

Commit

Permalink
Catch exception from non-streaming paraformer. (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj authored Sep 12, 2023
1 parent debab7c commit d46b7ec
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sherpa-onnx/csrc/offline-recognizer-paraformer-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Ort::Value, Ort::Value> 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));

Expand Down

0 comments on commit d46b7ec

Please sign in to comment.