File size: 923 Bytes
d6b40b1
 
 
 
 
752aa18
d6b40b1
c87b7a4
72d900d
c87b7a4
 
 
 
 
 
60444aa
 
72d900d
8fff576
c87b7a4
 
d6b40b1
c87b7a4
72d900d
c87b7a4
752aa18
d6b40b1
752aa18
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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

    # TTS with on the fly voice conversion
    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)