Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -19,8 +19,25 @@ from transformers import pipeline
|
|
19 |
import click
|
20 |
import soundfile as sf
|
21 |
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
print(f"Using {device} device")
|
25 |
|
26 |
# Use smaller, CPU-friendly models
|
@@ -34,11 +51,11 @@ vocos = Vocos.from_pretrained("charactr/vocos-mel-24khz")
|
|
34 |
|
35 |
# Reduce computational intensity
|
36 |
target_sample_rate = 24000
|
37 |
-
n_mel_channels =
|
38 |
hop_length = 256 # Increased from 256
|
39 |
target_rms = 0.1
|
40 |
nfe_step = 12 # Reduced from 8
|
41 |
-
cfg_strength =
|
42 |
ode_method = "euler"
|
43 |
sway_sampling_coef = -1
|
44 |
speed = 1
|
|
|
19 |
import click
|
20 |
import soundfile as sf
|
21 |
|
22 |
+
try:
|
23 |
+
import spaces
|
24 |
+
USING_SPACES = True
|
25 |
+
except ImportError:
|
26 |
+
USING_SPACES = False
|
27 |
+
|
28 |
+
def gpu_decorator(func):
|
29 |
+
if USING_SPACES:
|
30 |
+
return spaces.GPU(func)
|
31 |
+
else:
|
32 |
+
return func
|
33 |
+
|
34 |
+
device = (
|
35 |
+
"gpu"
|
36 |
+
if torch.cuda.is_available()
|
37 |
+
else "mps" if torch.backends.mps.is_available() else "cpu"
|
38 |
+
)
|
39 |
+
|
40 |
+
print(f"Using {device} device")
|
41 |
print(f"Using {device} device")
|
42 |
|
43 |
# Use smaller, CPU-friendly models
|
|
|
51 |
|
52 |
# Reduce computational intensity
|
53 |
target_sample_rate = 24000
|
54 |
+
n_mel_channels = 80 # Reduced from 100
|
55 |
hop_length = 256 # Increased from 256
|
56 |
target_rms = 0.1
|
57 |
nfe_step = 12 # Reduced from 8
|
58 |
+
cfg_strength = 1.5 # Reduced from 2.0
|
59 |
ode_method = "euler"
|
60 |
sway_sampling_coef = -1
|
61 |
speed = 1
|