@@ -166,7 +166,11 @@ def get_params(self) -> dict:
166
166
for param in dir (self ._params ):
167
167
if param .startswith ('__' ):
168
168
continue
169
- res [param ] = getattr (self ._params , param )
169
+ try :
170
+ res [param ] = getattr (self ._params , param )
171
+ except Exception :
172
+ # ignore callback functions
173
+ continue
170
174
return res
171
175
172
176
@staticmethod
@@ -224,7 +228,6 @@ def _init_model(self) -> None:
224
228
logger .info ("Initializing the model ..." )
225
229
with utils .redirect_stderr (to = self .redirect_whispercpp_logs_to ):
226
230
self ._ctx = pw .whisper_init_from_file (self .model_path )
227
- self ._params = pw .whisper_full_default_params (pw .whisper_sampling_strategy .WHISPER_SAMPLING_GREEDY )
228
231
229
232
def _set_params (self , kwargs : dict ) -> None :
230
233
"""
@@ -238,11 +241,12 @@ def _set_params(self, kwargs: dict) -> None:
238
241
def _transcribe (self , audio : np .ndarray , n_processors : int = None ):
239
242
"""
240
243
Private method to call the whisper.cpp/whisper_full function
241
-
244
+
242
245
:param audio: numpy array of audio data
243
246
:param n_processors: if not None, it will run whisper.cpp/whisper_full_parallel with n_processors
244
247
:return:
245
248
"""
249
+
246
250
if n_processors :
247
251
pw .whisper_full_parallel (self ._ctx , self ._params , audio , audio .size , n_processors )
248
252
else :
@@ -332,4 +336,4 @@ def __del__(self):
332
336
Free up resources
333
337
:return: None
334
338
"""
335
- pw .whisper_free (self ._ctx )
339
+ pw .whisper_free (self ._ctx )
0 commit comments