LAP-DEV commited on
Commit
798dc27
·
verified ·
1 Parent(s): 692f1bc

Update modules/whisper/whisper_base.py

Browse files
Files changed (1) hide show
  1. modules/whisper/whisper_base.py +7 -6
modules/whisper/whisper_base.py CHANGED
@@ -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)}),result_file_path,total_info]
428
  #return [result_str,result_file_path,total_info]
429
 
430
  except Exception as e:
@@ -618,17 +618,18 @@ class WhisperBase(ABC):
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_list = []
626
  temp_line_items = temp_line.split("#TAB#")
627
 
628
- # Add tabs to match Dataframe columns
629
- count_items = len(temp_line_items)
630
- while len(temp_line_items)<3:
631
- temp_line_items.insert(0,"")
 
632
 
633
  for temp_line_item in temp_line_items:
634
  temp_line_list.append(temp_line_item)
 
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,add_timestamp_preview,diarize_speakers)}),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,timestamps: bool, diarize: bool) -> list:
622
  outputdata = []
623
  temp_inputdata = inputdata.split("#NEWLINE#")
624
  for temp_line in temp_inputdata:
625
  temp_line_list = []
626
  temp_line_items = temp_line.split("#TAB#")
627
 
628
+ # Add columns to match Dataframe
629
+ if timestamps==True and diarize==False:
630
+ temp_line_items.insert(1,"")
631
+ if timestamps==False and diarize==True:
632
+ temp_line_items.insert(0,"")
633
 
634
  for temp_line_item in temp_line_items:
635
  temp_line_list.append(temp_line_item)