Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,27 +3,35 @@ import os, gradio as gr, spaces
|
|
3 |
from huggingface_hub import snapshot_download
|
4 |
from indextts.infer import IndexTTS
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
8 |
|
9 |
tts = None
|
10 |
def load():
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
13 |
|
14 |
@spaces.GPU
|
15 |
def synth(ref_wav, prompt):
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
|
21 |
with gr.Blocks() as demo:
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
|
28 |
demo.queue()
|
29 |
demo.launch(show_api=False, ssr_mode=False)
|
|
|
3 |
from huggingface_hub import snapshot_download
|
4 |
from indextts.infer import IndexTTS
|
5 |
|
6 |
+
os.environ["DS_BUILD_OPS"] = "0" # block any JIT build if deepspeed sneaks in
|
7 |
+
|
8 |
+
model_dir = snapshot_download("IndexTeam/IndexTTS-1.5",
|
9 |
+
local_dir="checkpoints",
|
10 |
+
local_dir_use_symlinks=False)
|
11 |
+
cfg_path = os.path.join(model_dir, "config.yaml")
|
12 |
|
13 |
tts = None
|
14 |
def load():
|
15 |
+
global tts
|
16 |
+
if tts is None:
|
17 |
+
# the key bit → force plain pytorch
|
18 |
+
tts = IndexTTS(model_dir=model_dir,
|
19 |
+
cfg_path=cfg_path,
|
20 |
+
use_deepspeed=False) # <- param exists in IndexTTS 1.5
|
21 |
|
22 |
@spaces.GPU
|
23 |
def synth(ref_wav, prompt):
|
24 |
+
load()
|
25 |
+
out = "out.wav"
|
26 |
+
tts.infer(ref_wav, prompt, out)
|
27 |
+
return out
|
28 |
|
29 |
with gr.Blocks() as demo:
|
30 |
+
gr.Markdown("# index-tts 1.5 zerogpu")
|
31 |
+
txt = gr.Textbox(label="text prompt")
|
32 |
+
ref = gr.Audio(label="reference voice", type="filepath")
|
33 |
+
gen = gr.Audio(label="generated speech", type="filepath")
|
34 |
+
gr.Button("generate").click(synth, [ref, txt], gen)
|
35 |
|
36 |
demo.queue()
|
37 |
demo.launch(show_api=False, ssr_mode=False)
|