File size: 759 Bytes
fb1ce3e 3c08b54 fb1ce3e 3c08b54 63d761e fb1ce3e 3c08b54 fb1ce3e 3c08b54 fb1ce3e 3c08b54 fb1ce3e |
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 |
from TTS.api import TTS
import gradio as gr
import torch
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "0" # Use GPU if available
tts = TTS(model_name="tts_models/en/ljspeech/tacotron2-DDC")
tts.to("cuda" if torch.cuda.is_available() else "cpu")
def synthesize(text):
output_path = "output.wav"
tts.tts_to_file(text=text, file_path=output_path)
return output_path
iface = gr.Interface(
fn=synthesize,
inputs=gr.Textbox(lines=3, label="Enter text to synthesize"),
outputs=gr.Audio(type="filepath", label="Generated Speech"),
title="Mozilla Tacotron2 TTS - Smooth & Clean",
description="Simple text-to-speech using Mozilla's Tacotron2-DDC model. No voice samples required."
)
if __name__ == "__main__":
iface.launch()
|