@@ -107,8 +107,10 @@ class OfflineRecognizerWhisperImpl : public OfflineRecognizerImpl {
107
107
int32_t num_frames = f.size () / feat_dim;
108
108
109
109
if (num_frames > max_num_frames) {
110
- SHERPA_ONNX_LOGE (" Only waves less than 30 seconds are supported." );
111
- exit (-1 );
110
+ SHERPA_ONNX_LOGE (
111
+ " Only waves less than 30 seconds are supported. We process only the "
112
+ " first 30 seconds and discard the remaining data" );
113
+ num_frames = max_num_frames;
112
114
}
113
115
114
116
NormalizeFeatures (f.data (), num_frames, feat_dim);
@@ -124,13 +126,19 @@ class OfflineRecognizerWhisperImpl : public OfflineRecognizerImpl {
124
126
(max_num_frames - num_frames) * feat_dim * sizeof (float ));
125
127
mel = Transpose12 (model_->Allocator (), &mel);
126
128
127
- auto cross_kv = model_->ForwardEncoder (std::move (mel));
129
+ try {
130
+ auto cross_kv = model_->ForwardEncoder (std::move (mel));
128
131
129
- auto results =
130
- decoder_-> Decode ( std::move (cross_kv. first ), std::move (cross_kv.second ));
132
+ auto results = decoder_-> Decode ( std::move (cross_kv. first ),
133
+ std::move (cross_kv.second ));
131
134
132
- auto r = Convert (results[0 ], symbol_table_);
133
- s->SetResult (r);
135
+ auto r = Convert (results[0 ], symbol_table_);
136
+ s->SetResult (r);
137
+ } catch (const Ort::Exception &ex) {
138
+ SHERPA_ONNX_LOGE (" \n\n Caught exception:\n\n %s\n\n Return an empty result" ,
139
+ ex.what ());
140
+ return ;
141
+ }
134
142
}
135
143
136
144
private:
0 commit comments