voice / app.py
taras5500's picture
Update app.py
b1c7a3d verified
raw
history blame
No virus
1.72 kB
import spaces
import gradio as gr
import torch
from TTS.api import TTS
import os
os.environ["COQUI_TOS_AGREED"] = "1"
device = "cuda"
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device)
@spaces.GPU(enable_queue=True)
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="""
Duplicated from https://huggingface.co/spaces/tonyassi/voice-clone
""",
theme = gr.themes.Base(primary_hue="teal",secondary_hue="teal",neutral_hue="slate"),
examples=[["Hey, it's me Messmer the Impaler. Type in whatever you'd like me to say.","./audio/Messmer_sample.mp3"],
["Hey! It's me Jolán, from the Elden Ring Shadow of the Erdtree. Type in whatever you'd like me to say.","./audio/20240728_171001.mp3"],
["It's me Vito Corleone, from the Godfather. Type in whatever you'd like me to say.","./audio/Godfather.wav"],
["Hey, it's me Megan Fox from Transformers. Type in whatever you'd like me to say.","./audio/Megan-Fox.mp3"],
["Hey there, it's me Jeff Goldblum. Type in whatever you'd like me to say.","./audio/Jeff-Goldblum.mp3"],]
)
iface.queue(api_open=True)
iface.launch(share=True, debug=True)