Update modules/whisper/whisper_base.py
Browse files- modules/whisper/whisper_base.py +18 -10
modules/whisper/whisper_base.py
CHANGED
|
@@ -260,7 +260,7 @@ class WhisperBase(ABC):
|
|
| 260 |
List of files to transcribe from gr.Video()
|
| 261 |
files_multi: list
|
| 262 |
List of files to transcribe from gr.Files_multi()
|
| 263 |
-
input_multi:
|
| 264 |
Process single or multiple files
|
| 265 |
input_folder_path: str
|
| 266 |
Input folder path to transcribe from gr.Textbox(). If this is provided, `files` will be ignored and
|
|
@@ -294,6 +294,7 @@ class WhisperBase(ABC):
|
|
| 294 |
|
| 295 |
try:
|
| 296 |
file_count_total = 0
|
|
|
|
| 297 |
files = ""
|
| 298 |
|
| 299 |
if input_multi == "Audio":
|
|
@@ -303,6 +304,7 @@ class WhisperBase(ABC):
|
|
| 303 |
else:
|
| 304 |
files = files_multi
|
| 305 |
file_count_total = len(files)
|
|
|
|
| 306 |
|
| 307 |
if input_folder_path:
|
| 308 |
files = get_media_files(input_folder_path)
|
|
@@ -406,17 +408,23 @@ class WhisperBase(ABC):
|
|
| 406 |
for file_name, info in files_info.items():
|
| 407 |
|
| 408 |
file_count += 1
|
| 409 |
-
|
| 410 |
-
if file_count > 1:
|
| 411 |
-
total_info += f'\n'
|
| 412 |
-
|
| 413 |
-
if file_count_total > 1:
|
| 414 |
-
if file_count > 1:
|
| 415 |
-
total_result += f'\n'
|
| 416 |
-
total_result += f'« Transcription of media file \'{info["input_source_file"]}\': »\n\n'
|
| 417 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 418 |
total_time += info["time_for_task"]
|
| 419 |
-
total_result += f'{info["subtitle"]}'
|
| 420 |
total_info += f'Media file:\t{info["input_source_file"]}\nLanguage:\t{info["lang"]} (probability {info["lang_prob"]}%)\n'
|
| 421 |
|
| 422 |
if params.is_translate:
|
|
|
|
| 260 |
List of files to transcribe from gr.Video()
|
| 261 |
files_multi: list
|
| 262 |
List of files to transcribe from gr.Files_multi()
|
| 263 |
+
input_multi: str
|
| 264 |
Process single or multiple files
|
| 265 |
input_folder_path: str
|
| 266 |
Input folder path to transcribe from gr.Textbox(). If this is provided, `files` will be ignored and
|
|
|
|
| 294 |
|
| 295 |
try:
|
| 296 |
file_count_total = 0
|
| 297 |
+
process_multiple = False
|
| 298 |
files = ""
|
| 299 |
|
| 300 |
if input_multi == "Audio":
|
|
|
|
| 304 |
else:
|
| 305 |
files = files_multi
|
| 306 |
file_count_total = len(files)
|
| 307 |
+
process_multiple = True
|
| 308 |
|
| 309 |
if input_folder_path:
|
| 310 |
files = get_media_files(input_folder_path)
|
|
|
|
| 408 |
for file_name, info in files_info.items():
|
| 409 |
|
| 410 |
file_count += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 411 |
|
| 412 |
+
# Add filename as column if multiple file processing
|
| 413 |
+
if process_multiple:
|
| 414 |
+
temp_lines = {info["subtitle"]}
|
| 415 |
+
line_count = 0
|
| 416 |
+
result_fixed = []
|
| 417 |
+
for temp_line in temp_lines:
|
| 418 |
+
line_count += 1
|
| 419 |
+
if line_count==1:
|
| 420 |
+
result_fixed.append(info["input_source_file"]+"\t"+temp_line)
|
| 421 |
+
else:
|
| 422 |
+
result_fixed.append("\t"+temp_line)
|
| 423 |
+
total_result += result_fixed
|
| 424 |
+
else:
|
| 425 |
+
total_result += f'{info["subtitle"]}'
|
| 426 |
+
|
| 427 |
total_time += info["time_for_task"]
|
|
|
|
| 428 |
total_info += f'Media file:\t{info["input_source_file"]}\nLanguage:\t{info["lang"]} (probability {info["lang_prob"]}%)\n'
|
| 429 |
|
| 430 |
if params.is_translate:
|