Skip to content

Commit

Permalink
Merge pull request #421 from AI4Bharat/translation_bugs
Browse files Browse the repository at this point in the history
Vo bug fix
  • Loading branch information
Shruti1229 authored Jul 25, 2023
2 parents d0a870b + a2f63d9 commit 218e246
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
36 changes: 18 additions & 18 deletions backend/translation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,15 @@ def save_translation(request):
task.status = "COMPLETE"
task.save()
translation_obj.save()
response = check_if_translation_correct(translation_obj, task)
if type(response) == dict:
return Response(
{
"data": response["data"],
"message": response["message"],
},
status=status.HTTP_400_BAD_REQUEST,
)
delete_indices = []
for index, sentence in enumerate(
translation_obj.payload["payload"]
Expand All @@ -1277,15 +1286,6 @@ def save_translation(request):
for ind in delete_indices:
translation_obj.payload["payload"].pop(ind)
translation_obj.save()
response = check_if_translation_correct(translation_obj, task)
if type(response) == dict:
return Response(
{
"data": response["data"],
"message": response["message"],
},
status=status.HTTP_400_BAD_REQUEST,
)
message = change_active_status_of_next_tasks(
task, translation_obj
)
Expand Down Expand Up @@ -1374,6 +1374,15 @@ def save_translation(request):
limit, payload, start_offset, end_offset, translation_obj
)
translation_obj.save()
translation_obj.save()
task.status = "COMPLETE"
task.save()
response = check_if_translation_correct(translation_obj, task)
if type(response) == dict:
return Response(
{"data": response["data"], "message": response["message"]},
status=status.HTTP_400_BAD_REQUEST,
)
delete_indices = []
for index, sentence in enumerate(
translation_obj.payload["payload"]
Expand All @@ -1384,15 +1393,6 @@ def save_translation(request):
delete_indices.reverse()
for ind in delete_indices:
translation_obj.payload["payload"].pop(ind)
translation_obj.save()
task.status = "COMPLETE"
task.save()
response = check_if_translation_correct(translation_obj, task)
if type(response) == dict:
return Response(
{"data": response["data"], "message": response["message"]},
status=status.HTTP_400_BAD_REQUEST,
)
message = change_active_status_of_next_tasks(task, translation_obj)
else:
translation_obj = (
Expand Down
13 changes: 8 additions & 5 deletions backend/voiceover/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,16 @@ def get_bad_sentences(translation_obj, target_language):
def get_bad_sentences_in_progress(translation_obj, target_language):
problem_sentences = []
translation = translation_obj.payload
compare_with_index = -1
last_valid_index = -1
for ind, text in enumerate(translation["payload"]):
if not compare_time(text["end_time"], text["start_time"])[0]:
if (
"text" in text.keys()
and not compare_time(text["end_time"], text["start_time"])[0]
):
problem_sentences.append(
{
"index": ind % 50,
"index": (ind % 50) + 1,
"page_number": (ind // 50) + 1,
"start_time": text["start_time"],
"end_time": text["end_time"],
Expand All @@ -415,8 +420,6 @@ def get_bad_sentences_in_progress(translation_obj, target_language):
}
)
if ind != 0 and ind < len(translation["payload"]):
compare_with_index = -1
last_valid_index = -1
compare = False
if "text" in translation["payload"][ind - 1] and "text" in text.keys():
compare_with_index = ind - 1
Expand All @@ -438,7 +441,7 @@ def get_bad_sentences_in_progress(translation_obj, target_language):
):
problem_sentences.append(
{
"index": ind % 50,
"index": (ind % 50) + 1,
"page_number": (ind // 50) + 1,
"start_time": text["start_time"],
"end_time": text["end_time"],
Expand Down

0 comments on commit 218e246

Please sign in to comment.