GaneshSarode commited on
Commit
ae5ceb3
·
verified ·
1 Parent(s): bb0c4ac

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from TTS.api import TTS
3
+ import tempfile
4
+ import os
5
+
6
+ tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2", gpu=True)
7
+
8
+ def clone(text, speaker_wav):
9
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as f:
10
+ f.write(speaker_wav)
11
+ ref = f.name
12
+
13
+ out = ref.replace(".wav", "_out.wav")
14
+
15
+ tts.tts_to_file(
16
+ text=text,
17
+ speaker_wav=ref,
18
+ language="en",
19
+ file_path=out
20
+ )
21
+
22
+ return out
23
+
24
+ ui = gr.Interface(
25
+ fn=clone,
26
+ inputs=[
27
+ gr.Textbox(label="Text"),
28
+ gr.Audio(type="numpy", label="Reference Voice")
29
+ ],
30
+ outputs=gr.Audio(label="Cloned Voice"),
31
+ title="XTTS Voice Clone"
32
+ )
33
+
34
+ ui.launch()