|
25 | 25 | import PySimpleGUI as sg |
26 | 26 | import httpx |
27 | 27 | from glob import glob |
| 28 | +from ffmpeg_progress_yield import FfmpegProgress |
28 | 29 | #import warnings |
29 | 30 | #warnings.filterwarnings("ignore", category=DeprecationWarning) |
30 | 31 | #warnings.filterwarnings("ignore", category=RuntimeWarning) |
@@ -507,6 +508,12 @@ def extract_audio(filename, main_window, channels=1, rate=16000): |
507 | 508 | main_window['-START-'].update(('Cancel','Start')[not_transcribing], button_color=(('white', ('red', '#283b5b')[not_transcribing]))) |
508 | 509 |
|
509 | 510 | command = ["ffmpeg", "-y", "-i", filename, "-ac", str(channels), "-ar", str(rate), "-loglevel", "error", temp.name] |
| 511 | + ff = FfmpegProgress(command) |
| 512 | + file_display_name = os.path.basename(filename).split('/')[-1] |
| 513 | + for progress in ff.run_command_with_progress(): |
| 514 | + pBar(progress, 100, 'Converting {} to a temporary WAV file : '.format(file_display_name), main_window) |
| 515 | + pBar(100, 100, 'Converting {} to a temporary WAV file : '.format(file_display_name), main_window) |
| 516 | + #main_window['-OUTPUT-MESSAGES-'].update("\n") |
510 | 517 |
|
511 | 518 | if not_transcribing: return |
512 | 519 |
|
@@ -627,9 +634,9 @@ def transcribe(src, dst, filename, subtitle_format, main_window): |
627 | 634 | main_window['-OUTPUT-MESSAGES-'].update("") |
628 | 635 | string_processing = "Processing {} :\n".format(file_display_name) |
629 | 636 | main_window['-OUTPUT-MESSAGES-'].update(string_processing, append=True) |
630 | | - main_window['-OUTPUT-MESSAGES-'].update("Converting {} to a temporary WAV file\n".format(file_display_name), append=True) |
| 637 | + #main_window['-OUTPUT-MESSAGES-'].update("Converting {} to a temporary WAV file\n".format(file_display_name), append=True) |
631 | 638 | wav_filename, audio_rate = extract_audio(filename, main_window) |
632 | | - main_window['-OUTPUT-MESSAGES-'].update("{} converted WAV file is : {}\n".format(file_display_name, wav_filename), append=True) |
| 639 | + main_window['-OUTPUT-MESSAGES-'].update("\n{} converted WAV file is : {}\n".format(file_display_name, wav_filename), append=True) |
633 | 640 | time.sleep(2) |
634 | 641 |
|
635 | 642 | if not_transcribing: return |
@@ -799,7 +806,7 @@ def main(): |
799 | 806 | parser.add_argument('-S', '--src-language', help="Voice language", default="en") |
800 | 807 | parser.add_argument('-D', '--dst-language', help="Desired language for translation", default="en") |
801 | 808 | parser.add_argument('-F', '--format', help="Destination subtitle format", default="srt") |
802 | | - parser.add_argument('-v', '--version', action='version', version='0.1.3') |
| 809 | + parser.add_argument('-v', '--version', action='version', version='0.1.4') |
803 | 810 | parser.add_argument('-lf', '--list-formats', help="List all available subtitle formats", action='store_true') |
804 | 811 | parser.add_argument('-ll', '--list-languages', help="List all available source/translation languages", action='store_true') |
805 | 812 |
|
|
0 commit comments