Update modules/whisper/whisper_base.py
Browse files
modules/whisper/whisper_base.py
CHANGED
@@ -226,16 +226,17 @@ class WhisperBase(ABC):
|
|
226 |
if files and isinstance(files[0], gr.utils.NamedString):
|
227 |
files = [file.name for file in files]
|
228 |
|
|
|
|
|
|
|
|
|
|
|
229 |
## Load parameters related with whisper
|
230 |
params = WhisperParameters.as_value(*whisper_params)
|
231 |
|
232 |
## Load model to detect language
|
233 |
model = whisper.load_model("base")
|
234 |
|
235 |
-
files_info = {}
|
236 |
-
files_to_download = {}
|
237 |
-
time_start = datetime.now()
|
238 |
-
|
239 |
for file in files:
|
240 |
|
241 |
## Detect language
|
@@ -331,17 +332,16 @@ class WhisperBase(ABC):
|
|
331 |
for file_name, info in files_info.items():
|
332 |
total_result += f'{info["subtitle"]}'
|
333 |
total_time += info["time_for_task"]
|
334 |
-
total_info += f'Input file: {info["input_source_file"]}\nLanguage: {info["lang"]} (Probability {info["lang_prob"]}%)\n'
|
335 |
|
336 |
if params.is_translate:
|
337 |
-
total_info += f'Translation: {info["transcription"]}\n'
|
338 |
|
339 |
if translate_output:
|
340 |
-
total_info += f'Translation: {info["translation"]}\n'
|
341 |
|
342 |
-
#total_info += f"\nTranscription duration: {self.format_time(total_time)}"
|
343 |
time_end = datetime.now()
|
344 |
-
total_info += f"\
|
345 |
|
346 |
result_str = total_result.rstrip("\n")
|
347 |
result_file_path = [info['path'] for info in files_to_download.values()]
|
|
|
226 |
if files and isinstance(files[0], gr.utils.NamedString):
|
227 |
files = [file.name for file in files]
|
228 |
|
229 |
+
## Initialization variables & start time
|
230 |
+
files_info = {}
|
231 |
+
files_to_download = {}
|
232 |
+
time_start = datetime.now()
|
233 |
+
|
234 |
## Load parameters related with whisper
|
235 |
params = WhisperParameters.as_value(*whisper_params)
|
236 |
|
237 |
## Load model to detect language
|
238 |
model = whisper.load_model("base")
|
239 |
|
|
|
|
|
|
|
|
|
240 |
for file in files:
|
241 |
|
242 |
## Detect language
|
|
|
332 |
for file_name, info in files_info.items():
|
333 |
total_result += f'{info["subtitle"]}'
|
334 |
total_time += info["time_for_task"]
|
335 |
+
total_info += f'Input file\t: {info["input_source_file"]}\nLanguage\t: {info["lang"]} (Probability {info["lang_prob"]}%)\n'
|
336 |
|
337 |
if params.is_translate:
|
338 |
+
total_info += f'Translation\t: {info["transcription"]}\n'
|
339 |
|
340 |
if translate_output:
|
341 |
+
total_info += f'Translation\t: {info["translation"]}\n'
|
342 |
|
|
|
343 |
time_end = datetime.now()
|
344 |
+
total_info += f"\nProcessing time\t: {self.format_time((time_end-time_start).total_seconds())}"
|
345 |
|
346 |
result_str = total_result.rstrip("\n")
|
347 |
result_file_path = [info['path'] for info in files_to_download.values()]
|