Spaces:
Sleeping
Sleeping
Upload infer_serverless.py
Browse files- infer_serverless.py +11 -29
infer_serverless.py
CHANGED
@@ -14,7 +14,7 @@ from scipy.io import wavfile
|
|
14 |
from datetime import datetime
|
15 |
from urllib.parse import urlparse
|
16 |
from mega import Mega
|
17 |
-
|
18 |
import base64
|
19 |
import tempfile
|
20 |
import threading
|
@@ -28,7 +28,7 @@ from threading import Lock
|
|
28 |
from multiprocessing import Process, SimpleQueue, set_start_method,get_context
|
29 |
from queue import Empty
|
30 |
from pydub import AudioSegment
|
31 |
-
|
32 |
import io
|
33 |
import runpod
|
34 |
import boto3
|
@@ -78,13 +78,6 @@ f0method_mode = ["pm", "harvest", "crepe"]
|
|
78 |
f0method_info = "PM is fast, Harvest is good but extremely slow, and Crepe effect is good but requires GPU (Default: PM)"
|
79 |
|
80 |
|
81 |
-
def index():
|
82 |
-
# Check if user is logged in
|
83 |
-
return render_template("ui.html")
|
84 |
-
#if google.authorized:
|
85 |
-
# return render_template("index.html", logged_in=True)
|
86 |
-
#else:
|
87 |
-
# return render_template("index.html", logged_in=False)
|
88 |
|
89 |
|
90 |
|
@@ -181,14 +174,14 @@ def upload_file(local_file_path,bucket_name):
|
|
181 |
response=client.upload_file(local_file_path, bucket_name, filename)
|
182 |
|
183 |
except client.exceptions.NoSuchKey:
|
184 |
-
return
|
185 |
except Exception as e:
|
186 |
-
return
|
187 |
|
188 |
# Optional: Send the file directly to the client
|
189 |
# return send_file(local_file_path, as_attachment=True)
|
190 |
|
191 |
-
return
|
192 |
|
193 |
|
194 |
|
@@ -216,22 +209,17 @@ def download_file(filename,bucket_name):
|
|
216 |
try:
|
217 |
client.download_file(bucket_name, object_key, local_file_path)
|
218 |
except client.exceptions.NoSuchKey:
|
219 |
-
return
|
220 |
except Exception as e:
|
221 |
-
return
|
222 |
|
223 |
# Optional: Send the file directly to the client
|
224 |
# return send_file(local_file_path, as_attachment=True)
|
225 |
|
226 |
-
return
|
227 |
|
228 |
|
229 |
-
|
230 |
-
directory = 'weights'
|
231 |
-
files = os.listdir(directory)
|
232 |
-
# Extract filenames without their extensions
|
233 |
-
filenames = [os.path.splitext(file)[0] for file in files if os.path.isfile(os.path.join(directory, file))]
|
234 |
-
return jsonify(filenames)
|
235 |
|
236 |
|
237 |
|
@@ -242,7 +230,7 @@ def get_status(audio_id):
|
|
242 |
# Retrieve the task status using the unique ID
|
243 |
print(audio_id)
|
244 |
status_info = task_status_tracker.get(audio_id, {"status": "Unknown ID", "percentage": 0})
|
245 |
-
return
|
246 |
|
247 |
processed_audio_storage = {}
|
248 |
|
@@ -250,7 +238,7 @@ def api_convert_voice(filename,spk_id1,unique_id):
|
|
250 |
acquired = request_semaphore.acquire(blocking=False)
|
251 |
|
252 |
if not acquired:
|
253 |
-
return
|
254 |
#task_status_tracker[unique_id] = {"status": "Starting", "percentage": 0}
|
255 |
try:
|
256 |
|
@@ -364,12 +352,6 @@ def get_vc_safe(sid, to_return_protect0):
|
|
364 |
|
365 |
|
366 |
|
367 |
-
def get_processed_audio(audio_id):
|
368 |
-
# Retrieve the path from temporary storage or session
|
369 |
-
if audio_id in processed_audio_storage:
|
370 |
-
file_path = processed_audio_storage[audio_id]
|
371 |
-
return send_file(file_path, as_attachment=True)
|
372 |
-
return jsonify({"error": "File not found."}), 404
|
373 |
|
374 |
def worker(spk_id, input_audio_path, voice_transform, unique_id, output_queue):
|
375 |
try:
|
|
|
14 |
from datetime import datetime
|
15 |
from urllib.parse import urlparse
|
16 |
from mega import Mega
|
17 |
+
|
18 |
import base64
|
19 |
import tempfile
|
20 |
import threading
|
|
|
28 |
from multiprocessing import Process, SimpleQueue, set_start_method,get_context
|
29 |
from queue import Empty
|
30 |
from pydub import AudioSegment
|
31 |
+
|
32 |
import io
|
33 |
import runpod
|
34 |
import boto3
|
|
|
78 |
f0method_info = "PM is fast, Harvest is good but extremely slow, and Crepe effect is good but requires GPU (Default: PM)"
|
79 |
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
|
83 |
|
|
|
174 |
response=client.upload_file(local_file_path, bucket_name, filename)
|
175 |
|
176 |
except client.exceptions.NoSuchKey:
|
177 |
+
return "error: File not found in the bucket"
|
178 |
except Exception as e:
|
179 |
+
return "error: File not found in the bucket"
|
180 |
|
181 |
# Optional: Send the file directly to the client
|
182 |
# return send_file(local_file_path, as_attachment=True)
|
183 |
|
184 |
+
return "success"
|
185 |
|
186 |
|
187 |
|
|
|
209 |
try:
|
210 |
client.download_file(bucket_name, object_key, local_file_path)
|
211 |
except client.exceptions.NoSuchKey:
|
212 |
+
return "file not in buecket"
|
213 |
except Exception as e:
|
214 |
+
return "exception"
|
215 |
|
216 |
# Optional: Send the file directly to the client
|
217 |
# return send_file(local_file_path, as_attachment=True)
|
218 |
|
219 |
+
return "success"
|
220 |
|
221 |
|
222 |
+
|
|
|
|
|
|
|
|
|
|
|
223 |
|
224 |
|
225 |
|
|
|
230 |
# Retrieve the task status using the unique ID
|
231 |
print(audio_id)
|
232 |
status_info = task_status_tracker.get(audio_id, {"status": "Unknown ID", "percentage": 0})
|
233 |
+
return "status"
|
234 |
|
235 |
processed_audio_storage = {}
|
236 |
|
|
|
238 |
acquired = request_semaphore.acquire(blocking=False)
|
239 |
|
240 |
if not acquired:
|
241 |
+
return "error in lock"
|
242 |
#task_status_tracker[unique_id] = {"status": "Starting", "percentage": 0}
|
243 |
try:
|
244 |
|
|
|
352 |
|
353 |
|
354 |
|
|
|
|
|
|
|
|
|
|
|
|
|
355 |
|
356 |
def worker(spk_id, input_audio_path, voice_transform, unique_id, output_queue):
|
357 |
try:
|