Skip to content

Commit

Permalink
Add config option for subtitle gap threshold
Browse files Browse the repository at this point in the history
User can now control the millisecond gap threshold for combining subtitles during that part of the process
  • Loading branch information
ThioJoe committed Jan 21, 2024
1 parent 3b7f740 commit c84b159
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Scripts/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
7 changes: 7 additions & 0 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c84b159

Please sign in to comment.