diff --git a/backend/backend/urls.py b/backend/backend/urls.py index 107481ed..7db6798b 100644 --- a/backend/backend/urls.py +++ b/backend/backend/urls.py @@ -74,7 +74,7 @@ def get_schema(self, request=None, public=False): path("voiceover/", include("voiceover.urls")), path("youtube/", include("youtube.urls")), path( - "api/generic/transliteration///", + "xlit-api/generic/transliteration//", TransliterationAPIView.as_view(), name="transliteration-api", ), diff --git a/backend/video/urls.py b/backend/video/urls.py index 32789a86..c9e82354 100644 --- a/backend/video/urls.py +++ b/backend/video/urls.py @@ -6,7 +6,7 @@ urlpatterns = [ path("", views.get_video, name="get_video"), path( - "api/generic/transliteration///", + "xlit-api/generic/transliteration//", TransliterationAPIView.as_view(), name="transliteration-api", ), diff --git a/backend/video/views.py b/backend/video/views.py index b2d2c0e6..8cbeaa1c 100644 --- a/backend/video/views.py +++ b/backend/video/views.py @@ -37,6 +37,7 @@ from collections import Counter from rest_framework.views import APIView import config +from rest_framework.permissions import IsAuthenticated accepted_languages = [ "as", @@ -96,25 +97,16 @@ class TransliterationAPIView(APIView): + permission_classes = [IsAuthenticated] + def get(self, request, target_language, data, *args, **kwargs): - json_data = { - "input": [{"source": data}], - "config": { - "language": { - "sourceLanguage": "en", - "targetLanguage": target_language, - }, - "isSentence": False, - "numSuggestions": 5, - }, - } - logging.info("Calling Transliteration API") - response_transliteration = requests.post( - config.transliteration_url, - headers={"authorization": config.dhruva_key}, - json=json_data, + response_transliteration = requests.get( + os.getenv("TRANSLITERATION_URL") + target_language + "/" + data, + headers={"Authorization": "Bearer " + os.getenv("TRANSLITERATION_KEY")}, ) + print(response_transliteration) + transliteration_output = response_transliteration.json() return Response(transliteration_output, status=status.HTTP_200_OK)