Spaces:
Configuration error
Configuration error
change schemas
Browse files- texttovoice/views.py +25 -0
texttovoice/views.py
CHANGED
|
@@ -8,12 +8,37 @@ from TTS.api import TTS
|
|
| 8 |
from rest_framework.authentication import TokenAuthentication
|
| 9 |
from rest_framework.permissions import IsAuthenticated
|
| 10 |
from .serializers import TextToSpeechSerializer
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
class TextToSpeechCreateView(CreateAPIView):
|
| 13 |
serializer_class = TextToSpeechSerializer
|
| 14 |
authentication_classes = [TokenAuthentication] # Apply token authentication
|
| 15 |
permission_classes = [IsAuthenticated] # Require authentication for this view
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
def create(self, request, *args, **kwargs):
|
| 18 |
serializer = self.get_serializer(data=request.data)
|
| 19 |
if serializer.is_valid():
|
|
|
|
| 8 |
from rest_framework.authentication import TokenAuthentication
|
| 9 |
from rest_framework.permissions import IsAuthenticated
|
| 10 |
from .serializers import TextToSpeechSerializer
|
| 11 |
+
from rest_framework.parsers import MultiPartParser
|
| 12 |
+
from drf_yasg import openapi
|
| 13 |
+
from drf_yasg.utils import swagger_auto_schema
|
| 14 |
+
|
| 15 |
|
| 16 |
class TextToSpeechCreateView(CreateAPIView):
|
| 17 |
serializer_class = TextToSpeechSerializer
|
| 18 |
authentication_classes = [TokenAuthentication] # Apply token authentication
|
| 19 |
permission_classes = [IsAuthenticated] # Require authentication for this view
|
| 20 |
|
| 21 |
+
parser_classes = [MultiPartParser]
|
| 22 |
+
|
| 23 |
+
@swagger_auto_schema(
|
| 24 |
+
operation_id='Create a document',
|
| 25 |
+
operation_description='Create a document by providing file and s3_key',
|
| 26 |
+
manual_parameters=[
|
| 27 |
+
openapi.Parameter('file', openapi.IN_FORM, type=openapi.TYPE_FILE, description='Document to be uploaded'),
|
| 28 |
+
openapi.Parameter('s3_key', openapi.IN_FORM, type=openapi.TYPE_STRING, description='S3 Key of the Document '
|
| 29 |
+
'(folders along with name)')
|
| 30 |
+
],
|
| 31 |
+
responses={
|
| 32 |
+
status.HTTP_200_OK: openapi.Response(
|
| 33 |
+
'Success', schema=openapi.Schema(type=openapi.TYPE_OBJECT, properties={
|
| 34 |
+
'doc_id': openapi.Schema(type=openapi.TYPE_STRING, description='Document ID'),
|
| 35 |
+
'mime_type': openapi.Schema(type=openapi.TYPE_STRING, description='Mime Type of the Document'),
|
| 36 |
+
'version_id': openapi.Schema(type=openapi.TYPE_STRING, description='S3 version ID of the document')
|
| 37 |
+
})
|
| 38 |
+
)
|
| 39 |
+
}
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
def create(self, request, *args, **kwargs):
|
| 43 |
serializer = self.get_serializer(data=request.data)
|
| 44 |
if serializer.is_valid():
|