Update modules/whisper/whisper_base.py
Browse files
modules/whisper/whisper_base.py
CHANGED
@@ -269,6 +269,12 @@ class WhisperBase(ABC):
|
|
269 |
#)
|
270 |
#files_info[file_name] = {"subtitle": subtitle, "time_for_task": time_for_task, "path": file_path, "lang": file_language, "lang_prob": file_lang_probs, "input_source_file": (file_name+file_ext)}
|
271 |
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
# Translate the transcribed segments
|
273 |
translation_note = ""
|
274 |
if translate_output:
|
@@ -288,7 +294,7 @@ class WhisperBase(ABC):
|
|
288 |
## Get preview as txt
|
289 |
file_name, file_ext = os.path.splitext(os.path.basename(file))
|
290 |
subtitle = get_txt(transcribed_segments)
|
291 |
-
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}
|
292 |
|
293 |
## Add output file as txt
|
294 |
file_name, file_ext = os.path.splitext(os.path.basename(file))
|
@@ -330,6 +336,10 @@ class WhisperBase(ABC):
|
|
330 |
total_result += f'{info["subtitle"]}'
|
331 |
total_time += info["time_for_task"]
|
332 |
total_info += f'Input file: {info["input_source_file"]}\nLanguage: {info["lang"]} with probability {info["lang_prob"]}%\n'
|
|
|
|
|
|
|
|
|
333 |
if translate_output:
|
334 |
total_info += f'Translation: {info["translation"]}\n'
|
335 |
|
|
|
269 |
#)
|
270 |
#files_info[file_name] = {"subtitle": subtitle, "time_for_task": time_for_task, "path": file_path, "lang": file_language, "lang_prob": file_lang_probs, "input_source_file": (file_name+file_ext)}
|
271 |
|
272 |
+
# Translate to English using Whisper built-in functionality
|
273 |
+
transcription_note = ""
|
274 |
+
if params.is_translate:
|
275 |
+
transcription_note = "Translated to English"
|
276 |
+
file_language = "English"
|
277 |
+
|
278 |
# Translate the transcribed segments
|
279 |
translation_note = ""
|
280 |
if translate_output:
|
|
|
294 |
## Get preview as txt
|
295 |
file_name, file_ext = os.path.splitext(os.path.basename(file))
|
296 |
subtitle = get_txt(transcribed_segments)
|
297 |
+
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}
|
298 |
|
299 |
## Add output file as txt
|
300 |
file_name, file_ext = os.path.splitext(os.path.basename(file))
|
|
|
336 |
total_result += f'{info["subtitle"]}'
|
337 |
total_time += info["time_for_task"]
|
338 |
total_info += f'Input file: {info["input_source_file"]}\nLanguage: {info["lang"]} with probability {info["lang_prob"]}%\n'
|
339 |
+
|
340 |
+
if params.is_translate:
|
341 |
+
total_info += f'transcription: {info["transcription"]}\n'
|
342 |
+
|
343 |
if translate_output:
|
344 |
total_info += f'Translation: {info["translation"]}\n'
|
345 |
|