Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ from TTS.api import TTS
|
|
| 5 |
|
| 6 |
print("π Loading XTTS model once...")
|
| 7 |
|
| 8 |
-
#
|
| 9 |
os.environ["COQUI_TOS_AGREED"] = "1"
|
| 10 |
|
| 11 |
tts = TTS(
|
|
@@ -17,11 +17,8 @@ tts = TTS(
|
|
| 17 |
print("β
Model loaded!")
|
| 18 |
|
| 19 |
def synthesize(text, speaker_wav):
|
| 20 |
-
if not text:
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
if speaker_wav is None:
|
| 24 |
-
raise gr.Error("Please upload a speaker WAV (5β10 seconds clean voice).")
|
| 25 |
|
| 26 |
out_path = os.path.join(tempfile.gettempdir(), "out.wav")
|
| 27 |
|
|
@@ -35,22 +32,17 @@ def synthesize(text, speaker_wav):
|
|
| 35 |
return out_path
|
| 36 |
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
fn=synthesize,
|
| 50 |
-
inputs=[text, speaker],
|
| 51 |
-
outputs=out_audio,
|
| 52 |
-
api_name="tts" # <-- IMPORTANT: exposes /tts endpoint
|
| 53 |
-
)
|
| 54 |
|
| 55 |
-
|
| 56 |
-
demo.
|
|
|
|
| 5 |
|
| 6 |
print("π Loading XTTS model once...")
|
| 7 |
|
| 8 |
+
# Accept Coqui license automatically
|
| 9 |
os.environ["COQUI_TOS_AGREED"] = "1"
|
| 10 |
|
| 11 |
tts = TTS(
|
|
|
|
| 17 |
print("β
Model loaded!")
|
| 18 |
|
| 19 |
def synthesize(text, speaker_wav):
|
| 20 |
+
if not text or speaker_wav is None:
|
| 21 |
+
raise gr.Error("Please provide both text and speaker WAV.")
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
out_path = os.path.join(tempfile.gettempdir(), "out.wav")
|
| 24 |
|
|
|
|
| 32 |
return out_path
|
| 33 |
|
| 34 |
|
| 35 |
+
demo = gr.Interface(
|
| 36 |
+
fn=synthesize,
|
| 37 |
+
inputs=[
|
| 38 |
+
gr.Textbox(label="Text"),
|
| 39 |
+
gr.Audio(label="Speaker WAV (5β10s clean voice)", type="filepath"),
|
| 40 |
+
],
|
| 41 |
+
outputs=gr.Audio(label="Generated Voice", type="filepath"),
|
| 42 |
+
title="XTTS Voice Cloning API (Offline, HF Space)",
|
| 43 |
+
description="Upload 5β10 seconds clean voice sample + enter text.",
|
| 44 |
+
api_name="tts" # β
THIS FIXES 'No API found'
|
| 45 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
+
demo.queue()
|
| 48 |
+
demo.launch()
|