File size: 659 Bytes
d2259bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
from TTS.api import TTS
tts = TTS("tts_models/en/multi-dataset/tortoise-v2")
import gradio as gr
try:
    tts.to("cuda")
except:
    print("Cuda not available")
def text_to_speech(text):
    tts.tts_to_file(text=text,
                    file_path="output.wav",
                    voice_dir="./tortoise-tts/tortoise/voices",
                    speaker="lj",
                    num_autoregressive_samples=1,
                    diffusion_iterations=10)
    
    return "output.wav"



def greet(text):
    return text_to_speech(text)

demo = gr.Interface(fn=greet, inputs="textbox", outputs="textbox")

if __name__ == "__main__":
    demo.launch()