Spaces:
Configuration error
Configuration error
debugging
Browse files- texttovoice/serializers.py +1 -1
- texttovoice/views.py +13 -6
texttovoice/serializers.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
from rest_framework import serializers
|
2 |
|
3 |
class TextToSpeechSerializer(serializers.Serializer):
|
4 |
-
text = serializers.CharField()
|
5 |
speaker_wav = serializers.FileField()
|
6 |
language = serializers.CharField(default="en")
|
|
|
1 |
from rest_framework import serializers
|
2 |
|
3 |
class TextToSpeechSerializer(serializers.Serializer):
|
4 |
+
text = serializers.CharField(default="In the quest for a sustainable future, renewable energy emerges as a beacon of hope")
|
5 |
speaker_wav = serializers.FileField()
|
6 |
language = serializers.CharField(default="en")
|
texttovoice/views.py
CHANGED
@@ -15,8 +15,8 @@ from drf_yasg.utils import swagger_auto_schema
|
|
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 |
|
@@ -48,9 +48,16 @@ class TextToSpeechCreateView(CreateAPIView):
|
|
48 |
output_filename = f"output_{uuid.uuid4()}.wav"
|
49 |
|
50 |
# try:
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
# Save the uploaded speaker file to a temporary location
|
53 |
-
speaker_file_path = os.path.join(
|
54 |
with open(speaker_file_path, "wb") as destination:
|
55 |
for chunk in speaker_wav.chunks():
|
56 |
destination.write(chunk)
|
@@ -58,8 +65,8 @@ class TextToSpeechCreateView(CreateAPIView):
|
|
58 |
print("after creating the speaker file path",speaker_file_path)
|
59 |
|
60 |
# Generate speech using tts.tts_to_file
|
61 |
-
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2", gpu=False)
|
62 |
-
tts.tts_to_file(text=text, file_path=output_filename, speaker_wav=speaker_file_path, language=language)
|
63 |
|
64 |
# Define a function to delete the output file
|
65 |
def file_iterator(file_name):
|
|
|
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 |
|
|
|
48 |
output_filename = f"output_{uuid.uuid4()}.wav"
|
49 |
|
50 |
# try:
|
51 |
+
# Define the directory path
|
52 |
+
tmp_dir = "/tmp"
|
53 |
+
|
54 |
+
# Check if the directory exists and create it if it doesn't
|
55 |
+
if not os.path.exists(tmp_dir):
|
56 |
+
os.makedirs(tmp_dir)
|
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(tmp_dir, speaker_wav.name)
|
61 |
with open(speaker_file_path, "wb") as destination:
|
62 |
for chunk in speaker_wav.chunks():
|
63 |
destination.write(chunk)
|
|
|
65 |
print("after creating the speaker file path",speaker_file_path)
|
66 |
|
67 |
# Generate speech using tts.tts_to_file
|
68 |
+
# tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2", gpu=False)
|
69 |
+
# tts.tts_to_file(text=text, file_path=output_filename, speaker_wav=speaker_file_path, language=language)
|
70 |
|
71 |
# Define a function to delete the output file
|
72 |
def file_iterator(file_name):
|