Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
import gradio as gr
|
| 3 |
+
from TTS.api import TTS
|
| 4 |
+
import torch
|
| 5 |
|
| 6 |
+
os.environ["COQUI_TOS_AGREED"] = "1"
|
| 7 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 8 |
|
| 9 |
+
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device)
|
| 10 |
+
|
| 11 |
+
def clone(text, lang, ref):
|
| 12 |
+
out = "out.wav"
|
| 13 |
+
tts.tts_to_file(text=text, file_path=out, speaker_wav=ref, language=lang)
|
| 14 |
+
return out
|
| 15 |
+
|
| 16 |
+
with gr.Blocks() as demo:
|
| 17 |
+
t=gr.Textbox()
|
| 18 |
+
l=gr.Dropdown(["fr","en","es","de","it"],value="fr")
|
| 19 |
+
r=gr.Audio(type="filepath")
|
| 20 |
+
o=gr.Audio()
|
| 21 |
+
gr.Button("Go").click(clone, [t,l,r], [o])
|
| 22 |
+
demo.launch()
|