Update modules/whisper/whisper_base.py
Browse files- modules/whisper/whisper_base.py +24 -18
modules/whisper/whisper_base.py
CHANGED
@@ -416,7 +416,7 @@ class WhisperBase(ABC):
|
|
416 |
if params.is_translate: title_line += f'\n{tabbed_space}Translation:\t{info["transcription"]} (Handled by OpenAI Whisper)'
|
417 |
if translate_output: title_line += f'\n{tabbed_space}Translation:\t{info["translation"]} (Handled by Facebook NLLB)'
|
418 |
|
419 |
-
total_result +=
|
420 |
total_time += info["time_for_task"]
|
421 |
|
422 |
time_end = datetime.now()
|
@@ -424,7 +424,7 @@ class WhisperBase(ABC):
|
|
424 |
result_file_path = [info['path'] for info in files_to_download.values()]
|
425 |
#total_info += f"Total processing time:\t{self.format_time((time_end-time_start).total_seconds())}"
|
426 |
|
427 |
-
return [gr.update(value={"data": self.transform_text_to_list(total_result
|
428 |
#return [result_str,result_file_path,total_info]
|
429 |
|
430 |
except Exception as e:
|
@@ -618,23 +618,29 @@ class WhisperBase(ABC):
|
|
618 |
gc.collect()
|
619 |
|
620 |
@staticmethod
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
|
|
|
|
|
|
|
|
636 |
|
637 |
-
|
|
|
|
|
638 |
|
639 |
@staticmethod
|
640 |
def format_time(elapsed_time: float) -> str:
|
|
|
416 |
if params.is_translate: title_line += f'\n{tabbed_space}Translation:\t{info["transcription"]} (Handled by OpenAI Whisper)'
|
417 |
if translate_output: title_line += f'\n{tabbed_space}Translation:\t{info["translation"]} (Handled by Facebook NLLB)'
|
418 |
|
419 |
+
total_result += title_line+"#NEWLINE#"+(((info["subtitle"].rstrip("\n")).replace("\t","#TAB#")).replace("\n","#NEWLINE#"))
|
420 |
total_time += info["time_for_task"]
|
421 |
|
422 |
time_end = datetime.now()
|
|
|
424 |
result_file_path = [info['path'] for info in files_to_download.values()]
|
425 |
#total_info += f"Total processing time:\t{self.format_time((time_end-time_start).total_seconds())}"
|
426 |
|
427 |
+
return [gr.update(value={"data": self.transform_text_to_list(total_result)}),result_file_path,total_info]
|
428 |
#return [result_str,result_file_path,total_info]
|
429 |
|
430 |
except Exception as e:
|
|
|
618 |
gc.collect()
|
619 |
|
620 |
@staticmethod
|
621 |
+
def transform_text_to_list(inputdata: str) -> list:
|
622 |
+
outputdata = []
|
623 |
+
temp_inputdata = inputdata.split("#NEWLINE#")
|
624 |
+
for temp_line in temp_inputdata:
|
625 |
+
temp_line_items = temp_line.split("#TAB#")
|
626 |
+
col_time,col_speaker,col_text = "","",""
|
627 |
+
|
628 |
+
if len(temp_line_items)==1:
|
629 |
+
col_text = temp_line_items[0]
|
630 |
+
if len(temp_line_items)==2:
|
631 |
+
if (temp_line_items[0])[0].isdigit():
|
632 |
+
col_time = temp_line_items[0]
|
633 |
+
else:
|
634 |
+
col_speaker = temp_line_items[0]
|
635 |
+
col_text = temp_line_items[1]
|
636 |
+
if len(temp_line_items)==3:
|
637 |
+
col_time = temp_line_items[0]
|
638 |
+
col_speaker = temp_line_items[1]
|
639 |
+
col_text = temp_line_items[2]
|
640 |
|
641 |
+
outputdata.append([col_time,col_speaker,col_text])
|
642 |
+
|
643 |
+
return outputdata
|
644 |
|
645 |
@staticmethod
|
646 |
def format_time(elapsed_time: float) -> str:
|