Skip to content

Commit 8ff21a4

Browse files
committed
Various logic improvements and bug fixes
Auto Sub ReTimer GUI.bat: - The cmd window now opens minimized to keep the GUI in the foreground, and closes automatically when the GUI is exited. Whisper "Fase0": - Fixed an issue that could cause a stall during "Fase0". Previously, to proceed it was necessary to manually delete leftover files created by previous processes, close and reopen the GUI. This situation will no longer occur. Whisper ReTimer, GUI: - Fixed an issue where, by starting the Whisper ReTimer process multiple times without restarting the GUI, when the question "Do you want subtitles to respect scene changes?" appeared, files were moved to the desktop even before the user had given a response. - "Whisper ReTimer" now disables along with "Whisper" if the "Faster-Whisper-XXL" folder is missing - Minor Fixes. "Fase5": - Fixed a bug where, when selecting "Yes" to the question "Do you want subtitles to respect scene changes?", both "Final.srt" and "whisper_adjusted.srt" were moved at the end of all processes instead of only the required file. Now: - If "Yes" is selected, only "Final.srt" and the related MKV will be moved. - If "No" is selected, only "whisper_adjusted.srt" and the related MKV will be moved.
1 parent 1ad743b commit 8ff21a4

File tree

4 files changed

+49
-22
lines changed

4 files changed

+49
-22
lines changed

Auto Sub ReTimer GUI.bat

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
@echo off
22
setlocal enabledelayedexpansion
33

4-
:: Vai nella directory dello script
54
cd /d "%~dp0"
65

7-
:: Disabilita controllo della versione pip e silenzia output pip
86
set PIP_DISABLE_PIP_VERSION_CHECK=1
97
set PIP_QUIET=1
108

119
set script_folder=Scripts\GUI
1210
set launcher_file=%script_folder%\GUI.py
1311
set torch_installed_flag=main\.torch_installed
1412

15-
:: Controlla se esiste la cartella "main" (ambiente virtuale)
1613
if not exist main (
1714
echo Creating the "main" folder...
1815
python\python.exe -m venv main
@@ -23,7 +20,6 @@ if not exist main (
2320
main\Scripts\python.exe -m pip install pysrt --use-pep517 --quiet
2421
)
2522

26-
:: Chiedi se installare CUDA solo se il flag non esiste
2723
if not exist "%torch_installed_flag%" (
2824
:ask_cuda
2925
echo.
@@ -50,11 +46,15 @@ if not exist "%torch_installed_flag%" (
5046
)
5147
)
5248

49+
if exist main if exist "%torch_installed_flag%" if not defined IS_MINIMIZED (
50+
set IS_MINIMIZED=1
51+
start "" /min cmd /c "%~dpnx0" %*
52+
exit
53+
)
54+
5355
if exist "%launcher_file%" (
5456
echo Starting the Gui....
5557
call main\Scripts\python.exe "%launcher_file%"
5658
) else (
5759
echo ERROR: Unable to find GUI.py in "%launcher_file%".
5860
)
59-
60-
pause

Scripts/GUI/GUI.py

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
root = ctk.CTk()
2929
root.title("Auto Sub ReTimer")
3030
root.geometry("1000x700")
31+
root.update_idletasks()
32+
x = (root.winfo_screenwidth() // 2) - (1000 // 2)
33+
y = (root.winfo_screenheight() // 2) - (700 // 2)
34+
root.geometry(f"1000x700+{x}+{y}")
3135

3236
# --------------------------------------------------
3337
# FUNZIONI PER LA GESTIONE DELLA CONFIGURAZIONE
@@ -52,10 +56,10 @@ def mostra_config_fase2():
5256
config = json.load(f)
5357
except (FileNotFoundError, json.JSONDecodeError):
5458
config = {
55-
"picco_audio_threshold": 200,
56-
"max_range_picco": 600,
57-
"lead_in": 200,
58-
"lead_out": 500
59+
"picco_audio_threshold": 400,
60+
"max_range_picco": 700,
61+
"lead_in": 175,
62+
"lead_out": 410
5963
}
6064

6165
config_frame = ctk.CTkFrame(frame_center)
@@ -135,8 +139,8 @@ def mostra_config_fase4():
135139
except (FileNotFoundError, json.JSONDecodeError):
136140
config = {
137141
"max_range_next_scene": 300,
138-
"gap_threshold": 230,
139-
"scene_change_before_threshold": 200,
142+
"gap_threshold": 280,
143+
"scene_change_before_threshold": 240,
140144
"scene_change_after_threshold": 200
141145
}
142146

@@ -460,10 +464,18 @@ def setup_paths():
460464
if not os.path.exists(paths['whisper_scripts']['exe_file']):
461465
missing_paths.append(f"Faster-Whisper file not found: {paths['whisper_scripts']['exe_file']}")
462466
paths['available']['whisper'] = False
467+
paths['available']['retimer'] = False
463468

464469
if not os.path.exists(paths['whisper_scripts']['venv_python']):
465470
missing_paths.append(f"Python virtualenv not found: {paths['whisper_scripts']['venv_python']}")
466471
paths['available']['whisper'] = False
472+
paths['available']['retimer'] = False
473+
474+
if paths['available']['whisper']:
475+
for name, path in paths['whisper_retimer'].items():
476+
if not os.path.exists(path):
477+
missing_paths.append(f"Whisper ReTimer script not found: {path}")
478+
paths['available']['retimer'] = False
467479

468480
if missing_paths:
469481
messagebox.showwarning("Warning",
@@ -502,6 +514,10 @@ def _create_dialog(self, question, options):
502514
dialog.geometry("500x200")
503515
dialog.transient(self.root)
504516
dialog.grab_set()
517+
dialog.update_idletasks()
518+
x = (dialog.winfo_screenwidth() // 2) - (500 // 2)
519+
y = (dialog.winfo_screenheight() // 2) - (200 // 2)
520+
dialog.geometry(f"+{x}+{y}")
505521

506522
label = ctk.CTkLabel(dialog, text=question, font=("Arial", 12))
507523
label.pack(pady=20)
@@ -512,7 +528,7 @@ def _create_dialog(self, question, options):
512528
for idx, option in enumerate(options, 1):
513529
btn = ctk.CTkButton(
514530
btn_frame,
515-
text=f"{idx}: {option}",
531+
text=option,
516532
command=lambda opt=idx: self._set_response(opt, dialog),
517533
width=120
518534
)
@@ -962,6 +978,8 @@ def esegui_whisper_retimer():
962978

963979
is_running = True
964980
button_avvia.configure(state="disabled")
981+
input_handler.response = None
982+
input_handler.event.clear()
965983
log_text.configure(state="normal")
966984
log_text.delete("1.0", "end")
967985
log_text.insert("end", "🚀 Starting Whisper ReTimer process...\n")

Scripts/Whisper Miglioramento Timing/Fase5.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,23 @@ def main():
4646
raise FileNotFoundError("Nessun file .mkv trovato nella directory.")
4747
mkv_filename = mkv_files[0]
4848

49-
files_to_keep = TARGET_FILES['keep'] + [mkv_filename]
50-
51-
# 1. Trova e sposta i file da conservare
52-
existing_to_keep = find_existing_files(files_to_keep, project_dir)
53-
move_to_desktop(existing_to_keep, project_dir, desktop_dir)
49+
existing_keep_files = find_existing_files(TARGET_FILES['keep'], project_dir)
50+
51+
files_to_move = []
52+
cleanup_list = TARGET_FILES['cleanup'].copy()
53+
54+
if "Final.srt" in existing_keep_files:
55+
files_to_move = ["Final.srt"]
56+
if "whisper_adjusted.srt" in existing_keep_files:
57+
cleanup_list.append("whisper_adjusted.srt")
58+
else:
59+
files_to_move = existing_keep_files
60+
61+
files_to_move.append(mkv_filename)
62+
63+
move_to_desktop(files_to_move, project_dir, desktop_dir)
5464

55-
# 2. Elimina i file residui
56-
existing_to_clean = find_existing_files(TARGET_FILES['cleanup'], project_dir)
65+
existing_to_clean = find_existing_files(cleanup_list, project_dir)
5766
cleanup_files(existing_to_clean, project_dir)
5867

5968
if __name__ == "__main__":

Scripts/Whisper/Fase0.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@
4444
# Se il file è già in formato AAC, lo estrae
4545
if codec == "aac":
4646
print("L'audio è già in formato AAC. Estrazione senza conversione...")
47-
ffmpeg_command = f'"{ffmpeg_path}" -hide_banner -vn -sn -dn -threads 0 -i "{input_path}" -vn -acodec copy "{audio_path}"'
47+
ffmpeg_command = f'"{ffmpeg_path}" -hide_banner -y -vn -sn -dn -threads 0 -i "{input_path}" -acodec copy "{audio_path}"'
4848
else:
4949
# Converte l'audio in formato AAC
5050
print("Convertendo l'audio in formato AAC...")
51-
ffmpeg_command = f'"{ffmpeg_path}" -hide_banner -i "{input_path}" -vn -sn -dn -acodec aac -b:a 192k -ac 2 -threads 0 "{audio_path}"'
51+
ffmpeg_command = f'"{ffmpeg_path}" -hide_banner -y -i "{input_path}" -vn -sn -dn -acodec aac -b:a 192k -ac 2 -threads 0 "{audio_path}"'
5252

5353
subprocess.run(ffmpeg_command, check=True)
5454
print(f"Operazione completata. File audio salvato come: {audio_path}")

0 commit comments

Comments
 (0)