Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import torch
|
|
3 |
import os
|
4 |
from kokoro import generate
|
5 |
from models import build_model
|
|
|
6 |
|
7 |
# Initialize model and device
|
8 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
@@ -23,7 +24,7 @@ voices = {
|
|
23 |
'af_sky': torch.load("voices/af_sky.pt", weights_only=True)
|
24 |
}
|
25 |
|
26 |
-
|
27 |
def parse_voice_formula(formula):
|
28 |
"""Parse the voice formula string and return the combined voice tensor."""
|
29 |
if not formula.strip():
|
@@ -55,6 +56,7 @@ def parse_voice_formula(formula):
|
|
55 |
|
56 |
return weighted_sum
|
57 |
|
|
|
58 |
def get_new_voice(formula):
|
59 |
try:
|
60 |
# Parse the formula and get the combined voice tensor
|
@@ -67,6 +69,7 @@ def get_new_voice(formula):
|
|
67 |
except Exception as e:
|
68 |
raise gr.Error(f"Failed to create voice: {str(e)}")
|
69 |
|
|
|
70 |
def text_to_speech(text, formula):
|
71 |
try:
|
72 |
if not text.strip():
|
|
|
3 |
import os
|
4 |
from kokoro import generate
|
5 |
from models import build_model
|
6 |
+
import spaces
|
7 |
|
8 |
# Initialize model and device
|
9 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
|
|
24 |
'af_sky': torch.load("voices/af_sky.pt", weights_only=True)
|
25 |
}
|
26 |
|
27 |
+
@spaces.GPU
|
28 |
def parse_voice_formula(formula):
|
29 |
"""Parse the voice formula string and return the combined voice tensor."""
|
30 |
if not formula.strip():
|
|
|
56 |
|
57 |
return weighted_sum
|
58 |
|
59 |
+
@spaces.GPU
|
60 |
def get_new_voice(formula):
|
61 |
try:
|
62 |
# Parse the formula and get the combined voice tensor
|
|
|
69 |
except Exception as e:
|
70 |
raise gr.Error(f"Failed to create voice: {str(e)}")
|
71 |
|
72 |
+
@spaces.GPU
|
73 |
def text_to_speech(text, formula):
|
74 |
try:
|
75 |
if not text.strip():
|