-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathITT.py
29 lines (22 loc) · 929 Bytes
/
ITT.py
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
26
27
28
29
from PIL import Image
import pytesseract
import cv2
from GTTS import gtts
def reader():
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
capr = cv2.VideoCapture(os.environ.get('CAM_IP1'))
retr, framer = capr.read()
framer = cv2.rotate(framer, cv2.ROTATE_90_COUNTERCLOCKWISE)
cv2.imwrite(r"C:\Users\aaron\OneDrive\Desktop\text.jpg", framer)
capr.release()
confidence_threshold = 80
image_path = r"C:\Users\aaron\OneDrive\Desktop\text.jpg"
image = Image.open(image_path)
result = pytesseract.image_to_data(image, output_type=pytesseract.Output.DICT)
print(result)
filtered_text = [result['text'][i] for i, conf in enumerate(result['conf']) if conf >= confidence_threshold]
print("Extracted Text:")
text=''
for i in filtered_text:
text+=i+" "
gtts(text, r'E:\Pegasus\imageaudio.mp3')