Skip to content

Commit

Permalink
Add check for too-long audio clips
Browse files Browse the repository at this point in the history
Will check while adding audio clips to final audio file whether any are too long such that they will overrun into the next audio clip. Or if its the last clip, then if it will be cut off at the end.
  • Loading branch information
ThioJoe committed Jan 29, 2024
1 parent 2e4a76b commit 8b4c0be
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Scripts/audio_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,17 @@ def build_audio(subsDict, langDict, totalAudioLength, twoPassVoiceSynth=False):
virtualTrimmedFileDict[key].seek(0) # Not 100% sure if this is necessary but it was in the other place it is used

canvas = insert_audio(canvas, stretchedClip, value['start_ms'])

# Print warning if audio clip is longer than expected and would overlap next clip
currentClipExpectedDuration = int(value['duration_ms'])
currentClipTrueDuration = stretchedClip.duration_seconds * 1000
difference = str(round(currentClipTrueDuration - currentClipExpectedDuration))
if key < len(subsDict) and (currentClipTrueDuration + int(value['start_ms']) > int(subsDict[key+1]['start_ms'])):
print(f"WARNING: Audio clip {str(key)} for language {langDict['languageCode']} is {difference}ms longer than expected and may overlap the next clip. Inspect the audio file after completion.")
elif key == len(subsDict) and (currentClipTrueDuration + int(value['start_ms']) > totalAudioLength):
print(f"WARNING: Audio clip {str(key)} for language {langDict['languageCode']} is {difference}ms longer than expected and may cut off at the end of the file. Inspect the audio file after completion.")


keyIndex = list(subsDict.keys()).index(key)
print(f" Final Audio Processed: {keyIndex+1} of {len(subsDict)}", end="\r")
print("\n")
Expand Down

0 comments on commit 8b4c0be

Please sign in to comment.