import gradio as gr import logging import os from TTS.api import TTS import time logging.basicConfig(level=logging.INFO) # TTS with on the fly voice conversion api = TTS("tts_models/deu/fairseq/vits") count = 0 def audio_tts(txt, audio_file): global count count += 1 if count > 50: time.sleep(5) os.system("rm -R /tmp/*") count = 0 api.tts_with_vc_to_file(txt, speaker_wav=audio_file, file_path="ouptut.wav") return "ouptut.wav" demo = gr.Interface(fn=audio_tts, inputs=[gr.Textbox(label="Input text TTS", value="Привет! Я Макс."), gr.Audio(source="upload", type="filepath", label="Input audio")], outputs=gr.Audio(source="upload", type="filepath", label="Output audio")) demo.queue(concurrency_count=1).launch(show_error=True)