Update modules/whisper/whisper_base.py
Browse files- modules/whisper/whisper_base.py +10 -10
modules/whisper/whisper_base.py
CHANGED
@@ -174,8 +174,8 @@ class WhisperBase(ABC):
|
|
174 |
progress,
|
175 |
*astuple(params)
|
176 |
)
|
177 |
-
|
178 |
-
|
179 |
|
180 |
if params.vad_filter:
|
181 |
restored_result = self.vad.restore_speech_timestamps(
|
@@ -568,14 +568,14 @@ class WhisperBase(ABC):
|
|
568 |
write_file(content, output_path)
|
569 |
return content, output_path
|
570 |
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
|
580 |
@staticmethod
|
581 |
def format_time(elapsed_time: float) -> str:
|
|
|
174 |
progress,
|
175 |
*astuple(params)
|
176 |
)
|
177 |
+
if bool_whisper_enable_offload:
|
178 |
+
self.offload()
|
179 |
|
180 |
if params.vad_filter:
|
181 |
restored_result = self.vad.restore_speech_timestamps(
|
|
|
568 |
write_file(content, output_path)
|
569 |
return content, output_path
|
570 |
|
571 |
+
def offload(self):
|
572 |
+
"""Offload the model and free up the memory"""
|
573 |
+
if self.model is not None:
|
574 |
+
del self.model
|
575 |
+
self.model = None
|
576 |
+
if self.device == "cuda":
|
577 |
+
self.release_cuda_memory()
|
578 |
+
gc.collect()
|
579 |
|
580 |
@staticmethod
|
581 |
def format_time(elapsed_time: float) -> str:
|