import spaces import gradio as gr import torch from TTS.api import TTS import os os.environ["COQUI_TOS_AGREED"] = "1" device = "cpu" tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device) def clone(text, audio): tts.tts_to_file(text=text, speaker_wav=audio, language="en", file_path="./output.wav") return "./output.wav" iface = gr.Interface(fn=clone, inputs=[gr.Textbox(label='Text'),gr.Audio(type='filepath', label='Voice reference audio file')], outputs=gr.Audio(type='filepath'), title='Voice Clone', description=""" by [Tony Assi](https://www.tonyassi.com/) --- ### If you like voice clone then try [Video Face Swap](https://huggingface.co/spaces/tonyassi/video-face-swap)! --- This space uses xtts_v2 model. Non-commercial use only. [Coqui Public Model License](https://coqui.ai/cpml) Please ❤️ this Space. Email me. """, theme = gr.themes.Base(primary_hue="teal",secondary_hue="teal",neutral_hue="slate")) iface.launch(show_error=True)