Skip to content

Commit

Permalink
Merge pull request #948 from AI4Bharat/minorchange05
Browse files Browse the repository at this point in the history
handle an edge case of negative duration
  • Loading branch information
aparna-aa authored Nov 20, 2024
2 parents 7fed359 + 42b6909 commit 0bc1e8e
Showing 1 changed file with 9 additions and 1 deletion.
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

0 comments on commit 0bc1e8e

Please sign in to comment.