Spaces:
Running
Running
jhj0517
commited on
Commit
·
ea1ae52
1
Parent(s):
5cce7db
remove annotation
Browse files
modules/whisper/faster_whisper_inference.py
CHANGED
@@ -9,7 +9,7 @@ import ctranslate2
|
|
9 |
import whisper
|
10 |
import gradio as gr
|
11 |
from argparse import Namespace
|
12 |
-
import spaces
|
13 |
|
14 |
from modules.whisper.whisper_parameter import *
|
15 |
from modules.whisper.whisper_base import WhisperBase
|
@@ -32,7 +32,7 @@ class FasterWhisperInference(WhisperBase):
|
|
32 |
self.available_compute_types = self.get_available_compute_type()
|
33 |
self.download_model(model_size="large-v2", model_dir=self.model_dir)
|
34 |
|
35 |
-
|
36 |
def transcribe(self,
|
37 |
audio: Union[str, BinaryIO, np.ndarray],
|
38 |
progress: gr.Progress,
|
@@ -90,7 +90,7 @@ class FasterWhisperInference(WhisperBase):
|
|
90 |
elapsed_time = time.time() - start_time
|
91 |
return segments_result, elapsed_time
|
92 |
|
93 |
-
|
94 |
def update_model(self,
|
95 |
model_size: str,
|
96 |
compute_type: str,
|
@@ -149,8 +149,8 @@ class FasterWhisperInference(WhisperBase):
|
|
149 |
return ['float32', 'int8_float16', 'float16', 'int8', 'int8_float32']
|
150 |
return ['int16', 'float32', 'int8', 'int8_float32']
|
151 |
|
|
|
152 |
@staticmethod
|
153 |
-
@spaces.GPU(duration=120)
|
154 |
def get_device():
|
155 |
if torch.cuda.is_available():
|
156 |
return "cuda"
|
|
|
9 |
import whisper
|
10 |
import gradio as gr
|
11 |
from argparse import Namespace
|
12 |
+
#import spaces
|
13 |
|
14 |
from modules.whisper.whisper_parameter import *
|
15 |
from modules.whisper.whisper_base import WhisperBase
|
|
|
32 |
self.available_compute_types = self.get_available_compute_type()
|
33 |
self.download_model(model_size="large-v2", model_dir=self.model_dir)
|
34 |
|
35 |
+
#@spaces.GPU(duration=120)
|
36 |
def transcribe(self,
|
37 |
audio: Union[str, BinaryIO, np.ndarray],
|
38 |
progress: gr.Progress,
|
|
|
90 |
elapsed_time = time.time() - start_time
|
91 |
return segments_result, elapsed_time
|
92 |
|
93 |
+
#@spaces.GPU(duration=120)
|
94 |
def update_model(self,
|
95 |
model_size: str,
|
96 |
compute_type: str,
|
|
|
149 |
return ['float32', 'int8_float16', 'float16', 'int8', 'int8_float32']
|
150 |
return ['int16', 'float32', 'int8', 'int8_float32']
|
151 |
|
152 |
+
#@spaces.GPU(duration=120)
|
153 |
@staticmethod
|
|
|
154 |
def get_device():
|
155 |
if torch.cuda.is_available():
|
156 |
return "cuda"
|
modules/whisper/whisper_base.py
CHANGED
@@ -42,7 +42,7 @@ class WhisperBase(ABC):
|
|
42 |
self.vad = SileroVAD()
|
43 |
|
44 |
@abstractmethod
|
45 |
-
|
46 |
def transcribe(self,
|
47 |
audio: Union[str, BinaryIO, np.ndarray],
|
48 |
progress: gr.Progress,
|
@@ -51,7 +51,7 @@ class WhisperBase(ABC):
|
|
51 |
pass
|
52 |
|
53 |
@abstractmethod
|
54 |
-
|
55 |
def update_model(self,
|
56 |
model_size: str,
|
57 |
compute_type: str,
|
@@ -59,7 +59,7 @@ class WhisperBase(ABC):
|
|
59 |
):
|
60 |
pass
|
61 |
|
62 |
-
|
63 |
def run(self,
|
64 |
audio: Union[str, BinaryIO, np.ndarray],
|
65 |
progress: gr.Progress,
|
@@ -196,7 +196,7 @@ class WhisperBase(ABC):
|
|
196 |
if not files:
|
197 |
self.remove_input_files([file.name for file in files])
|
198 |
|
199 |
-
|
200 |
def transcribe_mic(self,
|
201 |
mic_audio: str,
|
202 |
file_format: str,
|
@@ -249,7 +249,7 @@ class WhisperBase(ABC):
|
|
249 |
self.release_cuda_memory()
|
250 |
self.remove_input_files([mic_audio])
|
251 |
|
252 |
-
|
253 |
def transcribe_youtube(self,
|
254 |
youtube_link: str,
|
255 |
file_format: str,
|
@@ -400,7 +400,7 @@ class WhisperBase(ABC):
|
|
400 |
return time_str.strip()
|
401 |
|
402 |
@staticmethod
|
403 |
-
|
404 |
def get_device():
|
405 |
if torch.cuda.is_available():
|
406 |
return "cuda"
|
@@ -410,7 +410,7 @@ class WhisperBase(ABC):
|
|
410 |
return "cpu"
|
411 |
|
412 |
@staticmethod
|
413 |
-
|
414 |
def release_cuda_memory():
|
415 |
if torch.cuda.is_available():
|
416 |
torch.cuda.empty_cache()
|
|
|
42 |
self.vad = SileroVAD()
|
43 |
|
44 |
@abstractmethod
|
45 |
+
#@spaces.GPU(duration=120)
|
46 |
def transcribe(self,
|
47 |
audio: Union[str, BinaryIO, np.ndarray],
|
48 |
progress: gr.Progress,
|
|
|
51 |
pass
|
52 |
|
53 |
@abstractmethod
|
54 |
+
#@spaces.GPU(duration=120)
|
55 |
def update_model(self,
|
56 |
model_size: str,
|
57 |
compute_type: str,
|
|
|
59 |
):
|
60 |
pass
|
61 |
|
62 |
+
#@spaces.GPU(duration=120)
|
63 |
def run(self,
|
64 |
audio: Union[str, BinaryIO, np.ndarray],
|
65 |
progress: gr.Progress,
|
|
|
196 |
if not files:
|
197 |
self.remove_input_files([file.name for file in files])
|
198 |
|
199 |
+
#@spaces.GPU(duration=120)
|
200 |
def transcribe_mic(self,
|
201 |
mic_audio: str,
|
202 |
file_format: str,
|
|
|
249 |
self.release_cuda_memory()
|
250 |
self.remove_input_files([mic_audio])
|
251 |
|
252 |
+
#@spaces.GPU(duration=120)
|
253 |
def transcribe_youtube(self,
|
254 |
youtube_link: str,
|
255 |
file_format: str,
|
|
|
400 |
return time_str.strip()
|
401 |
|
402 |
@staticmethod
|
403 |
+
#@spaces.GPU(duration=120)
|
404 |
def get_device():
|
405 |
if torch.cuda.is_available():
|
406 |
return "cuda"
|
|
|
410 |
return "cpu"
|
411 |
|
412 |
@staticmethod
|
413 |
+
#@spaces.GPU(duration=120)
|
414 |
def release_cuda_memory():
|
415 |
if torch.cuda.is_available():
|
416 |
torch.cuda.empty_cache()
|