Spaces:
Configuration error
Configuration error
Fixning permission issue
Browse files- Dockerfile +1 -3
- texttovoice/views.py +10 -2
Dockerfile
CHANGED
@@ -38,12 +38,10 @@ COPY packages/matching.py /usr/local/lib/python3.10/site-packages/librosa/util/m
|
|
38 |
COPY packages/spectrum.py /usr/local/lib/python3.10/site-packages/librosa/core/spectrum.py
|
39 |
COPY packages/pitch.py /usr/local/lib/python3.10/site-packages/librosa/core/pitch.py
|
40 |
RUN chmod -R 777 /usr/local/lib/python3.10/site-packages/librosa \
|
41 |
-
&& chmod 777 /tmp && chmod -R 777
|
42 |
|
43 |
# Set the environment variable for the NUMBA cache directory
|
44 |
|
45 |
-
# Ensure the tmp directory is writable
|
46 |
-
RUN
|
47 |
|
48 |
# Expose the port your app runs on
|
49 |
EXPOSE 7860
|
|
|
38 |
COPY packages/spectrum.py /usr/local/lib/python3.10/site-packages/librosa/core/spectrum.py
|
39 |
COPY packages/pitch.py /usr/local/lib/python3.10/site-packages/librosa/core/pitch.py
|
40 |
RUN chmod -R 777 /usr/local/lib/python3.10/site-packages/librosa \
|
41 |
+
&& chmod 777 /tmp && mkdir /.local && chmod -R 777 /.local
|
42 |
|
43 |
# Set the environment variable for the NUMBA cache directory
|
44 |
|
|
|
|
|
45 |
|
46 |
# Expose the port your app runs on
|
47 |
EXPOSE 7860
|
texttovoice/views.py
CHANGED
@@ -7,6 +7,7 @@ from rest_framework.generics import CreateAPIView
|
|
7 |
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 |
from rest_framework.parsers import MultiPartParser
|
12 |
from drf_yasg import openapi
|
@@ -49,7 +50,7 @@ class TextToSpeechCreateView(CreateAPIView):
|
|
49 |
|
50 |
# try:
|
51 |
# Define the directory path
|
52 |
-
tmp_dir = "
|
53 |
|
54 |
# Check if the directory exists and create it if it doesn't
|
55 |
if not os.path.exists(tmp_dir):
|
@@ -57,7 +58,7 @@ class TextToSpeechCreateView(CreateAPIView):
|
|
57 |
print("before creating the speaker file path", os.path)
|
58 |
|
59 |
# Save the uploaded speaker file to a temporary location
|
60 |
-
speaker_file_path = os.path.join(
|
61 |
with open(speaker_file_path, "wb") as destination:
|
62 |
for chunk in speaker_wav.chunks():
|
63 |
destination.write(chunk)
|
@@ -81,6 +82,13 @@ class TextToSpeechCreateView(CreateAPIView):
|
|
81 |
pass
|
82 |
|
83 |
# Use the file_iterator to create a FileResponse
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
response = FileResponse(file_iterator(output_filename), as_attachment=True, content_type='audio/wav')
|
85 |
return response
|
86 |
|
|
|
7 |
from TTS.api import TTS
|
8 |
from rest_framework.authentication import TokenAuthentication
|
9 |
from rest_framework.permissions import IsAuthenticated
|
10 |
+
from texttovoice.models import TextToSpeech
|
11 |
from .serializers import TextToSpeechSerializer
|
12 |
from rest_framework.parsers import MultiPartParser
|
13 |
from drf_yasg import openapi
|
|
|
50 |
|
51 |
# try:
|
52 |
# Define the directory path
|
53 |
+
tmp_dir = "/.local"
|
54 |
|
55 |
# Check if the directory exists and create it if it doesn't
|
56 |
if not os.path.exists(tmp_dir):
|
|
|
58 |
print("before creating the speaker file path", os.path)
|
59 |
|
60 |
# Save the uploaded speaker file to a temporary location
|
61 |
+
speaker_file_path = os.path.join('/tmp', speaker_wav.name)
|
62 |
with open(speaker_file_path, "wb") as destination:
|
63 |
for chunk in speaker_wav.chunks():
|
64 |
destination.write(chunk)
|
|
|
82 |
pass
|
83 |
|
84 |
# Use the file_iterator to create a FileResponse
|
85 |
+
|
86 |
+
# TextToSpeech.objects.create(
|
87 |
+
# text=text,
|
88 |
+
# speaker_wav=speaker_wav,
|
89 |
+
# language=language,
|
90 |
+
# created_by=request.user # Assign the authenticated user here
|
91 |
+
# )
|
92 |
response = FileResponse(file_iterator(output_filename), as_attachment=True, content_type='audio/wav')
|
93 |
return response
|
94 |
|