Create app.py
Browse files12345678910111213141516171819202122232425262728293031323334import osimport gradio as grfrom TTS.api import TTSimport torchimport spaces
# License acceptos.environ["COQUI_TOS_AGREED"] = "1"
# Model load (Wait for 2-3 mins first time)device = "cuda" if torch.cuda.is_available() else "cpu"tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device)
@spaces.GPU(duration=60) def clone_voice(text, language, speaker_audio): output_path = "output.wav" tts.tts_to_file( text=text, file_path=output_path, speaker_wav=speaker_audio, language=language ) return output_path
iface = gr.Interface( fn=clone_voice, inputs=[ gr.Textbox(label="Text", value="Namaste, kaise hain aap?"), gr.Dropdown(label="Language", choices=["hi", "en"], value="hi"), gr.Audio(label="Reference Audio", type="filepath") ], outputs=gr.Audio(label="Cloned Voice"))iface.launch()app.pyAdded+34