LAP-DEV commited on
Commit
935bb7e
·
verified ·
1 Parent(s): ca69945

Update modules/whisper/whisper_base.py

Browse files
Files changed (1) hide show
  1. modules/whisper/whisper_base.py +15 -17
modules/whisper/whisper_base.py CHANGED
@@ -408,24 +408,22 @@ class WhisperBase(ABC):
408
 
409
  if file_count_total > 1:
410
  if file_count > 1:
411
- total_result += "#NEWLINE#"
412
 
413
  # Add filename & info as first line
414
- tabbed_space = ("\t")*3
415
- title_line = f'{tabbed_space}Media file:\t{info["input_source_file"]}'
416
- title_line += f'\n{tabbed_space}Language:\t{info["lang"]} (probability {info["lang_prob"]}%)'
417
- if params.is_translate: title_line += f'\n{tabbed_space}Translation:\t{info["transcription"]} (Handled by OpenAI Whisper)'
418
- if translate_output: title_line += f'\n{tabbed_space}Translation:\t{info["translation"]} (Handled by Facebook NLLB)'
419
-
420
- temp_subtitle = info["subtitle"]
421
- if temp_subtitle.strip() == "":
422
- temp_subtitle = "(No speech detected)"
423
-
424
- total_result += title_line+"#NEWLINE#"+(((temp_subtitle.rstrip("\n")).replace("\t","#TAB#")).replace("\n","#NEWLINE#"))
 
425
  total_time += info["time_for_task"]
426
-
427
- total_result = total_result.replace("\t"," ")
428
- total_result = total_result.replace("\n","<BR>")
429
 
430
  time_end = datetime.now()
431
  total_info = f"Processed {file_count} {'file' if file_count == 1 else 'files'} in {self.format_time((time_end-time_start).total_seconds())}"
@@ -631,9 +629,9 @@ class WhisperBase(ABC):
631
  @staticmethod
632
  def transform_text_to_list(inputdata: str) -> list:
633
  outputdata = []
634
- temp_inputdata = inputdata.split("#NEWLINE#")
635
  for temp_line in temp_inputdata:
636
- temp_line_items = temp_line.split("#TAB#")
637
  col_time,col_speaker,col_text = "","",""
638
 
639
  if len(temp_line_items)==1:
 
408
 
409
  if file_count_total > 1:
410
  if file_count > 1:
411
+ total_result += "\n"
412
 
413
  # Add filename & info as first line
414
+ html_multi_tab = ("&nbsp;")*3
415
+ html_single_tab = "&nbsp;"
416
+ html_newline = "<BR>"
417
+ title_line = f'{html_multi_tab}Media file:{html_single_tab}{info["input_source_file"]}'
418
+ title_line += f'{html_newline}{html_multi_tab}Language:{html_single_tab}{info["lang"]} (probability {info["lang_prob"]}%)'
419
+ if params.is_translate: title_line += f'{html_newline}{html_multi_tab}Translation:{html_single_tab}{info["transcription"]} (Handled by OpenAI Whisper)'
420
+ if translate_output: title_line += f'{html_newline}{html_multi_tab}Translation:{html_single_tab}{info["translation"]} (Handled by Facebook NLLB)'
421
+
422
+ if info["subtitle"] == "":
423
+ info["subtitle"] = "(No speech detected)"
424
+
425
+ total_result += title_line+"\n"+f'{info["subtitle"]}'
426
  total_time += info["time_for_task"]
 
 
 
427
 
428
  time_end = datetime.now()
429
  total_info = f"Processed {file_count} {'file' if file_count == 1 else 'files'} in {self.format_time((time_end-time_start).total_seconds())}"
 
629
  @staticmethod
630
  def transform_text_to_list(inputdata: str) -> list:
631
  outputdata = []
632
+ temp_inputdata = inputdata.split("\n")
633
  for temp_line in temp_inputdata:
634
+ temp_line_items = temp_line.split("\t")
635
  col_time,col_speaker,col_text = "","",""
636
 
637
  if len(temp_line_items)==1: