Files changed (1) hide show
  1. app.py +18 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as gr
3
+ import tempfile
4
+
5
+ # Load TTS pipeline with a model that works in Spaces
6
+ tts = pipeline("text-to-speech", model="facebook/fastspeech2-en-ljspeech")
7
+
8
+ def greet(name):
9
+ greeting = f"Hello {name}!! You're amazing!"
10
+ audio_data = tts(greeting)["audio"]
11
+
12
+ # Save to a temp WAV file
13
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as f:
14
+ f.write(audio_data)
15
+ return f.name
16
+
17
+ demo = gr.Interface(fn=greet, inputs="text", outputs=gr.Audio(type="filepath"))
18
+ demo.launch()