Spaces:
Running
Running
jhj0517
commited on
Commit
·
b5773e7
1
Parent(s):
7baa848
Update syntax
Browse files
modules/whisper/whisper_base.py
CHANGED
@@ -122,10 +122,10 @@ class WhisperBase(ABC):
|
|
122 |
|
123 |
if audio.ndim >= 2:
|
124 |
audio = audio.mean(axis=1)
|
125 |
-
if self.music_separator.audio_info is
|
126 |
-
origin_sample_rate = self.music_separator.audio_info.sample_rate
|
127 |
-
else:
|
128 |
origin_sample_rate = 16000
|
|
|
|
|
129 |
audio = self.resample_audio(audio=audio, original_sample_rate=origin_sample_rate)
|
130 |
|
131 |
self.music_separator.offload()
|
@@ -460,12 +460,14 @@ class WhisperBase(ABC):
|
|
460 |
|
461 |
@staticmethod
|
462 |
def release_cuda_memory():
|
|
|
463 |
if torch.cuda.is_available():
|
464 |
torch.cuda.empty_cache()
|
465 |
torch.cuda.reset_max_memory_allocated()
|
466 |
|
467 |
@staticmethod
|
468 |
def remove_input_files(file_paths: List[str]):
|
|
|
469 |
if not file_paths:
|
470 |
return
|
471 |
|
@@ -478,6 +480,7 @@ class WhisperBase(ABC):
|
|
478 |
whisper_params: WhisperValues,
|
479 |
add_timestamp: bool
|
480 |
):
|
|
|
481 |
cached_params = load_yaml(DEFAULT_PARAMETERS_CONFIG_PATH)
|
482 |
cached_whisper_param = whisper_params.to_yaml()
|
483 |
cached_yaml = {**cached_params, **cached_whisper_param}
|
|
|
122 |
|
123 |
if audio.ndim >= 2:
|
124 |
audio = audio.mean(axis=1)
|
125 |
+
if self.music_separator.audio_info is None:
|
|
|
|
|
126 |
origin_sample_rate = 16000
|
127 |
+
else:
|
128 |
+
origin_sample_rate = self.music_separator.audio_info.sample_rate
|
129 |
audio = self.resample_audio(audio=audio, original_sample_rate=origin_sample_rate)
|
130 |
|
131 |
self.music_separator.offload()
|
|
|
460 |
|
461 |
@staticmethod
|
462 |
def release_cuda_memory():
|
463 |
+
"""Release memory"""
|
464 |
if torch.cuda.is_available():
|
465 |
torch.cuda.empty_cache()
|
466 |
torch.cuda.reset_max_memory_allocated()
|
467 |
|
468 |
@staticmethod
|
469 |
def remove_input_files(file_paths: List[str]):
|
470 |
+
"""Remove gradio cached files"""
|
471 |
if not file_paths:
|
472 |
return
|
473 |
|
|
|
480 |
whisper_params: WhisperValues,
|
481 |
add_timestamp: bool
|
482 |
):
|
483 |
+
"""cache parameters to the yaml file"""
|
484 |
cached_params = load_yaml(DEFAULT_PARAMETERS_CONFIG_PATH)
|
485 |
cached_whisper_param = whisper_params.to_yaml()
|
486 |
cached_yaml = {**cached_params, **cached_whisper_param}
|