Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from TTS.api import TTS
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
# Load TTS Model
|
5 |
+
tts = TTS("tts_models/en/ljspeech/tacotron2-DDC", progress_bar=False).to("cpu")
|
6 |
+
|
7 |
+
def text_to_speech(text):
|
8 |
+
"""Generate Speech from Text"""
|
9 |
+
output_path = "output.wav"
|
10 |
+
tts.tts_to_file(text=text, file_path=output_path)
|
11 |
+
return output_path
|
12 |
+
|
13 |
+
# Gradio UI
|
14 |
+
gr.Interface(
|
15 |
+
fn=text_to_speech,
|
16 |
+
inputs=gr.Textbox(placeholder="Enter text to convert to speech"),
|
17 |
+
outputs=gr.Audio(),
|
18 |
+
title="Coqui TTS - Text to Speech",
|
19 |
+
description="Enter text and listen to the generated speech.",
|
20 |
+
).launch()
|