Update modules/whisper/whisper_base.py
Browse files
modules/whisper/whisper_base.py
CHANGED
@@ -15,7 +15,7 @@ from copy import deepcopy
|
|
15 |
from modules.uvr.music_separator import MusicSeparator
|
16 |
from modules.utils.paths import (WHISPER_MODELS_DIR, DIARIZATION_MODELS_DIR, OUTPUT_DIR, DEFAULT_PARAMETERS_CONFIG_PATH,
|
17 |
UVR_MODELS_DIR)
|
18 |
-
from modules.utils.subtitle_manager import get_srt, get_vtt, get_txt, get_csv, write_file, safe_filename
|
19 |
from modules.utils.youtube_manager import get_ytdata, get_ytaudio
|
20 |
from modules.utils.files_manager import get_media_files, format_gradio_files, load_yaml, save_yaml
|
21 |
from modules.whisper.whisper_parameter import *
|
@@ -325,9 +325,16 @@ class WhisperBase(ABC):
|
|
325 |
else:
|
326 |
translation_note = "Already in " + target_lang
|
327 |
|
328 |
-
## Get preview
|
329 |
file_name, file_ext = os.path.splitext(os.path.basename(file))
|
330 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
331 |
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}
|
332 |
|
333 |
## Add output file as txt
|
@@ -367,7 +374,9 @@ class WhisperBase(ABC):
|
|
367 |
total_info = ''
|
368 |
total_time = 0
|
369 |
for file_name, info in files_info.items():
|
370 |
-
total_result += f'{info["subtitle"]}'
|
|
|
|
|
371 |
total_time += info["time_for_task"]
|
372 |
total_info += f'Input file:\t\t{info["input_source_file"]}\nLanguage:\t{info["lang"]} (probability {info["lang_prob"]}%)\n'
|
373 |
|
|
|
15 |
from modules.uvr.music_separator import MusicSeparator
|
16 |
from modules.utils.paths import (WHISPER_MODELS_DIR, DIARIZATION_MODELS_DIR, OUTPUT_DIR, DEFAULT_PARAMETERS_CONFIG_PATH,
|
17 |
UVR_MODELS_DIR)
|
18 |
+
from modules.utils.subtitle_manager import get_srt, get_vtt, get_txt, get_plaintext, get_csv, write_file, safe_filename
|
19 |
from modules.utils.youtube_manager import get_ytdata, get_ytaudio
|
20 |
from modules.utils.files_manager import get_media_files, format_gradio_files, load_yaml, save_yaml
|
21 |
from modules.whisper.whisper_parameter import *
|
|
|
325 |
else:
|
326 |
translation_note = "Already in " + target_lang
|
327 |
|
328 |
+
## Get preview
|
329 |
file_name, file_ext = os.path.splitext(os.path.basename(file))
|
330 |
+
|
331 |
+
if preview_format == "text":
|
332 |
+
subtitle = get_txt(transcribed_segments)
|
333 |
+
if preview_format == "text with timestamps":
|
334 |
+
subtitle = get_plaintext(transcribed_segments)
|
335 |
+
if preview_format == "csv":
|
336 |
+
subtitle = get_csv(transcribed_segments)
|
337 |
+
|
338 |
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}
|
339 |
|
340 |
## Add output file as txt
|
|
|
374 |
total_info = ''
|
375 |
total_time = 0
|
376 |
for file_name, info in files_info.items():
|
377 |
+
#total_result += f'{info["subtitle"]}'
|
378 |
+
total_result = {info["subtitle"]
|
379 |
+
|
380 |
total_time += info["time_for_task"]
|
381 |
total_info += f'Input file:\t\t{info["input_source_file"]}\nLanguage:\t{info["lang"]} (probability {info["lang_prob"]}%)\n'
|
382 |
|