|
import gradio as gr |
|
import os |
|
from TTS.api import TTS |
|
import time |
|
|
|
count = 0 |
|
|
|
|
|
def audio_tts(txt, language, audio_file): |
|
global count |
|
count += 1 |
|
if count > 50: |
|
time.sleep(5) |
|
os.system("rm -R /tmp/*") |
|
count = 0 |
|
|
|
|
|
api = TTS(f"tts_models/{language}/fairseq/vits", gpu=False) |
|
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.Textbox(label="Language", value="rus"), |
|
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) |
|
|