File size: 885 Bytes
d6b40b1
 
 
 
 
 
 
 
752aa18
3d8fc15
752aa18
d6b40b1
c87b7a4
752aa18
c87b7a4
 
 
 
 
 
 
 
 
 
 
 
d6b40b1
c87b7a4
 
752aa18
d6b40b1
752aa18
d6b40b1
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
30
31
32
33
34
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", gpu=False)
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)