Update app.py
Browse files
app.py
CHANGED
|
@@ -6,19 +6,25 @@ import torch
|
|
| 6 |
os.environ["COQUI_TOS_AGREED"] = "1"
|
| 7 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 8 |
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
def clone(text, lang, ref):
|
| 12 |
-
|
| 13 |
tts.tts_to_file(text=text, file_path=out, speaker_wav=ref, language=lang)
|
| 14 |
return out
|
| 15 |
|
| 16 |
-
LANGS = ["en","es","fr","de","it","pt","pl","tr","ru","nl","cs","ar","zh-cn","ja","ko","hu"
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
demo.launch()
|
|
|
|
| 6 |
os.environ["COQUI_TOS_AGREED"] = "1"
|
| 7 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 8 |
|
| 9 |
+
print("Loading XTTS...")
|
| 10 |
+
try:
|
| 11 |
+
# Try direct ID loading which works on most versions
|
| 12 |
+
tts = TTS(model_name="tts_models/multilingual/multi-dataset/xtts_v2", progress_bar=False).to(device)
|
| 13 |
+
except Exception as e:
|
| 14 |
+
print(f"Error loading by name: {e}")
|
| 15 |
+
# Fallback to general initialization which triggers download
|
| 16 |
+
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device)
|
| 17 |
|
| 18 |
def clone(text, lang, ref):
|
| 19 |
+
out = "out.wav"
|
| 20 |
tts.tts_to_file(text=text, file_path=out, speaker_wav=ref, language=lang)
|
| 21 |
return out
|
| 22 |
|
| 23 |
+
LANGS = ["en","es","fr","de","it","pt","pl","tr","ru","nl","cs","ar","zh-cn","ja","ko","hu"
|
| 24 |
+
with gr.Blocks() as demo:
|
| 25 |
+
t=gr.Textbox(label="Text")
|
| 26 |
+
l=gr.Dropdown(label="Lang", choices=LANGS, value="fr")
|
| 27 |
+
r=gr.Audio(label="Ref", type="filepath")
|
| 28 |
+
o=gr.Audio(label="Out")
|
| 29 |
+
gr.Button("Generate").click(clone, [t,l,r], [o])
|
| 30 |
+
demo.launch()]
|
|
|