Update app.py
Browse files
app.py
CHANGED
|
@@ -2,38 +2,36 @@ from TTS.api import TTS
|
|
| 2 |
import gradio as gr
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
print("π Model dir contents:", os.listdir(MODEL_DIR))
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
print(os.listdir("/models"))
|
| 11 |
-
print(os.listdir("/models/xtts"))
|
| 12 |
-
|
| 13 |
|
| 14 |
tts = TTS(
|
| 15 |
-
model_path=
|
| 16 |
-
config_path=
|
| 17 |
gpu=False
|
| 18 |
)
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
| 22 |
tts.tts_to_file(
|
| 23 |
text=text,
|
| 24 |
-
speaker_wav=
|
| 25 |
-
|
| 26 |
-
|
| 27 |
)
|
| 28 |
return out_path
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
)
|
|
|
|
|
|
|
| 38 |
|
| 39 |
-
demo.
|
|
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
print("π Loading XTTS model once...")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
tts = TTS(
|
| 8 |
+
model_path="/models/xtts/model.pth",
|
| 9 |
+
config_path="/models/xtts/config.json",
|
| 10 |
gpu=False
|
| 11 |
)
|
| 12 |
|
| 13 |
+
print("β
Model loaded!")
|
| 14 |
+
|
| 15 |
+
def generate(text, voice):
|
| 16 |
+
out_path = "out.wav"
|
| 17 |
tts.tts_to_file(
|
| 18 |
text=text,
|
| 19 |
+
speaker_wav=voice,
|
| 20 |
+
language="en",
|
| 21 |
+
file_path=out_path
|
| 22 |
)
|
| 23 |
return out_path
|
| 24 |
|
| 25 |
+
with gr.Blocks() as demo:
|
| 26 |
+
gr.Markdown("# π XTTS Voice Clone API (HF Space)")
|
| 27 |
+
|
| 28 |
+
text = gr.Textbox(label="Text")
|
| 29 |
+
voice = gr.Audio(type="filepath", label="Upload Voice Sample (WAV)")
|
| 30 |
+
|
| 31 |
+
btn = gr.Button("Generate Voice")
|
| 32 |
+
out = gr.Audio(label="Output Audio")
|
| 33 |
+
|
| 34 |
+
btn.click(generate, inputs=[text, voice], outputs=out)
|
| 35 |
|
| 36 |
+
demo.queue()
|
| 37 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|