File size: 573 Bytes
d8bd8f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import torch
from TTS.api import TTS
import gradio as gr


device = "cuda" if torch.cuda.is_available() else "cpu"

def generate_audio(text="And those who were seen dancing were tought to be insane by those who could not hear the music"):

    tts = TTS(model_name='tts_models/en/ljspeech/fast_pitch').to(device)
    tts.tts_to_file(text=text, file_path="outputs/output.wav")

    return "outputs/output.wav"

demo = gr.Interface(fn=generate_audio, 
                    inputs=[gr.Text(label="Text")], 
                    outputs=[gr.Audio(label="Audio")])


demo.launch()