Update modules/whisper/whisper_base.py
Browse files- modules/whisper/whisper_base.py +12 -33
modules/whisper/whisper_base.py
CHANGED
@@ -236,7 +236,7 @@ class WhisperBase(ABC):
|
|
236 |
def transcribe_file(self,
|
237 |
files: Optional[List] = None,
|
238 |
input_folder_path: Optional[str] = None,
|
239 |
-
file_format:
|
240 |
add_timestamp: bool = True,
|
241 |
translate_output: bool = False,
|
242 |
translate_model: str = "",
|
@@ -359,39 +359,18 @@ class WhisperBase(ABC):
|
|
359 |
subtitle = get_plaintext(transcribed_segments)
|
360 |
files_info[file_name] = {"subtitle": subtitle, "time_for_task": time_for_task, "lang": file_language, "lang_prob": file_lang_probs, "input_source_file": (file_name+file_ext), "translation": translation_note, "transcription": transcription_note}
|
361 |
|
362 |
-
## Add output file as txt
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
|
|
372 |
|
373 |
-
## Add output file as srt
|
374 |
-
file_name, file_ext = os.path.splitext(os.path.basename(file))
|
375 |
-
subtitle, file_path = self.generate_and_write_file(
|
376 |
-
file_name=file_name,
|
377 |
-
transcribed_segments=transcribed_segments,
|
378 |
-
add_timestamp=add_timestamp,
|
379 |
-
file_format="srt",
|
380 |
-
output_dir=self.output_dir
|
381 |
-
)
|
382 |
-
files_to_download[file_name+"_srt"] = {"path": file_path}
|
383 |
-
|
384 |
-
## Add output file as csv
|
385 |
-
file_name, file_ext = os.path.splitext(os.path.basename(file))
|
386 |
-
subtitle, file_path = self.generate_and_write_file(
|
387 |
-
file_name=file_name,
|
388 |
-
transcribed_segments=transcribed_segments,
|
389 |
-
add_timestamp=add_timestamp,
|
390 |
-
file_format="csv",
|
391 |
-
output_dir=self.output_dir
|
392 |
-
)
|
393 |
-
files_to_download[file_name+"_csv"] = {"path": file_path}
|
394 |
-
|
395 |
total_result = ""
|
396 |
total_info = ""
|
397 |
total_time = 0
|
|
|
236 |
def transcribe_file(self,
|
237 |
files: Optional[List] = None,
|
238 |
input_folder_path: Optional[str] = None,
|
239 |
+
file_format: list = ["CSV"],
|
240 |
add_timestamp: bool = True,
|
241 |
translate_output: bool = False,
|
242 |
translate_model: str = "",
|
|
|
359 |
subtitle = get_plaintext(transcribed_segments)
|
360 |
files_info[file_name] = {"subtitle": subtitle, "time_for_task": time_for_task, "lang": file_language, "lang_prob": file_lang_probs, "input_source_file": (file_name+file_ext), "translation": translation_note, "transcription": transcription_note}
|
361 |
|
362 |
+
## Add output file as txt, srt and/or csv
|
363 |
+
for format in file_format:
|
364 |
+
file_name, file_ext = os.path.splitext(os.path.basename(file))
|
365 |
+
subtitle, file_path = self.generate_and_write_file(
|
366 |
+
file_name=file_name,
|
367 |
+
transcribed_segments=transcribed_segments,
|
368 |
+
add_timestamp=add_timestamp,
|
369 |
+
file_format=format.lower(),
|
370 |
+
output_dir=self.output_dir
|
371 |
+
)
|
372 |
+
files_to_download[file_name+"_"+format.lower()] = {"path": file_path}
|
373 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
374 |
total_result = ""
|
375 |
total_info = ""
|
376 |
total_time = 0
|