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

added regenerate for VOTR #912

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions backend/organization/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,9 @@ def list_org_tasks(self, request, pk=None, *args, **kwargs):
task["updated_at"]
).replace(tzinfo=None):
buttons["Reopen"] = False
if "TRANSLATION_VOICEOVER" in task["task_type"]:
if task["status"] in ["SELECTED_SOURCE", "FAILED"] and task["is_active"] is False:
buttons["Regenerate"] = True
if task["status"] == "POST_PROCESS":
buttons["Update"] = True
if task["status"] == "FAILED":
Expand Down
3 changes: 3 additions & 0 deletions backend/project/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,9 @@ def list_project_tasks(self, request, pk=None, *args, **kwargs):
data["updated_at"]
).replace(tzinfo=None):
buttons["Reopen"] = False
if "TRANSLATION_VOICEOVER" in data["task_type"]:
if data["status"] in ["SELECTED_SOURCE", "FAILED"] and data["is_active"] is False:
buttons["Regenerate"] = True
if data["status"] == "POST_PROCESS":
buttons["Update"] = True
if data["status"] == "FAILED":
Expand Down
8 changes: 7 additions & 1 deletion backend/task/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
from rest_framework.decorators import parser_classes
from rest_framework.parsers import MultiPartParser, FormParser
import regex

from translation.views import regenerate_translation_voiceover

def get_export_translation(request, task_id, export_type):
new_request = HttpRequest()
Expand Down Expand Up @@ -3392,6 +3392,12 @@ def regenerate_response(self, request, pk, *args, **kwargs):
elif task.task_type == "VOICEOVER_EDIT":
celery_tts_call.delay(task_id=task.id)
api = "TTS"
elif task.task_type == "TRANSLATION_VOICEOVER_EDIT":
if regenerate_translation_voiceover(task.id) is False:
return Response(
{"message": "Transcription task is not complete yet"}, status=status.HTTP_400_BAD_REQUEST
)
api = "NMT-TTS"
else:
return Response(
{"message": "Invalid task"}, status=status.HTTP_400_BAD_REQUEST
Expand Down
2 changes: 0 additions & 2 deletions backend/transcript/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1362,8 +1362,6 @@ def change_active_status_of_next_tasks(task, transcript_obj):
translation.save()
if source_type == None or source_type == "MACHINE_GENERATED":
source_type = "MACHINE_GENERATED"
translation.transcript = transcript_obj
translation.save()
celery_nmt_tts_call.delay(task_id=translation.task.id)
else:
payloads = generate_translation_payload(
Expand Down
17 changes: 16 additions & 1 deletion backend/translation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
from transcript.utils.timestamp import *
from django.core.mail import EmailMultiAlternatives
from django.conf import settings

from transcript.views import get_transcript_id
from task.tasks import celery_nmt_tts_call

@api_view(["GET"])
def get_translation_export_types(request):
Expand Down Expand Up @@ -2335,3 +2336,17 @@ def get_translation_report(request):
res.append(temp_data)

return Response(res, status=status.HTTP_200_OK)

def regenerate_translation_voiceover(task_id):
task_obj = Task.objects.get(pk=task_id)
video = Video.objects.filter(id=task_obj.video_id).first()
transcription_task = Task.objects.filter(video=video, task_type="TRANSCRIPTION_EDIT", status="COMPLETE").first()
if transcription_task is None:
return False
transcript = get_transcript_id(transcription_task)
transcript_obj = Transcript.objects.get(pk=transcript.id)
translation = Translation.objects.filter(task=task_obj).first()
translation.transcript = transcript_obj
translation.save()
celery_nmt_tts_call.delay(task_id)
return True
Loading