RIZAEFE commited on
Commit
54a1a72
·
verified ·
1 Parent(s): 241587b

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from gtts import gTTS
2
+ import gradio as gr
3
+
4
+
5
+ def textToSpeech(text,lang,file):
6
+
7
+ if file is not None:
8
+ with open(file.name, "r", encoding="utf-8") as f:
9
+ text = f.read()
10
+
11
+ record=gTTS(text=text,lang=lang,slow=False)
12
+ record.save("output.mp3")
13
+ return "output.mp3"
14
+
15
+ interface=gr.Interface(
16
+ fn=textToSpeech,
17
+ inputs=[gr.Textbox(label='Text to be spoken'),
18
+ gr.Dropdown(
19
+ ["tr", "en", "fr", "de"],
20
+ label="Language Selection",
21
+ value="tr"),
22
+ gr.File(label="Upload Text File(Optional)",type="filepath")
23
+ ],
24
+ outputs=gr.Audio(label="Voice"),
25
+ title="Text To Speech",
26
+ description="Enter the text you want to voice into the box"
27
+
28
+ )
29
+
30
+ interface.launch()