From c84b159a260d01c7d4d9b85e5f61ad176fee94dd Mon Sep 17 00:00:00 2001 From: ThioJoe <12518330+ThioJoe@users.noreply.github.com> Date: Sat, 20 Jan 2024 17:27:32 -0700 Subject: [PATCH] Add config option for subtitle gap threshold User can now control the millisecond gap threshold for combining subtitles during that part of the process --- Scripts/translate.py | 8 +++++++- config.ini | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Scripts/translate.py b/Scripts/translate.py index a6fbebe..289255c 100644 --- a/Scripts/translate.py +++ b/Scripts/translate.py @@ -550,7 +550,13 @@ def set_translation_info(languageBatchDict): #======================================== Combine Subtitle Lines ================================================ def combine_subtitles_advanced(inputDict, maxCharacters=200): charRateGoal = 20 #20 - gapThreshold = 200 # The maximum gap between subtitles to combine + # Set gap threshold, the maximum gap between subtitles to combine + if 'subtitle_gap_threshold_milliseconds' in config: + gapThreshold = int(config['subtitle_gap_threshold_milliseconds']) + else: + gapThreshold = 200 + + # Don't change this, it is not an option, it is for keeping track noMorePossibleCombines = False # Convert dictionary to list of dictionaries of the values entryList = [] diff --git a/config.ini b/config.ini index 1c107aa..5ca41f1 100644 --- a/config.ini +++ b/config.ini @@ -81,6 +81,13 @@ add_line_buffer_milliseconds = 0 combine_subtitles_max_chars = 200 + # This determines the largest gap between subtitle line timestamps where the script will consider combining them + # Setting this too low will result in more fragmented TTS speech, and setting it too high could affect how well in sync the TTS stays with the video in some parts. + # Note: This won't matter if your subtitles have all the timestamps butting right up against eachother + # Default: 200 +subtitle_gap_threshold_milliseconds = 200 + + # If this setting is true, when combining subtitle lines, it will prioritize starting and ending text lines at natural sentence breaks. # This will result in fewer awkward fragmented speech patterns by the TTS voice, at the cost of some text possibly being read faster or slower than desired. # Possible Values: True | False