Skip to content

Commit

Permalink
Merge pull request #55 from AI4Bharat/v1.0
Browse files Browse the repository at this point in the history
Changes
  • Loading branch information
Shanks0465 authored Sep 10, 2024
2 parents 54843f3 + 2276ada commit 4125f30
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 5 deletions.
6 changes: 5 additions & 1 deletion backend/areas/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.contrib import admin

# Register your models here.
from .models import Dataset, Tool, Model,News,ModelFeedback
from .models import Dataset, Tool, Model,News,ModelFeedback,Publication

from import_export import resources

Expand Down Expand Up @@ -34,9 +34,13 @@ class ModelAdmin(admin.ModelAdmin):
class ToolAdmin(admin.ModelAdmin):
search_fields = ["title"]

class PublicationAdmin(admin.ModelAdmin):
search_fields = ["title"]


admin.site.register(Dataset, DatasetAdmin)
admin.site.register(Tool, ToolAdmin)
admin.site.register(Model, ModelAdmin)
admin.site.register(News,NewsAdmin)
admin.site.register(ModelFeedback,ModelFeedbackAdmin)
admin.site.register(Publication,PublicationAdmin)
9 changes: 9 additions & 0 deletions backend/areas/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,12 @@ class News(models.Model):

def __str__(self) -> str:
return f"{self.title}"

class Publication(models.Model):
id = models.AutoField(primary_key=True)
title = models.CharField(max_length=200)
dataset = models.ManyToManyField(Dataset,null=True,blank=True)
model = models.ManyToManyField(Model,null=True,blank=True)

def __str__(self) -> str:
return f"{self.title}"
16 changes: 15 additions & 1 deletion backend/areas/serializers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from rest_framework.serializers import ModelSerializer
from .models import Dataset, Tool, Model,News,ModelFeedback
from .models import Dataset, Tool, Model,News,ModelFeedback,Publication


class DatasetSerializer(ModelSerializer):
Expand Down Expand Up @@ -73,3 +73,17 @@ class Meta:
"related_link",
"markdown_content"
]

class PublicationSerializer(ModelSerializer):
model = ModelSerializer(many=True)
dataset = DatasetSerializer(many=True)
class Meta:
model = Publication
fields = [
"id",
"title",
"model",
"dataset",
]


1 change: 1 addition & 0 deletions backend/areas/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
router.register(r"datasets", views.DatasetViewSet)
router.register(r"news",views.NewsViewSet)
router.register(r"feedback",views.ModelFeedbackViewSet)
router.register(r"pubs",views.PubViewSet)
# Do not register the ToolViewSet with the router, as we need custom routes

# The API URLs are now determined automatically by the router.
Expand Down
11 changes: 9 additions & 2 deletions backend/areas/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import subprocess

# Create your views here.
from .models import Dataset, Tool, Model,News,ModelFeedback
from .models import Dataset, Tool, Model,News,ModelFeedback,Publication
from rest_framework import viewsets,status
from .serializers import DatasetSerializer, ToolSerializer, ModelSerializer,NewsSerializer,ModelFeedbackSerializer
from .serializers import DatasetSerializer, ToolSerializer, ModelSerializer,NewsSerializer,ModelFeedbackSerializer,PublicationSerializer
from rest_framework.decorators import permission_classes
from rest_framework import permissions
from django_ratelimit.decorators import ratelimit
Expand Down Expand Up @@ -180,6 +180,10 @@ class NewsViewSet(viewsets.ModelViewSet):
queryset = News.objects.all()
serializer_class = NewsSerializer

class PubViewSet(viewsets.ModelViewSet):
queryset = Publication.objects.all()
serializer_class = PublicationSerializer

def val2Bool(val):
if val=="true":
return True
Expand Down Expand Up @@ -220,6 +224,9 @@ def create(self, request, *args, **kwargs):
modelInput = hashlib.sha256(wav_base64.encode())
modelInput = modelInput.hexdigest()

os.remove(webmPath)
os.remove(wavPath)

elif task=="tts":

modelResponse = hashlib.sha256(modelResponse.encode())
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/TryOut/ASR.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ export default function ASR({ services }: { services: any }) {
}}
recorderControls={recorderControls}
/>
<FileUploadButton handleFileChange={handleFileChange} />
{/* <FileUploadButton handleFileChange={handleFileChange} /> */}
</HStack>
<Textarea value={outputText} isReadOnly></Textarea>
{success ? (
Expand Down

0 comments on commit 4125f30

Please sign in to comment.