|
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() |