Committed by
GitHub
Catch exception from non-streaming paraformer. (#307)
正在显示
1 个修改的文件
包含
8 行增加
和
1 行删除
| @@ -184,7 +184,14 @@ class OfflineRecognizerParaformerImpl : public OfflineRecognizerImpl { | @@ -184,7 +184,14 @@ class OfflineRecognizerParaformerImpl : public OfflineRecognizerImpl { | ||
| 184 | // i.e., -23.025850929940457f | 184 | // i.e., -23.025850929940457f |
| 185 | Ort::Value x = PadSequence(model_->Allocator(), features_pointer, 0); | 185 | Ort::Value x = PadSequence(model_->Allocator(), features_pointer, 0); |
| 186 | 186 | ||
| 187 | - auto t = model_->Forward(std::move(x), std::move(x_length)); | 187 | + std::pair<Ort::Value, Ort::Value> t{nullptr, nullptr}; |
| 188 | + try { | ||
| 189 | + t = model_->Forward(std::move(x), std::move(x_length)); | ||
| 190 | + } catch (const Ort::Exception &ex) { | ||
| 191 | + SHERPA_ONNX_LOGE("\n\nCaught exception:\n\n%s\n\nReturn an empty result", | ||
| 192 | + ex.what()); | ||
| 193 | + return; | ||
| 194 | + } | ||
| 188 | 195 | ||
| 189 | auto results = decoder_->Decode(std::move(t.first), std::move(t.second)); | 196 | auto results = decoder_->Decode(std::move(t.first), std::move(t.second)); |
| 190 | 197 |
-
请 注册 或 登录 后发表评论