-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathsingleImageReader.py
More file actions
25 lines (22 loc) 路 701 Bytes
/
Copy pathsingleImageReader.py
File metadata and controls
25 lines (22 loc) 路 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
##SINGLE IMAGE SPEECH AND TXT##
######Tesseract code is here#########
from PIL import Image
import pytesseract
import warnings
warnings.simplefilter('ignore')
# If you don't have tesseract executable in your PATH, include the following:
pytesseract.pytesseract.tesseract_cmd = r'C:/Program Files (x86)/Tesseract-OCR/tesseract.exe'
content = pytesseract.image_to_string(Image.open('spoken text.PNG'))
######Tesseract ends HERE#########
##writing to file
file = open("test.txt", "w")
file.write(content)
file.close()
##writing ends here
##generating audio file
from gtts import gTTS
file = open("test.txt", "r")
txt = file.read()
tts = gTTS(text = txt, lang = 'en')
tts.save("read.mp3")
file.close()