Sanmath commited on
Commit
7a0c265
·
verified ·
1 Parent(s): b4fc3c1

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +56 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from gtts import gTTS
3
+ import uuid
4
+
5
+ def text_to_speech(text, lang, speed):
6
+ slow = True if speed == "Slow" else False
7
+ filename = f"{uuid.uuid4()}.mp3"
8
+ tts = gTTS(text, lang=lang, slow=slow)
9
+ tts.save(filename)
10
+ return filename
11
+
12
+ demo = gr.Interface(
13
+ fn=text_to_speech,
14
+ inputs=[
15
+ gr.Textbox(label="Enter Text"),
16
+ gr.Dropdown(
17
+ label="Language",
18
+ choices=[
19
+ ("English", "en"),
20
+ ("Spanish", "es"),
21
+ ("French", "fr"),
22
+ ("German", "de"),
23
+ ("Italian", "it"),
24
+ ("Japanese", "ja"),
25
+ ("Korean", "ko"),
26
+ ("Russian", "ru"),
27
+ ("Chinese (Simplified)", "zh-CN"),
28
+ ("Portuguese", "pt"),
29
+ ("Hindi", "hi"),
30
+ ("Arabic", "ar"),
31
+ ("Bengali", "bn"),
32
+ ("Dutch", "nl"),
33
+ ("Greek", "el"),
34
+ ("Hungarian", "hu"),
35
+ ("Indonesian", "id"),
36
+ ("Polish", "pl"),
37
+ ("Swedish", "sv"),
38
+ ("Thai", "th"),
39
+ ("Turkish", "tr"),
40
+ ("Vietnamese", "vi")
41
+ ],
42
+ value="en"
43
+ ),
44
+ gr.Dropdown(
45
+ label="Speed",
46
+ choices=["Normal", "Slow"],
47
+ value="Normal"
48
+ )
49
+ ],
50
+ outputs=gr.Audio(label="Generated Speech", type="filepath"),
51
+ title="Text to Speech Converter",
52
+ description="Type something and convert it into speech using gTTS with language and speed selection.",
53
+ theme="gradio/space"
54
+ )
55
+
56
+ demo.launch(share=True)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gTTS
2
+ gradio