Spaces:
Running
Running
jhj0517
commited on
Commit
•
5845bfc
1
Parent(s):
dcbe7f7
default model to None
Browse files- modules/whisper_Inference.py +11 -12
modules/whisper_Inference.py
CHANGED
@@ -10,20 +10,19 @@ DEFAULT_MODEL_SIZE = "large-v2"
|
|
10 |
|
11 |
class WhisperInference:
|
12 |
def __init__(self):
|
13 |
-
|
14 |
-
self.
|
15 |
-
self.model = whisper.load_model(name=DEFAULT_MODEL_SIZE, download_root="models/Whisper")
|
16 |
self.available_models = whisper.available_models()
|
17 |
self.available_langs = sorted(list(whisper.tokenizer.LANGUAGES.values()))
|
18 |
|
19 |
-
def transcribe_file(self, fileobjs
|
20 |
-
|
21 |
progress=gr.Progress()):
|
22 |
|
23 |
def progress_callback(progress_value):
|
24 |
progress(progress_value, desc="Transcribing..")
|
25 |
|
26 |
-
if model_size != self.current_model_size:
|
27 |
progress(0, desc="Initializing Model..")
|
28 |
self.current_model_size = model_size
|
29 |
self.model = whisper.load_model(name=model_size, download_root="models/Whisper")
|
@@ -71,14 +70,14 @@ class WhisperInference:
|
|
71 |
|
72 |
return f"Done! Subtitle is in the outputs folder.\n\n{total_result}"
|
73 |
|
74 |
-
def transcribe_youtube(self, youtubelink
|
75 |
-
|
76 |
progress=gr.Progress()):
|
77 |
|
78 |
def progress_callback(progress_value):
|
79 |
progress(progress_value, desc="Transcribing..")
|
80 |
|
81 |
-
if model_size != self.current_model_size:
|
82 |
progress(0, desc="Initializing Model..")
|
83 |
self.current_model_size = model_size
|
84 |
self.model = whisper.load_model(name=model_size, download_root="models/Whisper")
|
@@ -113,14 +112,14 @@ class WhisperInference:
|
|
113 |
|
114 |
return f"Done! Subtitle file is in the outputs folder.\n\n{subtitle}"
|
115 |
|
116 |
-
def transcribe_mic(self, micaudio
|
117 |
-
|
118 |
progress=gr.Progress()):
|
119 |
|
120 |
def progress_callback(progress_value):
|
121 |
progress(progress_value, desc="Transcribing..")
|
122 |
|
123 |
-
if model_size != self.current_model_size:
|
124 |
progress(0, desc="Initializing Model..")
|
125 |
self.current_model_size = model_size
|
126 |
self.model = whisper.load_model(name=model_size, download_root="models/Whisper")
|
|
|
10 |
|
11 |
class WhisperInference:
|
12 |
def __init__(self):
|
13 |
+
self.current_model_size = None
|
14 |
+
self.model = None
|
|
|
15 |
self.available_models = whisper.available_models()
|
16 |
self.available_langs = sorted(list(whisper.tokenizer.LANGUAGES.values()))
|
17 |
|
18 |
+
def transcribe_file(self, fileobjs,
|
19 |
+
model_size, lang, subformat, istranslate,
|
20 |
progress=gr.Progress()):
|
21 |
|
22 |
def progress_callback(progress_value):
|
23 |
progress(progress_value, desc="Transcribing..")
|
24 |
|
25 |
+
if model_size != self.current_model_size or self.model is None:
|
26 |
progress(0, desc="Initializing Model..")
|
27 |
self.current_model_size = model_size
|
28 |
self.model = whisper.load_model(name=model_size, download_root="models/Whisper")
|
|
|
70 |
|
71 |
return f"Done! Subtitle is in the outputs folder.\n\n{total_result}"
|
72 |
|
73 |
+
def transcribe_youtube(self, youtubelink,
|
74 |
+
model_size, lang, subformat, istranslate,
|
75 |
progress=gr.Progress()):
|
76 |
|
77 |
def progress_callback(progress_value):
|
78 |
progress(progress_value, desc="Transcribing..")
|
79 |
|
80 |
+
if model_size != self.current_model_size or self.model is None:
|
81 |
progress(0, desc="Initializing Model..")
|
82 |
self.current_model_size = model_size
|
83 |
self.model = whisper.load_model(name=model_size, download_root="models/Whisper")
|
|
|
112 |
|
113 |
return f"Done! Subtitle file is in the outputs folder.\n\n{subtitle}"
|
114 |
|
115 |
+
def transcribe_mic(self, micaudio,
|
116 |
+
model_size, lang, subformat, istranslate,
|
117 |
progress=gr.Progress()):
|
118 |
|
119 |
def progress_callback(progress_value):
|
120 |
progress(progress_value, desc="Transcribing..")
|
121 |
|
122 |
+
if model_size != self.current_model_size or self.model is None:
|
123 |
progress(0, desc="Initializing Model..")
|
124 |
self.current_model_size = model_size
|
125 |
self.model = whisper.load_model(name=model_size, download_root="models/Whisper")
|