Spaces:
Sleeping
Sleeping
Upload myinfer_latest.py
Browse files- myinfer_latest.py +20 -1
myinfer_latest.py
CHANGED
|
@@ -360,7 +360,7 @@ def vc_single(
|
|
| 360 |
thread_name = threading.current_thread().name
|
| 361 |
print(f"Thread {thread_name}: Hash {hash_val}")
|
| 362 |
|
| 363 |
-
|
| 364 |
sample_and_print(audio_opt,thread_name)
|
| 365 |
# Print the hash and thread information
|
| 366 |
if resample_sr >= 16000 and tgt_sr != resample_sr:
|
|
@@ -394,6 +394,25 @@ def vc_single(
|
|
| 394 |
|
| 395 |
return info, (None, None)
|
| 396 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 397 |
def sample_and_print(array, thread_name):
|
| 398 |
# Ensure the array has more than 10 elements; otherwise, use the array length
|
| 399 |
num_samples = 10 if len(array) > 10 else len(array)
|
|
|
|
| 360 |
thread_name = threading.current_thread().name
|
| 361 |
print(f"Thread {thread_name}: Hash {hash_val}")
|
| 362 |
|
| 363 |
+
save_audio_with_thread_id(audio_opt)
|
| 364 |
sample_and_print(audio_opt,thread_name)
|
| 365 |
# Print the hash and thread information
|
| 366 |
if resample_sr >= 16000 and tgt_sr != resample_sr:
|
|
|
|
| 394 |
|
| 395 |
return info, (None, None)
|
| 396 |
|
| 397 |
+
def save_audio_with_thread_id(audio_opt, output_dir="output"):
|
| 398 |
+
# Ensure the output directory exists
|
| 399 |
+
os.makedirs(output_dir, exist_ok=True)
|
| 400 |
+
|
| 401 |
+
# Get the current thread ID or name
|
| 402 |
+
thread_id = threading.current_thread().name
|
| 403 |
+
|
| 404 |
+
# Construct the filename using the thread ID
|
| 405 |
+
filename = f"audio_{thread_id}.wav"
|
| 406 |
+
output_path = os.path.join(output_dir, filename)
|
| 407 |
+
|
| 408 |
+
# Assuming the target sample rate is defined elsewhere; replace as necessary
|
| 409 |
+
tgt_sr = 16000 # Example sample rate, adjust according to your needs
|
| 410 |
+
|
| 411 |
+
# Write the audio file
|
| 412 |
+
sf.write(output_path, audio_opt, tgt_sr)
|
| 413 |
+
|
| 414 |
+
print(f"Saved {output_path}")
|
| 415 |
+
|
| 416 |
def sample_and_print(array, thread_name):
|
| 417 |
# Ensure the array has more than 10 elements; otherwise, use the array length
|
| 418 |
num_samples = 10 if len(array) > 10 else len(array)
|