QuickLearnerAI commited on
Commit
c9239bf
·
verified ·
1 Parent(s): 6d8045f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -5
app.py CHANGED
@@ -1,11 +1,37 @@
1
  import gradio as gr
 
2
 
 
3
 
4
- def greet(name):
5
- return "Hello " + name + "!"
 
 
 
 
6
 
 
7
 
8
- demo = gr.Interface(fn=greet, inputs="textbox", outputs="textbox")
9
 
10
- if __name__ == "__main__":
11
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import pyttsx3
3
 
4
+ engine = pyttsx3.init()
5
 
6
+ def text_to_speech(text):
7
+ if not text.strip():
8
+ return None
9
+ file_path = "output.mp3"
10
+ engine.save_to_file(text, file_path)
11
+ engine.runAndWait()
12
 
13
+ return file_path
14
 
 
15
 
16
+ # Gradio UI
17
+
18
+ with gr.Blocks() as demo:
19
+ gr.Markdown("## 🗣️ Text to Speech App")
20
+ with gr.Row():
21
+ text_input = gr.Textbox(label="Enter your text", placeholder="Type something...")
22
+ with gr.Row():
23
+ output_audio = gr.Audio(label="Generated Voice", type="filepath")
24
+ submit_btn = gr.Button("🔊 Submit")
25
+
26
+ submit_btn.click(fn=text_to_speech, inputs=text_input, outputs=output_audio)
27
+
28
+ demo.launch()
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+