From 5436703f48118ed989961f44726a25ca2419e1b0 Mon Sep 17 00:00:00 2001 From: Shanks0465 Date: Tue, 17 Sep 2024 13:35:48 +0530 Subject: [PATCH 1/2] Changes for Data Analysis --- backend/areas/views.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/backend/areas/views.py b/backend/areas/views.py index e6eaaa7..d7ff0aa 100644 --- a/backend/areas/views.py +++ b/backend/areas/views.py @@ -10,7 +10,7 @@ import shutil import httpx - +timeout = httpx.Timeout(None, read=None) # Create your views here. from .models import Dataset, Tool, Model,News,ModelFeedback,Publication @@ -57,7 +57,7 @@ async def translate(request): } payload = { "controlConfig": { - "dataTracking": True + "dataTracking": body["track"] }, "config": { "serviceId": body["serviceId"], @@ -76,7 +76,7 @@ async def translate(request): } async with httpx.AsyncClient() as client: - inference_result = await client.post(url, headers=headers, json=payload) + inference_result = await client.post(url, headers=headers, json=payload,timeout=timeout) if inference_result.status_code != 200: return Response({"message": "Inference Failed"}, status=status.HTTP_503_SERVICE_UNAVAILABLE) @@ -114,7 +114,7 @@ async def transcribe(request): headers = {'x-auth-source': 'API_KEY','Authorization': os.getenv('DHRUVA_API_KEY')} payload = { "controlConfig": { - "dataTracking": True + "dataTracking": body["track"] }, "config": { "audioFormat": "wav", @@ -141,7 +141,7 @@ async def transcribe(request): } async with httpx.AsyncClient() as client: - inferenceResult = await client.post(os.getenv("DHRUVA_ASR_ENDPOINT"),headers=headers,json=payload) + inferenceResult = await client.post(os.getenv("DHRUVA_ASR_ENDPOINT"),headers=headers,json=payload,timeout=timeout) os.remove(webmPath) os.remove(wavPath) @@ -165,7 +165,7 @@ async def convertToAudio(request): json_payload = { "controlConfig": { - "dataTracking": True + "dataTracking": body["track"] }, "config": { "serviceId": body["serviceId"], @@ -186,7 +186,7 @@ async def convertToAudio(request): } async with httpx.AsyncClient() as client: - inference_result = await client.post(url, headers=headers, json=json_payload) + inference_result = await client.post(url, headers=headers, json=json_payload,timeout=timeout) if inference_result.status_code != 200: return Response({"message": "Inference Failed"}, status=status.HTTP_503_SERVICE_UNAVAILABLE) @@ -246,7 +246,8 @@ def create(self, request, *args, **kwargs): modelInput = hashlib.sha256(wav_base64.encode()) modelInput = modelInput.hexdigest() - shutil.copy2(wavPath,f"/home/ai4bharat/ai4b-website/backend/media/audio/{modelInput}.wav") + if body["track"]: + shutil.copy2(wavPath,f"/home/ai4bharat/ai4b-website/backend/media/audio/{modelInput}.wav") os.remove(webmPath) os.remove(wavPath) @@ -269,7 +270,7 @@ class DatasetViewSet(viewsets.ModelViewSet): queryset = Dataset.objects.all() serializer_class = DatasetSerializer - @method_decorator(cache_page(60*15)) + # @method_decorator(cache_page(60*15)) def list(self, request, *args, **kwargs): queryset = self.get_queryset() serializer = self.get_serializer(queryset, many=True) @@ -281,13 +282,14 @@ class ModelViewSet(viewsets.ModelViewSet): queryset = Model.objects.all() serializer_class = ModelSerializer - @method_decorator(cache_page(60*15)) + # @method_decorator(cache_page(60*15)) def list(self, request, *args, **kwargs): queryset = self.get_queryset() serializer = self.get_serializer(queryset, many=True) models = serializer.data return Response(models) - + + @method_decorator(cache_page(60*15)) def retrieve(self, request, *args, **kwargs): @@ -394,7 +396,8 @@ def list(self, request, *args, **kwargs): for item in data ] return Response(filtered_data) - + + @method_decorator(cache_page(60*15)) def retrieve(self, request, *args, **kwargs): title = kwargs.get("title") try: From a6a13f295a8991aa6445254af9288c329fcfbf32 Mon Sep 17 00:00:00 2001 From: Shanks0465 Date: Tue, 17 Sep 2024 17:49:30 +0530 Subject: [PATCH 2/2] Track Default --- frontend/components/TryOut/ASR.tsx | 2 +- frontend/components/TryOut/NMT.tsx | 2 +- frontend/components/TryOut/TTS.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/components/TryOut/ASR.tsx b/frontend/components/TryOut/ASR.tsx index 9a2440b..8f4970c 100644 --- a/frontend/components/TryOut/ASR.tsx +++ b/frontend/components/TryOut/ASR.tsx @@ -105,7 +105,7 @@ export default function ASR({ services }: { services: any }) { const [success, setSuccess] = useState(false); const [isLoading, setIsLoading] = useState(false); - const [tracking, setTracking] = useState(false); + const [tracking, setTracking] = useState(true); const toast = useToast(); diff --git a/frontend/components/TryOut/NMT.tsx b/frontend/components/TryOut/NMT.tsx index ed348db..b8fad17 100644 --- a/frontend/components/TryOut/NMT.tsx +++ b/frontend/components/TryOut/NMT.tsx @@ -65,7 +65,7 @@ export default function NMT({ services }: { services: any }) { const [outputText, setOutputText] = useState(""); const [success, setSuccess] = useState(false); const [isLoading, setIsLoading] = useState(false); - const [tracking, setTracking] = useState(false); + const [tracking, setTracking] = useState(true); const toast = useToast(); diff --git a/frontend/components/TryOut/TTS.tsx b/frontend/components/TryOut/TTS.tsx index b258693..070235b 100644 --- a/frontend/components/TryOut/TTS.tsx +++ b/frontend/components/TryOut/TTS.tsx @@ -69,7 +69,7 @@ export default function TTS({ services }: { services: any }) { const [inputText, setInputText] = useState(""); const [output, setOutput] = useState(""); const [isLoading, setIsLoading] = useState(false); - const [tracking, setTracking] = useState(false); + const [tracking, setTracking] = useState(true); const [success, setSuccess] = useState(false);