File tree Expand file tree Collapse file tree 4 files changed +62
-0
lines changed Expand file tree Collapse file tree 4 files changed +62
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Text to speech Converter
2
+
3
+ ### Third Party Libraries Required :
4
+ 1.GTTS
5
+ gtts, stands for the Google-Text-To-Speech module that is used to convert text to speech
6
+
7
+ 2 . pytesseract
8
+ It is used for recognition of words
9
+
10
+ ### How to install above Library
11
+ ```
12
+ pip install gtts
13
+ pip install pytesseract
14
+ ```
15
+
16
+ ### How to use it :
17
+ 1 . Download or clone the repository
18
+ 2 . Install Required Libraries
19
+ 3 . Run text.py
20
+ 4 . You will be given two option to enter text or enter file
21
+ 5 . you will get .mp3 file in the same folder
22
+
23
+
24
+ ![ endpoint] ( https://github.com/Tejas1510/hacking-tools-scripts/blob/text/Python/TextToSpeech/images/image1.png )
25
+
26
+
27
+ ![ built with love] ( https://forthebadge.com/images/badges/built-with-love.svg )
28
+
29
+ Check out my Github profile [ Tejas1510!] ( https://github.com/Tejas1510 )
Original file line number Diff line number Diff line change
1
+
2
+ from gtts import gTTS
3
+ import os
4
+
5
+
6
+ import pytesseract
7
+ from PIL import Image
8
+
9
+ language = "en"
10
+ print ("Option 1, Enter Text : \n " )
11
+ print ("Option 2, Enter File Name : \n " )
12
+
13
+
14
+
15
+ def convert_text_to_speech (option ):
16
+
17
+ text = ""
18
+ if option == 1 :
19
+ text = input ("Enter the text : " )
20
+
21
+ elif option == 2 :
22
+ file_name = input ("Enter the name of the text file : " )
23
+ with open (file_name , "r" ) as handle :
24
+ text = handle .read ().replace ("\n " , "" )
25
+
26
+ speech = gTTS (text = text , lang = language , slow = True )
27
+ speech .save ("text_content.mp3" )
28
+ print ("Speech File Gererated" )
29
+
30
+
31
+ if __name__ == "__main__" :
32
+ option = int (input ("Enter the option " ))
33
+ convert_text_to_speech (option )
You can’t perform that action at this time.
0 commit comments