Spaces:
Running on Zero
Running on Zero
Update core.py
Browse files
core.py
CHANGED
|
@@ -4,6 +4,10 @@ import json
|
|
| 4 |
import argparse
|
| 5 |
import subprocess
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
now_dir = os.getcwd()
|
| 8 |
sys.path.append(now_dir)
|
| 9 |
|
|
@@ -37,6 +41,7 @@ locales = list({voice["Locale"] for voice in voices_data})
|
|
| 37 |
|
| 38 |
|
| 39 |
# Infer
|
|
|
|
| 40 |
def run_infer_script(
|
| 41 |
f0up_key,
|
| 42 |
filter_radius,
|
|
@@ -55,6 +60,11 @@ def run_infer_script(
|
|
| 55 |
clean_strength,
|
| 56 |
export_format,
|
| 57 |
):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
infer_pipeline(
|
| 59 |
f0up_key,
|
| 60 |
filter_radius,
|
|
@@ -73,11 +83,13 @@ def run_infer_script(
|
|
| 73 |
clean_strength,
|
| 74 |
export_format,
|
| 75 |
)
|
|
|
|
| 76 |
return f"File {input_path} inferred successfully.", output_path.replace(
|
| 77 |
".wav", f".{export_format.lower()}"
|
| 78 |
)
|
| 79 |
|
| 80 |
|
|
|
|
| 81 |
# Batch infer
|
| 82 |
def run_batch_infer_script(
|
| 83 |
f0up_key,
|
|
|
|
| 4 |
import argparse
|
| 5 |
import subprocess
|
| 6 |
|
| 7 |
+
# اضافه کردن پشتیبانی از GPU و ZeroGPU
|
| 8 |
+
import spaces
|
| 9 |
+
import torch
|
| 10 |
+
|
| 11 |
now_dir = os.getcwd()
|
| 12 |
sys.path.append(now_dir)
|
| 13 |
|
|
|
|
| 41 |
|
| 42 |
|
| 43 |
# Infer
|
| 44 |
+
@spaces.GPU
|
| 45 |
def run_infer_script(
|
| 46 |
f0up_key,
|
| 47 |
filter_radius,
|
|
|
|
| 60 |
clean_strength,
|
| 61 |
export_format,
|
| 62 |
):
|
| 63 |
+
# بررسی و مقداردهی اولیه GPU
|
| 64 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 65 |
+
print(f"✅ Running inference on {device}")
|
| 66 |
+
|
| 67 |
+
# اجرای پردازش
|
| 68 |
infer_pipeline(
|
| 69 |
f0up_key,
|
| 70 |
filter_radius,
|
|
|
|
| 83 |
clean_strength,
|
| 84 |
export_format,
|
| 85 |
)
|
| 86 |
+
|
| 87 |
return f"File {input_path} inferred successfully.", output_path.replace(
|
| 88 |
".wav", f".{export_format.lower()}"
|
| 89 |
)
|
| 90 |
|
| 91 |
|
| 92 |
+
|
| 93 |
# Batch infer
|
| 94 |
def run_batch_infer_script(
|
| 95 |
f0up_key,
|