Devity4756 commited on
Commit
d738503
·
verified ·
1 Parent(s): c044a68

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -25
app.py CHANGED
@@ -1,34 +1,24 @@
1
- import spaces
2
  import gradio as gr
3
- import torch
4
  from TTS.api import TTS
5
  import os
 
6
  os.environ["COQUI_TOS_AGREED"] = "1"
7
 
8
- device = "cpu"
9
- tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device)
10
 
11
  def clone(text, audio):
12
- tts.tts_to_file(text=text, speaker_wav=audio, language="en", file_path="./output.wav")
13
- return "./output.wav"
14
-
15
- iface = gr.Interface(fn=clone,
16
- inputs=[gr.Textbox(label='Text'), gr.Audio(type='filepath', label='Voice reference audio file')],
17
- outputs=gr.Audio(type='filepath'),
18
- title='Voice Clone',
19
- description="""
20
- by [Tony Assi](https://www.tonyassi.com/)
21
-
22
- ---
23
-
24
- ### If you like voice clone then try [Video Face Swap](https://huggingface.co/spaces/tonyassi/video-face-swap)!
25
-
26
- ---
27
 
28
- This space uses xtts_v2 model. Non-commercial use only. [Coqui Public Model License](https://coqui.ai/cpml)
 
29
 
30
- Please ❤️ this Space. <a href="mailto: tony.assi.media@gmail.com">Email me</a>.
31
- """,
32
- theme=gr.themes.Base(primary_hue="teal",secondary_hue="teal",neutral_hue="slate")
33
- )
34
- iface.launch()
 
 
1
  import gradio as gr
 
2
  from TTS.api import TTS
3
  import os
4
+
5
  os.environ["COQUI_TOS_AGREED"] = "1"
6
 
7
+ tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to("cpu")
 
8
 
9
  def clone(text, audio):
10
+ output_path = "./output.wav"
11
+ tts.tts_to_file(text=text, speaker_wav=audio, language="en", file_path=output_path)
12
+ return output_path
13
+
14
+ iface = gr.Interface(
15
+ fn=clone,
16
+ inputs=[gr.Textbox(label="Text"), gr.Audio(type="filepath", label="Voice Reference")],
17
+ outputs=gr.Audio(type="filepath")
18
+ )
 
 
 
 
 
 
19
 
20
+ # Launch and capture the interface info
21
+ server, _, _ = iface.launch(server_name="0.0.0.0", server_port=7860, share=True)
22
 
23
+ # Print the public shareable URL
24
+ print(f"Gradio link: {server.local_url} / {server.share_url}")