LAP-DEV commited on
Commit
76c7911
·
verified ·
1 Parent(s): 329d7c6

Update modules/whisper/whisper_base.py

Browse files
Files changed (1) hide show
  1. modules/whisper/whisper_base.py +10 -0
modules/whisper/whisper_base.py CHANGED
@@ -9,6 +9,7 @@ import numpy as np
9
  from datetime import datetime
10
  from faster_whisper.vad import VadOptions
11
  from dataclasses import astuple
 
12
  from copy import deepcopy
13
 
14
  from modules.uvr.music_separator import MusicSeparator
@@ -567,6 +568,15 @@ class WhisperBase(ABC):
567
  write_file(content, output_path)
568
  return content, output_path
569
 
 
 
 
 
 
 
 
 
 
570
  @staticmethod
571
  def format_time(elapsed_time: float) -> str:
572
  """
 
9
  from datetime import datetime
10
  from faster_whisper.vad import VadOptions
11
  from dataclasses import astuple
12
+ import gc
13
  from copy import deepcopy
14
 
15
  from modules.uvr.music_separator import MusicSeparator
 
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:
582
  """