RIZAEFE commited on
Commit
51cdecb
·
verified ·
1 Parent(s): ffa6a34

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -0
app.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ # coding: utf-8
3
+
4
+ # In[20]:
5
+
6
+
7
+ from gtts import gTTS
8
+ import gradio as gr
9
+ import warnings
10
+ warnings.filterwarnings('ignore')
11
+
12
+
13
+ # In[22]:
14
+
15
+
16
+ def textToSpeech(text,lang,file):
17
+
18
+ if file is not None:
19
+ with open(file.name, "r", encoding="utf-8") as f:
20
+ text = f.read()
21
+
22
+ record=gTTS(text=text,lang=lang,slow=False)
23
+ record.save("output.mp3")
24
+ return "output.mp3"
25
+
26
+
27
+ # In[25]:
28
+
29
+
30
+ interface=gr.Interface(
31
+ fn=textToSpeech,
32
+ inputs=[gr.Textbox(label='Text to be spoken'),
33
+ gr.Dropdown(
34
+ ["tr", "en", "fr", "de"],
35
+ label="Language Selection",
36
+ value="tr"),
37
+ gr.File(label="Upload Text File(Optional)",type="filepath")
38
+ ],
39
+ outputs=gr.Audio(label="Voice"),
40
+ title="Text To Speech",
41
+ description="Enter the text you want to voice into the box"
42
+
43
+ )
44
+
45
+ interface.launch()
46
+
47
+
48
+ # In[ ]:
49
+
50
+
51
+
52
+