Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -23,9 +23,11 @@ os.environ["COQUI_TOS_AGREED"] = "1"
|
|
23 |
device = "cuda"
|
24 |
|
25 |
tts = TTS("tts_models/multilingual/multi-dataset/xtts_bill_spa").to(device)
|
26 |
-
|
|
|
|
|
|
|
27 |
|
28 |
-
"""
|
29 |
def clear_gpu_cache():
|
30 |
# clear the GPU cache
|
31 |
if torch.cuda.is_available():
|
@@ -46,7 +48,6 @@ def load_model(xtts_checkpoint, xtts_config, xtts_vocab):
|
|
46 |
XTTS_MODEL.cuda()
|
47 |
|
48 |
print("Model Loaded!")
|
49 |
-
return "Model Loaded!"
|
50 |
|
51 |
def run_tts(lang='es', tts_text, speaker_audio_file):
|
52 |
if XTTS_MODEL is None or not speaker_audio_file:
|
@@ -69,14 +70,16 @@ def run_tts(lang='es', tts_text, speaker_audio_file):
|
|
69 |
out["wav"] = torch.tensor(out["wav"]).unsqueeze(0)
|
70 |
out_path = fp.name
|
71 |
torchaudio.save(out_path, out["wav"], 24000)
|
|
|
|
|
|
|
72 |
|
73 |
-
return "Speech generated !", out_path, speaker_audio_file
|
74 |
-
"""
|
75 |
|
76 |
@spaces.GPU(enable_queue=True)
|
77 |
def generate(text, audio):
|
78 |
-
|
79 |
-
|
|
|
80 |
|
81 |
demo = gr.Interface(
|
82 |
fn=generate,
|
|
|
23 |
device = "cuda"
|
24 |
|
25 |
tts = TTS("tts_models/multilingual/multi-dataset/xtts_bill_spa").to(device)
|
26 |
+
model_path = '/home/user/.local/share/tts/tts_models--multilingual--multi-dataset--xtts_bill_spa/model.pth'
|
27 |
+
config_path = '/home/user/.local/share/tts/tts_models--multilingual--multi-dataset--xtts_bill_spa/config.json'
|
28 |
+
vocab_path = '/home/user/.local/share/tts/tts_models--multilingual--multi-dataset--xtts_bill_spa/vocab.json'
|
29 |
+
|
30 |
|
|
|
31 |
def clear_gpu_cache():
|
32 |
# clear the GPU cache
|
33 |
if torch.cuda.is_available():
|
|
|
48 |
XTTS_MODEL.cuda()
|
49 |
|
50 |
print("Model Loaded!")
|
|
|
51 |
|
52 |
def run_tts(lang='es', tts_text, speaker_audio_file):
|
53 |
if XTTS_MODEL is None or not speaker_audio_file:
|
|
|
70 |
out["wav"] = torch.tensor(out["wav"]).unsqueeze(0)
|
71 |
out_path = fp.name
|
72 |
torchaudio.save(out_path, out["wav"], 24000)
|
73 |
+
print("Speech generated !")
|
74 |
+
|
75 |
+
return out_path, speaker_audio_file
|
76 |
|
|
|
|
|
77 |
|
78 |
@spaces.GPU(enable_queue=True)
|
79 |
def generate(text, audio):
|
80 |
+
load_model(model_path, config_path, vocab_path)
|
81 |
+
out_path, speaker_audio_file = run_tts(lang='es', tts_text=text, speaker_audio_file=audio)
|
82 |
+
return out_path
|
83 |
|
84 |
demo = gr.Interface(
|
85 |
fn=generate,
|