Skip to content

Commit bac6c97

Browse files
committed
Fix and improvements
Auto Sub ReTimer: Fase2: - Removed the unnecessary ".wav" conversion from the very first versions of the script, now it reads the necessary file directly, speeding up the process. Fase4: - "min_peaks_count" set to 3 instead of 2. This results in fewer errors in linking the final time stamps of lines to scene changes. Fase6: - Removed the deletion of "temp.wav" since "Fase2" no longer creates these files.
1 parent 9c3cc60 commit bac6c97

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

Scripts/Migliora il Timing Dei Sub/Fase2.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,8 @@ def milliseconds_to_subrip_time(milliseconds):
4444
milliseconds = int(milliseconds % 1000)
4545
return pysrt.SubRipTime(hours=hours, minutes=minutes, seconds=seconds, milliseconds=milliseconds)
4646

47-
def get_audio_segments(audio_file, silence_threshold=320):
48-
audio = AudioSegment.from_file(audio_file)
49-
temp_file = os.path.join(project_path, "temp.wav")
50-
audio.export(temp_file, format="wav")
51-
52-
y, sr = librosa.load(temp_file, sr=None)
47+
def get_audio_segments(audio_file="vocali.wav", silence_threshold=320):
48+
y, sr = librosa.load(audio_file, sr=None)
5349
intervals = librosa.effects.split(y, top_db=20)
5450

5551
segments = []

Scripts/Migliora il Timing Dei Sub/Fase4.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def adjust_sub_end_based_on_previous_scene_change(original_subs, scene_subs, aud
160160
max_range = 900
161161
peak_threshold = 150 # 150ms per early/late peaks
162162
min_gap_to_next_sub = 100
163-
min_peaks_count = 2
163+
min_peaks_count = 3
164164

165165
for i, sub in enumerate(original_subs):
166166
original_end = sub.end.ordinal

Scripts/Migliora il Timing Dei Sub/Fase6.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ def verifica_file(files, base_path):
282282
"scene_timestamps.srt",
283283
"scene_timestamps_adjusted.srt",
284284
"Sub.srt",
285-
"temp.wav",
286285
"vocali.wav",
287286
"Dialoghi.ass",
288287
"Final.srt",
@@ -296,7 +295,6 @@ def verifica_file(files, base_path):
296295
"scene_timestamps.srt",
297296
"scene_timestamps_adjusted.srt",
298297
"Sub.srt",
299-
"temp.wav",
300298
"vocali.wav",
301299
"On Top.srt"
302300
]

0 commit comments

Comments
 (0)