Update modules/whisper/whisper_base.py
Browse files- modules/whisper/whisper_base.py +12 -17
modules/whisper/whisper_base.py
CHANGED
@@ -296,9 +296,6 @@ class WhisperBase(ABC):
|
|
296 |
file_count_total = 0
|
297 |
process_multiple = False
|
298 |
files = ""
|
299 |
-
|
300 |
-
char_tab = "#TAB#"
|
301 |
-
char_newline = "#NEWLINE#"
|
302 |
|
303 |
if input_multi == "Audio":
|
304 |
files = files_audio
|
@@ -414,16 +411,16 @@ class WhisperBase(ABC):
|
|
414 |
|
415 |
# Add filename & info as first line
|
416 |
title_line = ""
|
417 |
-
tabbed_space =
|
418 |
-
if add_timestamp_preview: title_line +=
|
419 |
-
if diarize_speakers: title_line +=
|
420 |
-
title_line += f'{tabbed_space}Media file:{
|
421 |
-
title_line += f'{
|
422 |
-
if params.is_translate: title_line += f'{
|
423 |
-
if translate_output: title_line += f'{
|
424 |
-
title_line +=
|
425 |
-
|
426 |
-
total_result += title_line+info["subtitle"]
|
427 |
total_time += info["time_for_task"]
|
428 |
|
429 |
time_end = datetime.now()
|
@@ -431,8 +428,6 @@ class WhisperBase(ABC):
|
|
431 |
#total_info += f"Total processing time:\t{self.format_time((time_end-time_start).total_seconds())}"
|
432 |
|
433 |
result_str = self.transform_text_to_list(total_result) #Transform to gr.Dataframe format
|
434 |
-
result_str = result_str.replace(char_tab,"\t")
|
435 |
-
result_str = result_str.replace(char_newline,"\n")
|
436 |
result_file_path = [info['path'] for info in files_to_download.values()]
|
437 |
|
438 |
return [result_str,result_file_path,total_info]
|
@@ -630,10 +625,10 @@ class WhisperBase(ABC):
|
|
630 |
@staticmethod
|
631 |
def transform_text_to_list(inputdata: str) -> list:
|
632 |
outputdata = []
|
633 |
-
temp_inputdata = inputdata.split("
|
634 |
for temp_line in temp_inputdata:
|
635 |
temp_line_list = []
|
636 |
-
temp_line_items = temp_line.split("
|
637 |
for temp_line_item in temp_line_items:
|
638 |
temp_line_list.append(temp_line_item)
|
639 |
outputdata.append(temp_line_list)
|
|
|
296 |
file_count_total = 0
|
297 |
process_multiple = False
|
298 |
files = ""
|
|
|
|
|
|
|
299 |
|
300 |
if input_multi == "Audio":
|
301 |
files = files_audio
|
|
|
411 |
|
412 |
# Add filename & info as first line
|
413 |
title_line = ""
|
414 |
+
tabbed_space = "\t"*3
|
415 |
+
if add_timestamp_preview: title_line += "#TAB#"
|
416 |
+
if diarize_speakers: title_line += "#TAB#"
|
417 |
+
title_line += f'{tabbed_space}Media file:"\t{info["input_source_file"]}'
|
418 |
+
title_line += f'\n{tabbed_space}Language:\t{info["lang"]} (probability {info["lang_prob"]}%)'
|
419 |
+
if params.is_translate: title_line += f'\n{tabbed_space}Translation:\t{info["transcription"]} (Handled by OpenAI Whisper)'
|
420 |
+
if translate_output: title_line += f'\n{tabbed_space}Translation:\t{info["translation"]} (Handled by Facebook NLLB)'
|
421 |
+
title_line += "#NEWLINE#"
|
422 |
+
|
423 |
+
total_result += title_line+(info["subtitle"].replace("\t","#TAB#")).replace("\n","#NEWLINE#"))
|
424 |
total_time += info["time_for_task"]
|
425 |
|
426 |
time_end = datetime.now()
|
|
|
428 |
#total_info += f"Total processing time:\t{self.format_time((time_end-time_start).total_seconds())}"
|
429 |
|
430 |
result_str = self.transform_text_to_list(total_result) #Transform to gr.Dataframe format
|
|
|
|
|
431 |
result_file_path = [info['path'] for info in files_to_download.values()]
|
432 |
|
433 |
return [result_str,result_file_path,total_info]
|
|
|
625 |
@staticmethod
|
626 |
def transform_text_to_list(inputdata: str) -> list:
|
627 |
outputdata = []
|
628 |
+
temp_inputdata = inputdata.split("#NEWLINE#")
|
629 |
for temp_line in temp_inputdata:
|
630 |
temp_line_list = []
|
631 |
+
temp_line_items = temp_line.split("#TAB#")
|
632 |
for temp_line_item in temp_line_items:
|
633 |
temp_line_list.append(temp_line_item)
|
634 |
outputdata.append(temp_line_list)
|