|
import subprocess |
|
|
|
|
|
try: |
|
subprocess.run(['python', 'setup.py', 'install', '--user'], check=True) |
|
print("Installation successful.") |
|
except subprocess.CalledProcessError as e: |
|
print(f"Installation failed with error: {e}") |
|
|
|
import gradio as gr |
|
import torch |
|
from TTS.api import TTS |
|
|
|
|
|
device = "cuda" if torch.cuda.is_available() else "cpu" |
|
|
|
|
|
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device) |
|
|
|
def voice_clone(text: str, speaker_wav: str, language: str): |
|
|
|
print("Speaker wav:", speaker_wav) |
|
tts.tts_to_file(text=text, speaker_wav=speaker_wav, language=language, file_path="output.wav") |
|
return "output.wav" |
|
|
|
iface = gr.Interface(fn=voice_clone, |
|
inputs=[gr.Textbox(label="Input the text.The limit is 300 symbols", max_lines=3), gr.Audio(type="filepath", label="Upload audio file"), gr.Radio(label="Language", choices=["ru", "en", "zh-cn", "de", "fr", "it", "pt", "pl", "tr", "ko", "nl", "cs", "ar", "es", "hu"], value="en")], |
|
outputs=gr.Audio(type="filepath", label="Output"), |
|
title="Voice Cloning") |
|
|
|
iface.launch() |