Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle an edge case of negative duration #948

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion backend/voiceover/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@ def check_audio_completion(voice_over_obj):

for index, payload in enumerate(voice_over_obj.translation.payload["payload"]):
if str(index) in voice_over_obj.payload["payload"].keys():
if (get_original_duration(voice_over_obj.payload["payload"][str(index)]["start_time"], voice_over_obj.payload["payload"][str(index)]["end_time"]) < 0.1):
if (get_original_duration_neg(voice_over_obj.payload["payload"][str(index)]["start_time"], voice_over_obj.payload["payload"][str(index)]["end_time"]) < 0.1):
missing_cards.append(
{
"card_number": index + 1,
Expand Down Expand Up @@ -1292,6 +1292,14 @@ def get_original_duration(start_time, end_time):
)
return t_d

def get_original_duration_neg(start_time, end_time):
start = datetime.strptime(start_time, "%H:%M:%S.%f")
end = datetime.strptime(end_time, "%H:%M:%S.%f")

time_difference = (end - start).total_seconds()

return time_difference


def integrate_all_audios(file_name, payload, video_duration):
length_payload = len(payload["payload"])
Expand Down
Loading