Skip to content

Commit 5f249c0

Browse files
authored
Merge pull request sanscript-tech#240 from Tejas1510/text
Add the code for text to Speech Converter
2 parents 79176f4 + ba5e4c2 commit 5f249c0

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

Python/TextToSpeech/Readme.MD

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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)
34.7 KB
Loading

Python/TextToSpeech/text.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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)

Python/TextToSpeech/text_content.mp3

51 KB
Binary file not shown.

0 commit comments

Comments
 (0)