renator commited on
Commit
e2882d6
1 Parent(s): df4965a
Dockerfile CHANGED
@@ -58,4 +58,4 @@ ENV COQUI_TOS_AGREED=1
58
  RUN python manage.py migrate
59
 
60
  # Use Django's built-in server to serve the app
61
- CMD ["python", "manage.py", "runserver", "0.0.0.0:7860"]
 
58
  RUN python manage.py migrate
59
 
60
  # Use Django's built-in server to serve the app
61
+ CMD ["python3", "manage.py", "runserver", "0.0.0.0:7860"]
config/settings.py CHANGED
@@ -13,7 +13,6 @@ https://docs.djangoproject.com/en/5.0/ref/settings/
13
 
14
  import os
15
  from pathlib import Path
16
- import logging
17
 
18
 
19
  # Build paths inside the project like this: BASE_DIR / 'subdir'.
@@ -52,7 +51,7 @@ INSTALLED_APPS = [
52
  CORS_ALLOW_ALL_ORIGINS = True # If this is used then `CORS_ALLOWED_ORIGINS` will not have any effect
53
  CORS_ALLOW_CREDENTIALS = True
54
  CORS_ALLOWED_ORIGINS = [
55
- 'https://undetectable-voice-clone.hf.space',
56
  ]
57
 
58
  REST_FRAMEWORK = {
@@ -73,29 +72,6 @@ SWAGGER_SETTINGS = {
73
  }
74
  }
75
  }
76
- LOGGING = {
77
- 'version': 1,
78
- 'disable_existing_loggers': False,
79
- 'handlers': {
80
- 'file': {
81
- 'level': 'DEBUG', # Choose the desired logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
82
- 'class': 'logging.FileHandler',
83
- 'filename': 'project.log', # Path to the log file
84
- },
85
- },
86
- 'loggers': {
87
- 'django': {
88
- 'handlers': ['file'],
89
- 'level': 'DEBUG', # Set the level for Django-related logs
90
- 'propagate': True,
91
- },
92
- 'myapp': {
93
- 'handlers': ['file'],
94
- 'level': 'DEBUG', # Set the level for your app's logs
95
- 'propagate': True,
96
- },
97
- },
98
- }
99
 
100
  X_FRAME_OPTIONS = 'ALLOW-FROM https://huggingface.co/'
101
 
@@ -137,11 +113,19 @@ WSGI_APPLICATION = 'config.wsgi.application'
137
 
138
  DATABASES = {
139
  'default': {
140
- 'ENGINE': 'django.db.backends.sqlite3',
141
- 'NAME': BASE_DIR / 'db.sqlite3',
 
 
 
 
142
  }
143
  }
144
 
 
 
 
 
145
 
146
  # Password validation
147
  # https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
@@ -181,13 +165,6 @@ STATIC_URL = 'static/'
181
  MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
182
  MEDIA_URL = '/media/'
183
 
184
- # settings.py
185
-
186
- MINIO_ENDPOINT = '64.176.199.162:9000'
187
- MINIO_ACCESS_KEY = 'voice-clone'
188
- MINIO_SECRET_KEY = 'voice-clone'
189
- MINIO_SECURE = False # Change to True if using HTTPS
190
-
191
  # Default primary key field type
192
  # https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
193
 
 
13
 
14
  import os
15
  from pathlib import Path
 
16
 
17
 
18
  # Build paths inside the project like this: BASE_DIR / 'subdir'.
 
51
  CORS_ALLOW_ALL_ORIGINS = True # If this is used then `CORS_ALLOWED_ORIGINS` will not have any effect
52
  CORS_ALLOW_CREDENTIALS = True
53
  CORS_ALLOWED_ORIGINS = [
54
+ 'https://undetectable-voice-clone.hf.space', "http://94.101.98.237:7860"
55
  ]
56
 
57
  REST_FRAMEWORK = {
 
72
  }
73
  }
74
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  X_FRAME_OPTIONS = 'ALLOW-FROM https://huggingface.co/'
77
 
 
113
 
114
  DATABASES = {
115
  'default': {
116
+ 'ENGINE': 'django.db.backends.postgresql',
117
+ 'NAME': 'voice-clone',
118
+ 'USER': 'postgres',
119
+ 'PASSWORD': 'postgres', # Assuming you want to use the POSTGRES_PASSWORD from Docker Compose
120
+ 'HOST': '94.101.98.237', # Use the service name defined in Docker Compose
121
+ 'PORT': '5432',
122
  }
123
  }
124
 
125
+ MINIO_ENDPOINT = '94.101.98.237:9000' # Use the service name defined in Docker Compose
126
+ MINIO_ACCESS_KEY = 'voice-clone'
127
+ MINIO_SECRET_KEY = 'voice-clone'
128
+ MINIO_SECURE = False # Change to True if using HTTPS
129
 
130
  # Password validation
131
  # https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
 
165
  MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
166
  MEDIA_URL = '/media/'
167
 
 
 
 
 
 
 
 
168
  # Default primary key field type
169
  # https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
170
 
requirements.txt CHANGED
@@ -14,6 +14,7 @@ djangorestframework
14
  drf-yasg
15
  django-cors-headers
16
  minio
 
17
 
18
  # fastapi==0.70.0
19
  # uvicorn==0.15.0
 
14
  drf-yasg
15
  django-cors-headers
16
  minio
17
+ psycopg2-binary
18
 
19
  # fastapi==0.70.0
20
  # uvicorn==0.15.0
texttovoice/migrations/0001_initial.py CHANGED
@@ -1,4 +1,4 @@
1
- # Generated by Django 5.0.1 on 2024-02-07 16:14
2
 
3
  import django.db.models.deletion
4
  from django.conf import settings
@@ -19,9 +19,9 @@ class Migration(migrations.Migration):
19
  fields=[
20
  ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
21
  ('created_date', models.DateTimeField(auto_now_add=True)),
22
- ('text', models.CharField(default='In the quest for a sustainable future, renewable energy emerges as a beacon of hope', max_length=255)),
23
- ('speaker_wav', models.CharField(max_length=255)),
24
- ('output_wav', models.CharField(max_length=255)),
25
  ('language', models.CharField(default='en', max_length=2)),
26
  ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_created_by', to=settings.AUTH_USER_MODEL)),
27
  ],
 
1
+ # Generated by Django 5.0.1 on 2024-02-22 08:28
2
 
3
  import django.db.models.deletion
4
  from django.conf import settings
 
19
  fields=[
20
  ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
21
  ('created_date', models.DateTimeField(auto_now_add=True)),
22
+ ('text', models.TextField(default='In the quest for a sustainable future, renewable energy emerges as a beacon of hope')),
23
+ ('speaker_wav', models.TextField()),
24
+ ('output_wav', models.TextField()),
25
  ('language', models.CharField(default='en', max_length=2)),
26
  ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_created_by', to=settings.AUTH_USER_MODEL)),
27
  ],
texttovoice/models.py CHANGED
@@ -13,12 +13,11 @@ class BaseModel(models.Model):
13
  abstract = True
14
  ordering = ["-created_date"]
15
  class TextToSpeech(BaseModel):
16
- text = models.CharField(
17
- max_length=255,
18
  default="In the quest for a sustainable future, renewable energy emerges as a beacon of hope"
19
  )
20
- speaker_wav = models.CharField( max_length=255)
21
- output_wav = models.CharField( max_length=255)
22
  language = models.CharField(
23
  max_length=2, # Adjust the max length based on your language code requirements
24
  default="en"
 
13
  abstract = True
14
  ordering = ["-created_date"]
15
  class TextToSpeech(BaseModel):
16
+ text = models.TextField(
 
17
  default="In the quest for a sustainable future, renewable energy emerges as a beacon of hope"
18
  )
19
+ speaker_wav = models.TextField()
20
+ output_wav = models.TextField()
21
  language = models.CharField(
22
  max_length=2, # Adjust the max length based on your language code requirements
23
  default="en"
texttovoice/views.py CHANGED
@@ -1,7 +1,6 @@
1
  from datetime import timedelta
2
  import os
3
  import uuid
4
- import logging
5
  import torch
6
  from rest_framework import status
7
  from rest_framework.response import Response
@@ -19,7 +18,6 @@ from .minio_utils import get_minio_client # Ensure this import matches your fil
19
 
20
  minio_client = get_minio_client()
21
 
22
- logger = logging.getLogger(__name__)
23
  BUCKET_NAME = "voice-clone"
24
 
25
  class TextToSpeechCreateView(CreateAPIView):
@@ -90,7 +88,7 @@ class TextToSpeechCreateView(CreateAPIView):
90
 
91
  return Response(response_data, status=status.HTTP_201_CREATED)
92
  except Exception as e:
93
- logger.error(f"Error processing request: {str(e)}")
94
  return Response({"error": "An error occurred processing your request."}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
95
  finally:
96
  # Ensure cleanup happens
@@ -116,10 +114,8 @@ class TextToSpeechCreateView(CreateAPIView):
116
  try:
117
  os.remove(file_path)
118
  except Exception as e:
119
- logger.error(f"Failed to delete temporary file {file_path}: {e}")
120
-
121
-
122
-
123
 
124
  class TextToSpeechListView(ListAPIView):
125
  serializer_class = TextToSpeechSerializerResponseWithURL
@@ -147,5 +143,5 @@ class TextToSpeechListView(ListAPIView):
147
  presigned_url = minio_client.presigned_get_object(bucket, object_name, expires=timedelta(hours=1))
148
  return presigned_url
149
  except Exception as e:
150
- logger.error(f"Failed to generate presigned URL for {object_path}: {e}")
151
  return None
 
1
  from datetime import timedelta
2
  import os
3
  import uuid
 
4
  import torch
5
  from rest_framework import status
6
  from rest_framework.response import Response
 
18
 
19
  minio_client = get_minio_client()
20
 
 
21
  BUCKET_NAME = "voice-clone"
22
 
23
  class TextToSpeechCreateView(CreateAPIView):
 
88
 
89
  return Response(response_data, status=status.HTTP_201_CREATED)
90
  except Exception as e:
91
+ print("Error due to ",e)
92
  return Response({"error": "An error occurred processing your request."}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
93
  finally:
94
  # Ensure cleanup happens
 
114
  try:
115
  os.remove(file_path)
116
  except Exception as e:
117
+ print(e)
118
+ pass
 
 
119
 
120
  class TextToSpeechListView(ListAPIView):
121
  serializer_class = TextToSpeechSerializerResponseWithURL
 
143
  presigned_url = minio_client.presigned_get_object(bucket, object_name, expires=timedelta(hours=1))
144
  return presigned_url
145
  except Exception as e:
146
+ print(e)
147
  return None